JAXB XML output format questions JAXB XML output format questions xml xml

JAXB XML output format questions


Indenting occurs modulo 8, in

com.sun.xml.bind.v2.runtime.output.IndentingUTF8XmlOutput

you find

int i = depth%8;


One of the overloads of the marshal() method of the marshaler accepts an XMLStreamWriter, so you can bypass the brain-damaged formatting mechanism of the Reference Implementation of JAXB by writing your own formatting XML stream writer. You would end up doing something like this:

public static void SaveContainer( Container container, OutputStream stream ) throws ...{    XMLOutputFactory factory = XMLOutputFactory.newInstance();    XMLStreamWriter writer = factory.createXMLStreamWriter( stream, "UTF-8" );    writer = new MyAwesomeCoolFormattingXMLStreamWriter( writer );    marshaller.marshal( container, writer );}


I don't think there's a limit. I've seen very deep nesting, without any difficulties. Do you have any whitespace control in place? Also, you haven't provided the definition of the RateThreshold class, which is the one creating the unexpected output.