You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Hendrik van der Linde <H....@qualityonline.com> on 2004/04/23 09:08:33 UTC

Fw: difference between attribute and element NS

Hello,

I have sent this message to the xerces-j-user mailing before, but have not 
gotten a reaction, maybe you can help me with this?

thanks, Hendrik van der Linde

> Hi,
> 
> I have a question for you regarding the difference between 
> NameSpaces of attributes and elements.
> 
> For elements it is possible to use the method getElementsByTagNameNS
> (String, String) which returns all elements within the supplied 
> namespace and with the given name. The nice thing is that it allows 
> you to use the wildcard ("*") as a namespace, thus returning all 
> elements with the supplied name, regardless of namespace. I make 
> heavy use of this.
> For attributes it's another story. I can use getAttributeNodeNS to 
> get an attribute by namespace. But if the namespace does not exist, 
> it returns null. Also, using the wildcard is not possible. Is this 
> by design / according to the specification? It's a tedious job to go
> over possible namespaces (that you sometimes even don't know 
beforehand).
> 
> Any tips, or suggestions for using another method for the latter 
> case are very welcome. (If there is no solution I can always 
> implement the behaviour for attributes to macth the behaviour of 
> elements myself, of course).
> 
> bye, Hendrik

Re: Fw: difference between attribute and element NS

Posted by Neil Delima <nd...@ca.ibm.com>.



Hi Hendrik,

> For attributes it's another story. I can use getAttributeNodeNS to
> get an attribute by namespace. But if the namespace does not exist,
> it returns null. Also, using the wildcard is not possible. Is this
> by design / according to the specification? It's a tedious job to go
> over possible namespaces (that you sometimes even don't know beforehand).

>

This is according to the DOM specification[1].  You could try
Element.getAttributes()[2] which returns a NamedNodeMap of Attr nodes, but
not sure if that works for you.

Neil.

[1]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-ElGetAtNodeNS
[2]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-84CF096




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org