[jdom-interest] XMLOutputter indent problems

Abe Mishler Abe at WhiteBeachStudios.com
Wed May 21 05:48:57 PDT 2003


This is exactly the problem I was having. The following seems to be the 
generally accepted fix to prevent "bloating" in 9:

In your code,

XMLOutputter outputter = new XMLOutputter("  ", true, "ISO-8859-1");
outputter.setTrimAllWhite(true);

 - or -

XMLOutputter outputter = new XMLOutputter();
outputter.setEncoding("ISO-8859-1");
outputter.setIndent("  ");
outputter.setNewlines(true);
outputter.setTrimAllWhite(true);

In both examples, the last line is the key.

Hope this helps,
 - Abe Mishler
White Beach Studios, USA

On Tue, 20 May 2003 21:44:32 +0200, Roy van der Kuil 
<roy_van_der_kuil at hotmail.com> wrote:

> Hi,
>
> I am having problems with writing a previously readed xml-file.
> if I have a file that says:
> <fruits>
> 	<fruit name="banana"/>
> 	<fruit name="apple"/>
> </fruits>
>
> And I read it in (using SAXBuilder)
> and after that do an new XMLOutputter("   ", true).output(fruitDocument, 
> file);
> I get:
> <fruits>
>
> 	<fruit name="banana"/>
>
> 	<fruit name="apple"/>
>
> </fruits>
>
> After re-reading  and rewritng that another empty line is added between 
> the elements.
>
> I;have replaced the XMLOutputter from beta-9 with the one from beta-8 and 
> that fixes the problem.. Any clues?
>
> -Roy
>
> _________________________________________________________________
> Protect your PC - get McAfee.com VirusScan Online 
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom- 
> interest/youraddr at yourhost.com
>
>



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/




More information about the jdom-interest mailing list