[jdom-interest] Attribute and Namespace

Tom M. Yeh tomyeh at infoshock.com.tw
Thu Oct 4 00:15:04 PDT 2001


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));

-----Original Message-----
From: Jason Hunter [mailto:jhunter at collab.net]
Sent: Thursday, October 04, 2001 2:50 PM
To: Tom M. Yeh
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] Attribute and Namespace


JDOM uses Xerces (or some other parser) so your statement is a little
odd.  It might be that JDOM differs from the DOM built by Xerces. 
Before we get into that, have you tried this with the latest code in
CVS?  

-jh-

"Tom M. Yeh" wrote:
> 
> Hi,
> 
> 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.
> 
> After looking the source codes, I found SAXHandler seems not adding element's namespace to availableNamespaces. Thus, when SAXHandler.getNamespace got called for the attribute, no namespace is found!
> _______________________________________________
> 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