jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Hagedorn <nachteilh...@gmx.de>
Subject XPath query: check if child-node does not exist
Date Wed, 01 Dec 2010 13:38:45 GMT
Hi,

I am trying to build a XPath query that gets all nodes that do not have 
a certain (grand)child node but do have a property with a certain value

example

node1 (property=test)
  + child
     + grandchild1
     + grandchild2


node2 (property=test)
  + child
     + grandchild1


With my query I would like to find all nodes ("nodeX") that do not have 
a grandchild "grandchild2" but do have a property "property" with value 
"test".

i.e. in the example above I would like the query to return node2 (since 
node1 has a grandchild "grandchild2".

It doesn't matter to me if "grandchildX" is the name of the 
grandchild-node, or if it was in an extra name-property of the grandchild.

I tried with the grandchild names as a property (all grandchildren have 
the same node name) and have the following sample:
//element(*,mynode)[child/grandchild/@name!='grandchild2' and 
@property='test']

But this also returns node1 as this has a granchild which is not 
grandchild2 ...


Is this possible with Jackrabbit/XPath and could someone please show me 
how? ;)

Thanks in advance,
Stefan

Mime
View raw message