Re: getAttributeNode vs getAttributeNodeNS

Paolo Casarini wrote:

> With an xml element like this:
> 
> <TEST xmlns:pippo="urn:ex.ex.ex" FOO="bar" pippo:CIPPO="lippo" />
> 
> if I call on the TEST element object the method getAttributeNode("FOO") I
> get the attribute object of FOO, if I call the
> getAttributeNodeNS("urn:ex.ex.ex","CIPPO") I get the attribute object of
> CIPPO, 
> but if I call getAttributeNode("CIPPO") I should get CIPPO Attribute
> Object or NULL?

Assume a level 2 aware parser which created the pippo:CIPPO attribute 
with both namespaceURI and prefix, enabling it to be compatible with 
both level 1 and level 2 NS calls.  In this case, I believe:

getAttributeNode("CIPPO") returns a null, whereas
getAttributeNode("pippo:CIPPO") returns the CIPPO attribute object, 
enabling level 1 applications which passed in a qualified name to the 
old style methods to continue to work as they did with level 1 DOMs 
which completely ignored the prefix and treated it as part of the name.

If, on the other hand, the attribute were created by a level 2 
application which did not bother to set the prefix because it knew that 
the serializer would fix it all in the end, then:

getAttributeNode("CIPPO") returns the CIPPO attribute object
getAttributeNode("pippo:CIPPO") returns nothing because by manipulating 
the document using level 2 methods (without bothering to set prefixes, 
as a parser would) the application forfeits the ability to be compatible 
with level 1 calls that were effectively superceded by level 2 NS methods.

That's the way I understand it, anyway.

Ray Whitmer
rayw@netscape.com

Received on Wednesday, 14 February 2001 06:32:41 UTC