[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(new Element("child"));
        XMLOutputter o1 = new XMLOutputter("  ",true);
        try {
        } catch (java.io.IOException  ex) {
            System.err.println("ex - "+ex);

    public static void main(String args[]) {
        new Z();

Currently it prints:

text  <child />

This is definitely wrong.  It should probably print the following:

  text<child />

Or maybe:

  <child />

(Which is better?  Hmm...)

You can reverse the text/child items for other strange results.


More information about the jdom-interest mailing list