[jdom-interest] Saving Formatted XML preserving whitespaces ?

Jason Hunter jhunter at xquery.com
Mon Aug 16 10:25:08 PDT 2004


You're hoping for JDOM to preserve whitespace while at the same time 
beautifying whitespace.  Think about that for a sec.  :)

The XMLOutputter defaults are to not alter whitespace.  By choosing a 
pretty format, you're giving it permission to trim and add as necessary. 
  You can use xml:space="preserve" attributes to disallow whitespace 
altering within a certain element's content.

-jh-

Vikas Mane wrote:

> Hi Geeks
> 
> I am using Format.getPrettyFormat() with  format.setIndent("   ")  to 
> save the XML.
> 
> Using the above method doesnt allow to preserve the whitespaces between 
> the Elements,
> Eg  : <MyText>         hi              </MyText>
> Jdom trims the whitespaces .
> 
> On using the  Format.TextMode./PRESERVE/ , the xml is not saved in 
> proper format.
> *
> Can any buddy suggest some way to save xml in proper format ( preserving 
> white spaces).*
> 
> 
> Regards
> 
> Vikas Mane
> Kenati Technologies
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com


More information about the jdom-interest mailing list