This should be simple request – How can I programmatically set Marshaller to indent the generated XML?

 

I do not want to set my “customized” castor.properties file on the classpath because of deployment concerns. I did see Keith Visco’s reply  to the same question on Fri Dec 07 2001, but obviously things have changed since then. So what is the recommended approach now?

 

Just for reference, here is the text of the original posting and Keith’s reply.

 

You can use:

Serializer serializer = Configuration.getSerializer();

serializer.setOutputCharStream(writer);

OutputFormat format = Configuration.getOutputFormat();

format.setIndent(true);

serializer.setOutputFormat(format);

Marhaller marshaller = new Marshaller(serializer.asDocumentHandler());

--Keith

Youri Canetti wrote:
>
> Hello,
>
> is there a way to _programmatically_ set the "org.exolab.castor.indent"
> property? in other words, is there a way to force a Marshaller to indent the
> generated XML?
> the only way I found is a bit brutal, as it affects all castor output:
>
> Configuration.getDefault().setProperty(Configuration.Property.Indent,
> "true");
> I could save the previous state and restore it after using my Marshaller,
> but in that case I also need to make a synchronized block. any more elegant
> solution?
>
> youri
>

 

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

Reply via email to