[jdom-interest] XMLOutputter PI and formatting problem...

John Pang jpang at viviance.com
Tue Aug 7 09:38:54 PDT 2001


I'm having some trouble with the XMLOutputter.

I have some xml files, which I would like to remain relatively 'untouched'.
I've got some basic code which builds a Document and writes it out again. So
at the moment, the code should just output without any changes.

SAXBuilder builder = new SAXBuilder();
Document document = builder.build(inFile);
XMLOutputter outputter = new XMLOutputter();
outputter.output(document, writer);

There are some things which I don't understand with the output.

* I use the default constructor for XMLOutputter. In my output file I get
the XML declaration on the 1st line, my doctype declaration on the 2nd line
and the rest of the xml file on the 3rd line. Is there a way to preserve my
original formatting so that i don't get the rest of my xml file on just the
3rd line?

* On the beginning of the third line i get a PI, <?ATTLINK img-ref sliid
"SLI"?>, which was not in the original xml file (but was in the dtd). Why
does this happen, and is there a way that I can suppress this from appearing
in the outputted xml file?

Thanks in advance,
John Pang

More information about the jdom-interest mailing list