jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Hagedorn <nachteilh...@gmx.de>
Subject XPath: check for property of child node
Date Thu, 11 Nov 2010 08:05:21 GMT
Hi,

I am not very familiar with XPath and I am trying to build a query that 
selects nodes that have a grandchild with a specific name.

My structure is:

<level1>
	<level21>
		<item name="item1">
			<children>
				<aaa name="aaa" />
				<xxx name="xxx" />
			</children>
		</item>

		<item name="item2">
			<children>
				<yyy name="yyy" />
				<aaa name="aaa" />
			</children>
		</item>			
	</level21>

	<level22>
		<item name="item2">
			<children>
				<ddd name="ddd" />
				<ccc name="ccc" />
			</children>
		</item>			
	</level22>
</level1>

What I want to do is to get all item nodes that have e.g. a "xxx" 
grandchild.

In my query I do:

/jcr:root/level1//element(item,item-type)[children/xxx/@name='xxx']

It works, but it feels wrong. I would like to leave out the redundant 
property/attribute 'name'. But then I will have to check if children/xxx 
exists... and I don't know how to do it.

Could anyone please give me a hint?

Thanks in advance!

Stefan

Mime
View raw message