You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Torgeir Veimo <to...@pobox.com> on 2006/07/03 04:08:43 UTC

xpath query with child constraints

I have a hard time coming up with a way to query on content 
(jcr:contains) on subnodes of type nt:resource, combined with 
constraints on properties of the parent nodes.

Is this possible?

-- 
-Torgeir

Re: xpath query with child constraints

Posted by Marcel Reutegger <ma...@gmx.net>.
Torgeir Veimo wrote:
> Torgeir Veimo wrote:
>> I have a hard time coming up with a way to query on content 
>> (jcr:contains) on subnodes of type nt:resource, combined with 
>> constraints on properties of the parent nodes.
> 
> Is it correct to do something along the lines of
> 
> /jcr:root//element(*,nen:resource)[@isarticle]//element(*,nt:resource)[jcr:contains(*,'alive')] 

If you know that your nen:resource node has a nt:resource child node the 
descendant-or-self axis is overkill. this should be sufficient:

/jcr:root//element(*,nen:resource)[@isarticle]/*[jcr:contains(.,'alive')]

please note that the '*' in jcr:contains() in your query is wrong, it 
should be '.' (context node).

regards
  marcel

Re: xpath query with child constraints

Posted by Torgeir Veimo <to...@pobox.com>.
Torgeir Veimo wrote:
> I have a hard time coming up with a way to query on content 
> (jcr:contains) on subnodes of type nt:resource, combined with 
> constraints on properties of the parent nodes.

Is it correct to do something along the lines of

/jcr:root//element(*,nen:resource)[@isarticle]//element(*,nt:resource)[jcr:contains(*,'alive')]

where nen:resource is a parent node to nt:resource, and isarticle is a 
required attribute on the parent node?

-- 
-Torgeir