Hello,
I have found the perfect solution to my problem.
I have subclassed org.apache.xml.serialize.XMLSerializer in this way:
package org.apache.xml.serialize;
import java.io.IOException;
import org.apache.xml.serialize.ElementState;
import org.apache.xml.serialize.XMLSerializer;
public final class XMLNotContractedSerializer extends XMLSerializer {
public void endElementIO(String arg0, String arg1, String arg2) throws
IOException {
_printer.unindent();
ElementState elementState = getElementState();
if (elementState.empty){
_printer.printText(">");
if (_indenting) {
_printer.breakLine();
}
_printer.printText("</");
_printer.printText(elementState.rawName);
_printer.printText('>');
}
else
{
if (elementState.inCData)
_printer.printText("]]>");
if (_indenting && !elementState.preserveSpace &&
(elementState.afterElement || elementState.afterComment))
_printer.breakLine();
_printer.printText("</");
_printer.printText(elementState.rawName);
_printer.printText('>');
}
elementState = leaveElementState();
elementState.afterElement = true;
elementState.afterComment = false;
elementState.empty = false;
if (isDocumentState())
_printer.flush();
}
}
As you can see, also when elementState.empty is true I put the end-tag in a
new line.
Then, in my application main function I have added the following line:
LocalConfiguration.getInstance().getProperties().setProperty("org.exolab.cas
tor.serializer", "org.apache.xml.serialize.XMLNotContractedSerializer");
In this way, Castor marshal my objects with my serializer.
It works !!
=================================
Hi all,
I need to use ALWAYS an end-tag containing a name that echoes the element's
type as given in the start-tag.
For example, now marshal method produce the following stream:
<REQUEST Service="Alarm"/>
I need, on the other hand, this result:
<REQUEST Service="Alarm">
</REQUEST>
Is there any way to obtain this ?
Thank you,
Daniele Marelli
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev