[jdom-interest] Bug in XMLOutputter or Element.addAttribute
depending on whether null is valid
Jason Hunter
jhunter at collab.net
Thu Nov 16 19:57:33 PST 2000
Scott M Stark wrote:
>
> The Element class allows one to add an attribute with a null
> value. However, when you try to output such an element with the
> XMLOutputter it crashes because it does not
> protect against attributes having null values. This is with the
> jdom b5 release.
We need a Verifier.checkAttributeValue() call, and it should protect
against null values. Elliotte, do you want to handle this as Verifier
master?
-jh-
>
> bash-2.04$ cat tstOut.java
> import java.io.*;
> import org.jdom.*;
> import org.jdom.output.*;
>
> class tstOut
> {
> public static void main(String[] args) throws Exception
> {
> Element root = new Element("ProjectInfo");
> root.addAttribute("name", "project1");
> root.addAttribute("description", null);
> Document doc = new Document(root);
> XMLOutputter output = new XMLOutputter(" ");
> output.output(doc, new FileOutputStream("out.xml"));
> }
> }
> bash-2.04$ java -classpath ".;build/jdom.jar" tstOut
> Exception in thread "main" java.lang.NullPointerException
> at org.jdom.output.XMLOutputter.escapeAttributeEntities(XMLOutputter.java:1143)
> at org.jdom.output.XMLOutputter.printAttributes(XMLOutputter.java:1125)
> at org.jdom.output.XMLOutputter.printElement(XMLOutputter.java:907)
> at org.jdom.output.XMLOutputter.output(XMLOutputter.java:522)
> at org.jdom.output.XMLOutputter.output(XMLOutputter.java:494)
> at org.jdom.output.XMLOutputter.output(XMLOutputter.java:453)
> at tstOut.main(tstOut.java:14)
> bash-2.04$
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list