W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2002

Re: XPath namespace nodes

From: Joseph Kesselman <keshlam@us.ibm.com>
Date: Tue, 17 Sep 2002 09:28:13 -0400
To: www-dom@w3.org
Message-ID: <OFF7EE8F28.15646FEB-ON85256C37.0048D1A4-85256C37.004AC2CD@us.ibm.com>

Parent and ownerElement are distinct values in the DOM. As of DOM Level 1 
(and 2), the latter is defined only for  Attrs, which have no parent 
(because they are never children) but do have an ownerElement (because 
some applications -- the XPath data model in particular! -- did want to be 
able to navigate from Attr to its associated Element). 

What XPath calls parent has to be implemented in  DOM code as
        if(node is an Attribute -- or, now, a Namespace Node)
                return node's ownerElement
        else
                return node's parent

Since Namespace Nodes are also not children, they too have no Parent -- 
but do have an ownerElement, for exactly the same reason; XPath 1.0 
insisted on making it possible to navigate back to the Element. XPath 2.0 
has admitted that was a design error and said that the parent of a 
Namespace Node is undefined, which makes implementation one heck of a lot 
simpler -- especially since nobody but compliance tests was ever 
attempting to navigate back out of a Namespace Node, and vanishingly few 
applications even attempt to use the Namespace axis.


Yes, this terminology conflict, and the extra test, is a nuisance. In 
retrospect, XPath really should have changed their terminology (but they 
weren't willing to do so, sigh), and/or the DOM should have provided a 
single operation that mapped more closely to XPath's concept of parent 
(which is why I've proposed that we might want to move ownerElement from 
the Attr interface to the Node interface).

______________________________________
Joe Kesselman  / IBM Research
Received on Tuesday, 17 September 2002 09:28:48 GMT

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