[jdom-interest] Last call: getChild/getChildren versus getChildElement/getChildElements

Jason Hunter jhunter at xquery.com
Thu Feb 5 18:28:38 PST 2004

Elliotte Rusty Harold wrote:

> At 3:11 PM -0800 2/5/04, Jason Hunter wrote:
>> And here's more ammo.  What does $foo/child::* return in XPath/XQuery? 
>> All the child elements!  So getChildren() makes perfect sense in that 
>> view.
> but $foo/child::node() returns all nodes, not just elements. The 
> elements part of this expression is in the *, not the child. 

Yes, but the child axis still has elements as the principal node type, 
which is why $foo/child::bar returns bar elements and not bar PIs.  Thus 
getChildren("bar") can be justified to return bar elements.

> getChildElements is the right name for a method that does not return all 
> children.

If we were starting over, I think I'd agree with you.  But I don't want 
the hate mail.  I'd rather have Vadim's beer.  :-)


More information about the jdom-interest mailing list