jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Select all leafs of a tree w/XPath
Date Sat, 08 Nov 2008 19:06:34 GMT
Hi,

On Sat, Nov 8, 2008 at 6:53 PM, Sergey Podatelev
<brightnesslevels@gmail.com> 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

Mime
View raw message