[jdom-interest] Attribute and Namespace

Brett McLaughlin brett at newinstance.com
Sun Oct 7 17:33:44 PDT 2001


> > I found a behavior of JDOM differs from Xerces. When parsing the
following XML (thru SAXBuilder+Xerces).
> >
> > <ns:ele xmlns:ns="http://anydomain" ns:attr>
> > ...
> >
> > Then, the namespace of the 'attr' attribute is NO_NAMESPACE, rather than
the ns namespace. On the other hand, it works well if I use JAXP + Xerces.


> In my test case, JDOM uses SAXBuilder and then SAXHandler, while DOM uses
the Xerces DOM builder. So, the result might be different.
>
> I apologize that I didn't try the latest code, before asking questions.
After browsing the source codes, I found the problem "shall" be fixed
because Brett has commented out statements at line 496-498. However, this
fix looks odd to me, because it introduces a side effect: adding an extra
namespace to Element.additionalNamespace. Won't it be better by replacing
line 528 as follows?
>
> attribute = factory.attribute(attLocalName, atts.getValue(i),
> element.getNamespace(attPrefix));

Tom-

  I have some ideas here, and would like to try your suggestion as well as
some of my own thoughts. Would you send in a sample XML document and a
simple test case, just to get you a little more involved?

  We could then test your suggestion, and get it into CVS.

Thanks
---
Brett McLaughlin          <http://www.newInstance.com>
Lutris Technologies       <http://www.lutris.com>
Author, Java and XML <http://www.oreilly.com/catalog/javaxml2>




More information about the jdom-interest mailing list