[jdom-interest] SAXBuilder inserts unwanted carriage return

Philippe Converset pconverset at Qarbon.com
Tue Oct 30 02:26:47 PST 2001

When you create a document using SAXBuilder.build(), it seems that a 
carriage return is inserted at each end of line. And when you output the 
loaded document, it leads to ugly indentation.

This is particularly true on script elements where
  is inserted on EACH line.

Here is a small code that shows the problem
public void showError()
     InputStream input;
     Document document;
     SAXBuilder builder;
     XMLOutputter outputter;

       outputter = new XMLOutputter("  ", true);
       builder = new SAXBuilder();
       // Use your own xml file defining a script
       document = builder.build(new File("myDocument.xml"));
       outputter.output(document, System.out);
     catch(Exception e)

It is not a big deal, but if you want to use templates to generate your 
final XML files, then you got badly indented files and human unreadable 

Can the wonderful jdom team try to fix that for the next release?

Philippe Converset

More information about the jdom-interest mailing list