users@jaxb.java.net

Re: Unmarshalling a DOM node to an XML file with JAXB

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 04 Mar 2003 08:02:04 -0800

The problem is that you are building non-namespace aware DOM:

> Element itemListElt = (Element)doc.createElement("item_list");

Instead, you have to say:

> Element itemListElt = (Element)doc.createElementNS("","item_list");

JAXB dies trying to read namespace URIs and local names from DOM, which
is not available.


I'm not sure whose problem this is. JAXB RI can be certainly modified to
read this sort of DOM, but I'm not sure if it's a good idea to
automatically recover from "incorrect" inputs.

On the other hand, I don't think this NullPointerException is very helpful,
so perhaps we should just improve the error message.

A part of me thinks it's a DOM problem. I believe other better DOM
implementations like dom4j don't have this kind of design problems.

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com