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

setAttributeNS vs. setAttributeNodeNS

From: Keith W. Boone <kboone@ebt.com>
Date: Tue, 21 Mar 2000 09:40:02 -0500
To: <www-dom@w3.org>
Message-ID: <003401bf9343$57e06980$767770c6@ebt.com>
In reading the specification for setAttributeNS vs. setAttributeNodeNS, I
have a question about the distinctions made between changing and replacing
nodes in these two methods.

setAttributeNS indicates that:
If an attribute with the same local name and Namespace URI is already
present on the element, its prefix is changed to be ...

whereas setAttributeNodeNS indicates that:
If an attribute with that local name and Namespace URI is already present in
the element, it is replaced by the new one.

Assuming the following Java statements are executed:

	attr.setValue("foo");
	element.setAttributeNodeNS(attr);
	element.setAttributeNS(attr.getNamespaceURI(), attr.getName(), "bar");

What will be returned by attr.getValue()?
According to the specification, it appears that the value must be "bar".  Is
this intentional, or can it be up to the implementation whether an existing
attribute is changed or replaced with a new attribute.

	Keith
Received on Tuesday, 21 March 2000 09:40:31 GMT

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