[jdom-interest] META: Children of a lesser spec
EGalluzzo at synchrony.net
Mon Oct 2 07:23:26 PDT 2000
> -----Original Message-----
> From: Jason Hunter [mailto:jhunter at collab.net]
Well, I do know a fair bit about XPath, so I figured I had to chime in here.
:) By the way, I really don't mind what we call the
getChildren()/ChildElements()/Elements() method, just so long as it sticks
around in one form or another.
> Little follow-up on the getChild/getChildElement debate. :-)
> For a final example, let's look at the XPath spec:
> child::* selects all element children of the context node
> child::text() selects all text node children of the context node
> child::node() selects all the children of the context node, whatever
> their node type
> Pretty clear that child::* returns only *element* children. You use
> child::node() to return a list of all types. When XPath says
> "child" it
> also means element children.
Actually, this isn't true. "child::node()" selects all children (text
nodes, comment nodes, element nodes, attribute nodes, etc.). The only
reason "child::*" selects all child element nodes is that "*" refers to "all
element nodes". Actually, "child" is just a traversal direction -- or, as
XPath calls it, an "axis." In the same manner, preceding-sibling::* would
select all preceding sibling element nodes, and preceding-sibling::node()
would select all preceding sibling element nodes (attributes, comments,
etc.). So the fact that "child::*" happens to select all element nodes is a
facet of the "*", not the "child".
Now, we could call the method getAsterisk() if you like.... ;)
More information about the jdom-interest