Are you sure you can't use the XPath expression:
//*[count(child::*) = 0]
to select the element nodes that have no children (i.e. leaf nodes)?
Phil :n.
----- "Jukka Zitting" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> On Sat, Nov 8, 2008 at 6:53 PM, Sergey Podatelev
> <[EMAIL PROTECTED]> wrote:
> > Seriously, guys, is there an easy way to select leafs or I have to
> implement
> > a particular property for this?
>
> There is no query constraint for selecting leaf nodes.
>
> Your idea of using a particular property that you only set on leaf
> nodes is one way to do this. An alternative would be to use normal
> tree traversal like this:
>
> void visitLeaves(Node node) {
> NodeIterator nodes = node.getNodes();
> if (!nodes.hasNext()) {
> // ... this is a leaf node, process it ...
> } else {
> while (nodes.hasNext()) {
> visitLeaves(nodes.nextNode());
> }
> }
> }
>
> BR,
>
> Jukka Zitting