[jdom-interest] Formatting output

Oliver Hirschi o.hirschi at bluewin.ch
Wed Feb 27 05:22:59 PST 2008


I'm realy confused. In my example formatting the output does not work 
correctly and I have no idea to solve this. I'm using JDOM 1.1.

1. I read a SVG file with JDOM.
2. I make some changes in the xml-tree (new elements, detach elements, 
3. I write the tree to file with the following code:
XMLOutputter oXMLOutputter = new XMLOutputter();
Format oFormat = Format.getPrettyFormat();
FileOutputStream oFileOutputStream = new FileOutputStream(sFileChart);
OutputStreamWriter oOutputStreamWriter = new 
OutputStreamWriter(oFileOutputStream, "UTF-8");
oXMLOutputter.output(oDoc_Chart, oOutputStreamWriter);

Now, my written XML is not formatted "pretty", e.g. where I detached an 
element, a blank line is in the file and the identing is also not 
correct. I also tried to set "oFormat.setLineSeparator("\n\n\n");", so 
there comes three newlines before the root-element, but the content of 
the root-element is not formatted???

Great thanks & kind regards,
Oliver Hirschi 

More information about the jdom-interest mailing list