JAXB XML output format questions
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 );}