W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2000

Re: setting Node.prefix

From: Philippe Le Hegaret <plh@w3.org>
Date: Fri, 22 Dec 2000 16:29:35 +0100
Message-ID: <3A43735F.E6A91AFB@w3.org>
To: Garret Wilson <garret@globalmentor.com>
CC: www-dom list <www-dom@w3.org>
Garret Wilson wrote:
> The documentation for Node.prefix says that Node.prefix will always be null
> if (for example) an element was created with DOM Level 1
> Document.createElement(). Yet there seems to be no restriction in setting
> the prefix (Node.setPrefix()) after the node is created.

If you use Document.createElement(tagName), the namespaceURI of your Element
node will be null:
Return Value 
  A new Element object with the nodeName attribute set to tagName, and
  localName, prefix, and namespaceURI set to null.

-- Document Object Model Core
Thu, 09 Nov 2000 23:18:19 GMT

Now, if you try to set the prefix with a null namespaceURI, you'll get
NAMESPACE_ERR: Raised if the specified prefix is malformed, if the namespaceURI
of this node is null, [...]

-- Document Object Model Core
Thu, 09 Nov 2000 23:18:19 GMT

There is no way to set the prefix on a DOM Level 1 node.

> 1. In all elements, does setting Node.nodeName update Node.prefix? (Why not?
> The converse is true, after all.)
> 2. In all elements, does setting Node.nodeName update Node.localName? (If #1
> is true, then this should be the case for consistency.)

Node.nodeName is read only. You can't set it.

> In other words, I would assume that, if the following takes place, the
> corresponding value changes will occur):
> Step 1: Document document=myDocument.createElement("myNS:myElement")
> {nodeName="myNS:myElement"; prefix=null; localName=null;}

and namespaceURI=null;
> Step 2: myDocument.setPrefix("yourNS") {nodeNS="yourNS:myElement";
> prefix="yourNS"; localName="myElement"}

Step 2 raises a NAMESPACE_ERR DOMException.

Received on Friday, 22 December 2000 10:29:42 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:07 UTC