Hi Andrew,
Andrew Norton wrote:
> Hello,
>
> I need my XML output to look like the following even if it isn't "valid".
>
> <mchoice>
> <question>
> Some data
> </question>
> <answer Correct="Yes">
> Firewalking
> </answer>
> <answer Correct="No">
> IDLE scanning
> </answer>
> <answer Correct="No">
> Footprinting
> </answer>
> <answer Correct="No">
> Enumeration
> </answer>
> <feedbackonincorrect>
> Some data
> </feedbackonincorrect>
> </mchoice>
>
> I've tried to insert a newline in my marshal method of the custom
> converter that handles this object. I can't seem to get the desired
> solution. Any advice is very appreciated.
You cannot modify the format of the XML with a converter. That one handles
only "values". You can try with a derived PrettyPrintWriter:
====================== %< ====================
class MyWriter extends PrettyPrintWriter {
// ...
protected void writeText(QuickWriter writer, String text) {
endOfLine();
super.writeText(writer, text);
endOfLine();
}
}
XStream xstream(new XppDriver() {
public HierarchicalStreamWriter createWriter(Writer out) {
return new MyWriter(out, getNameCoder());
}
});
String xml = xstream.toXML(object);
====================== %< ====================
> Thank you and Happy New Year!
Cheers,
Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email