W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2001

Re: getAttributeNode vs getAttributeNodeNS

From: Ray Whitmer <rayw@netscape.com>
Date: Wed, 14 Feb 2001 03:37:33 -0800
Message-ID: <3A8A6DFD.1070808@netscape.com>
To: Paolo Casarini <casarini@CS.UniBO.IT>
CC: www-dom@w3.org
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT