[jdom-interest] XMLOutputter extraspacing in reused Documents

philip.nelson at omniresources.com philip.nelson at omniresources.com
Fri May 11 06:47:17 PDT 2001


There are a couple of setting for whitespace in the XMLOutputter.
Generally, if you want to have a human readable output, you will set the
indent and newlines to true in the contstructor and setTrimText to remove
the original whitespace.  Without the last step, whitespace just keeps
getting added on.

> -----Original Message-----
> From: Jon Baer [mailto:jonbaer at digitalanywhere.com]
> Sent: Thursday, May 10, 2001 5:02 AM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] XMLOutputter extraspacing in reused Documents
> 
> 
> Normally Ive used JDOM for outputting an XML stream without 
> having to reuse the XML
> document, but in something I just did I get extra returns in 
> the previously built
> Document between the Elements:
> 
> <?xml version="1.0"?>
> <aiml version="1.0">
> 
>   <category>
> 
>     <pattern>THIS IS TARGET * 1</pattern>
> 
>     <template>Sorry.  I don't know.</template>
> 
>   </category>
> 
>  <category>
>   <pattern>THIS IS TARGET * 2</pattern>
>   <template>Sorry.  I don't know.</template>
>  </category>
> </aiml>
> 
> Using the latest build I beleive, any ideas?
> 
> - Jon
> 
> Code:
> 
> File file = new File(TARGETS_AIML);
>    SAXBuilder builder = new SAXBuilder();
>    Document doc = builder.build(file);
>    XMLOutputter out = new XMLOutputter(" ", true);
>    out.setOmitEncoding(true);
>    out.setLineSeparator("\n");
>    Element root = doc.getRootElement();
> 
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com



More information about the jdom-interest mailing list