jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jukka Zitting <jukka.zitt...@gmail.com>
Subject Re: xpath
Date Thu, 02 Feb 2006 14:50:05 GMT
Hi,

On 2/2/06, Michael Singer <jackrabbit@it-specialist.at> wrote:
> I want to build an xpath query which returns all nodes of a particular
> (well known) type where the property "value" of child node "name" has
> the value "test".

The normal XPath query for this would be something like this:

    //element(*,'type')[name/@value='test']

Unfortunately Jackrabbit doesn't support the child node axis in XPath
predicates (see JCR-247), which means that the above query will not
work.

I can't think of a simple workaround to this issue, so my solution
would be to run a query like //*[@value='test'] and post-process the
results with:

    while (iterator.hasNext()) {
        Node node = (Node) iterator.next();
        Node parent = node.getParent();
        if (parent.getPrimaryNodeType().isNodeType("type")) {
            // process parent node
        }
    }

Another solution would be to redesign the node type structure to match
the limitations of the Jackrabbit query capabilities.

BR,

Jukka Zitting

--
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftmanship, JCR consulting, and Java development
Mime
View raw message