Java Mailing List Archive

http://www.junlu.com/

Home » JDOM Projects »

[jdom-interest] Formatting output

Oliver Hirschi

2008-02-27


Author LoginPost Reply
Hi

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,
etc.)
3. I write the tree to file with the following code:
------------------
XMLOutputter oXMLOutputter = new XMLOutputter();
Format oFormat = Format.getPrettyFormat();
oXMLOutputter.setFormat(oFormat);
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


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.