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

Re: Feature suggestion: Hook property on Node

From: Philippe Le Hegaret <plh@w3.org>
Date: Thu, 31 Jan 2002 10:58:52 -0500
Message-ID: <3C5969BC.67CFB64@w3.org>
To: Ronald Bourret <rpbourret@rpbourret.com>
Cc: www-dom@w3.org, xml-dev <xml-dev@lists.xml.org>
Ronald Bourret wrote:
> [...]
> > Check the DOM Level 3 Core draft:
> > http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020114/core.html#Node3-setUserData
> [...]
> That does exactly what I need. (My code wouldn't use the UserDataHandler
> interface, but it's easy to imagine code that would.) My only objection
> is the name "DOMKeyObject", which sounds like a key, not data.
> "DOMDataObject" or "DOMUserDataObject" would be better.

Good point.

> > > Another use (inspired by recent discussions on xml-dev) would be storing
> > > the current namespace scoping information. I am certain that many other
> > > uses/abuses could be found as well.
> >
> > As a side comment, the DOM Level 3 XPath gives you this information:
> > http://www.w3.org/TR/2001/WD-DOM-Level-3-XPath-20011031/xpath.html#XPathNamespace
> >
> > We didn't find any interest or enough use cases to add this Node into
> > the DOM Level 3 Core module. XPath was our only main one.
> 
> Too bad. This would be useful for anyone traversing the tree and wanting
> to discover what namespace declarations are in force at the time. Two
> use cases are:
> 
> 1) Figuring out if you need to add an xmlns attribute after moving a
> node from one location to another. (I would prefer that DOM did this for
> you, but in the absence of that, this node would be very useful. The
> alternative is to traverse the path back to the root and figure it out
> myself. Yech.)

The DOM will do that for you but not automatically. It is one of the purposes of the
normalizeDocument method:
http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020114/core.html#Document3-normalizeDocument

This method works with the normalization features (also used in the Load and
Save module. One of them is "namespace-declarations" and is activated by default.
Calling normalizeDocument will add the appropriate xmlns declarations for you.

> 2) Resolving QNames in attribute or element content. I'm not sure how
> many languages do this, but at least some do.

We're still working on that but you can take a look at lookupNamespaceURI
and lookupNamespacePrefix on the Node interface:
http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020114/core.html#Node3-lookupNamespacePrefix
http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020114/core.html#Node3-lookupNamespaceURI

We are currently improving the namespace algorithms and default namespace handling.

> Note that it would be most useful if, instead of having a set of
> Namespace Nodes, I could simply call Node.getPrefix(uri) and
> Node.getURI(prefix).

see above.

Philippe
Received on Thursday, 31 January 2002 10:58:55 GMT

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