Heiko,

Please take a look at the org.apache.xml.serialize package in the Xerces
distro. Here are two classes you need: OutputFormat and XMLSerializer.

Create an OutputFormat with our custom properties (*way* more options than
just 'indent=true'!) like this:

OutputFormat of = new OutputFormat();
of.setIndenting( true );
of.setIndent( 2 );  // 2-space indention
of.setLineWidth( 16384 );  // As large as needed to prevent linebreaks in
text nodes
of. ...

XMLSerializer serializer = new XMLSerializer( new FileWriter(
"test-output.xml" ), of );

marshaller.marshal( objectRoot, serializer.asContentHanddler() );  //
Marshal 'objectRoot' to the file 'test-output.xml'


That's it!

HTH,

Bart Guijt

(BTW: IIRC this serializer originates from the Castor codebase!)

----- Original Message -----
From: "Heiko Erhardt" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 06, 2002 7:31 PM
Subject: [castor-dev] XML: Link breaks in indent mode


> When setting the org.exolab.castor.indent property to true,
> Castor nicely indents the generated xml.
> However, it also inserts line breaks in long strings that are marshalled
> as elements. These line breaks will be retained when unmarshalling
> the document. Any idea how to get rid of this behavior?
>
> Heiko Erhardt
> skynamics AG
> www.skynamics.com

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to