Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Attributes, ParentNodes, and "child" nodes ...

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Gregory Garretson <gregory AT garretson.info>
  • To: Michael Kay <mike AT saxonica.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Attributes, ParentNodes, and "child" nodes ...
  • Date: Wed, 15 Mar 2006 11:57:10 -0500

Michael Kay wrote:

Why is an Attribute a Node that has a ParentNode as a parent, as returned by attribute.getParent(), but at the same time it's not a child of a ParentNode, as returned by parent.getChild(n)?


When people ask that question of the XPath model, my usual response is: it
was a mistake to use the word "parent" for the relationship between a node
and its owner, given that (a) we expect parent to be the inverse
relationship of child, and (b) we expect things to have two parents, not
one.

Actually, I think you're confusing two problems that come from different sources. The expectation that things will have two parents is a problem that comes with the use of the "parent-child" analogy to describe trees. However, since it is very well established in computer science (and graph theory) to speak of a tree in terms of parent and child nodes, it isn't a bigger problem here than it is anywhere else, which, I would argue, is still not much.

On the other hand, I think that your point (a) is very good; even in comp sci, we typically expect the parent-child relationship to be a reciprocal one, so if c.getParent() returns p, then we should expect p.getChild(n) to return c for some n. Perhaps there should be a different name for getParent(), as John suggests. But then there's the inheritance problem that Mike C. brings up. Sorry I don't have any good suggestions...

Gregory





Archive powered by MHonArc 2.6.24.

Top of Page