[jdom-interest] XMLOutputter odd indenting
Jason Hunter
jhunter at collab.net
Wed Mar 14 22:09:27 PST 2001
Here's an old XMLOutputter issue sent to me via private email that I'm
posting to the list so it'll be archived. Kudos to anyone who addresses
it before I get to it.
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
public class Z {
/**
* Creates new demo
*/
public Z() {
Element root = new Element("root");
root.addContent("text");
root.addContent(new Element("child"));
XMLOutputter o1 = new XMLOutputter(" ",true);
try {
o1.output(root,System.out);
} catch (java.io.IOException ex) {
System.err.println("ex - "+ex);
ex.printStackTrace(System.err);
}
}
public static void main(String args[]) {
new Z();
}
}
Currently it prints:
<root>
text <child />
</root>
This is definitely wrong. It should probably print the following:
<root>
text<child />
</root>
Or maybe:
<root>
text
<child />
</root>
(Which is better? Hmm...)
You can reverse the text/child items for other strange results.
-jh-
More information about the jdom-interest
mailing list