That can happen if the DOM was built with a non-namespace-aware parser, in
which case each of the element nodes [1] will have a null local name.
Calling namespace-aware methods on non-namespace-aware nodes (and vice
versa) is a common usage error. If that's what you're doing, building the
DOM with a namespace-aware parser (i.e. setting
DocumentBuilderFactory.setNamespaceAware(true)) should fix your problem.
Thanks.
[1]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-2141741547
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@xxxxxxxxxx
E-mail: mrglavas@xxxxxxxxxx
"Jae Kwon" <jae@xxxxxxxxx> wrote on 05/12/2006 05:35:20 PM:
>
> **** bug? ****
>
> I have a Document object created by DocumentBuilder, whose
> (Element)parent.getElementsByTagNameNS(null, "*").item(0) returns an
> Element with name "Url" with namespaceURL of null. The NodeList only
> has this 1 element.
>
> However the following statement returns null:
> (Element)parent.getElementsByTagNameNS(null, "Url").item(0)
>
> as does the following.
> (Element)parent.getElementsByTagNameNS("", "Url").item(0)
> (Element)parent.getElementsByTagNameNS("*", "Url").item(0)
>
>
> I am working with Java :
> java version "1.5.0_05"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
>
> I am using Xerces version 2_7_1. (I have included this in my
> classpath. Perhaps my JRE will override this, I'm not sure.).
> I know that the Element is a xerces Element.
>
> Is this in any way at all OK behavior or does this expose a bug in
> xerces 2_7_1?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xxxxxxxxxxxxxxxxx
> For additional commands, e-mail: j-users-help@xxxxxxxxxxxxxxxxx
|