[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
"<![CDATA[
]]>"
  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;
     try
     {
       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 
scripts.
Can the wonderful jdom team try to fix that for the next release?
Thanks,
Philippe Converset
    
    
More information about the jdom-interest
mailing list