[jdom-interest] XMLOutputter NPE

Will Glozer will.glozer at jda.com
Thu Aug 3 15:19:58 PDT 2000


I'm just starting to use JDOM, so please forgive me in advance if this is
a known issue... I looked through the more recent logs and didn't see 
anything.

        XMLOutputter xmlOut = new XMLOutputter();

        Element e = new Element("test");
        Document doc = new Document(e);
        e.setText("");

        xmlOut.output(doc, System.out);

That code will throw a NullPointerException inside XMLOutputter.output
because
the contents of the Element is an empty string... The question I have is
whether
or not JDOM will ever be able to distinguish between empty,
String.equals(""), 
Element content and null, String == null, content.

I was able to do this with W3C DOM, so I'd like to see it in JDOM.  Perhaps
consider doing "<tag />" as null content and "<tag></tag>" as empty content?

Thanks,
Will



More information about the jdom-interest mailing list