Re: XPath namespace nodes

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 UTC