On Wednesday, March 5, 2003, at 04:03 PM, Malachi de AElfweald wrote:
> On Wed, 5 Mar 2003 15:11:09 -0800, Kohsuke Kawaguchi
> <Kohsuke.Kawaguchi_at_Sun.COM> wrote:
>>> However, shouldn't a user be able to use this API without REQUIRING a
>>> 3rd party application/API to make it work correctly?
>>
>> Yes. We do want to address these XML writer related issues in future
>> releases, but I thought it's equally important to give the users the
>> way
>> to solve the problem with what we have today.
>
> Agreed.
>
> Is there any way, currently, without using 3rd party stuff, to
> Marshall it correctly to a file or stream or whatever? Perhaps
> outputting it via JAXP or something....?
>
> Malachi
>
I use javax.xml.bind.util.JAXBResult and then feed that into an XSLT
transformer to get nicely indented output.
Here's what you can find from the API doc:
JAXBResult result = new JAXBResult(
JAXBContext.newInstance("org.acme.foo") );
// set up XSLT transformation
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer(new StreamSource("test.xsl"));
// run transformation
t.transform(new StreamSource("document.xml"),result);
// obtain the unmarshalled content tree
Object o = result.getReult();