You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Marcel Reutegger <ma...@gmx.net> on 2009/08/27 09:37:25 UTC

Re: Comparing properties in xpath query

Hi,

in JSR 283 there's an equi join that might be helpful. however, it may
also return tuples with distinct nodes. e.g. let's assume you have a
node A with props (a='foo' and b='foo') and a node B with props
(a='bar' and b='foo')

then the query will return [{A, A}, {A, B}]

but that should lower the number of nodes already significantly and
you can do some manual filtering on the result.

regards
 marcel

On Sat, Aug 22, 2009 at 00:33, Brian Stiles<bs...@bstiles.net> wrote:
> I'm trying to query the repository for nodes that have two properties with
> the same value:
>
> //element(*, nt:unstructured)[@a=@b]
>
> where properties a and b have arbitrary string values.
>
> I understand that this is not supported in the JCR spec as the property can
> only be compared to a literal value.  From what I can tell, the SQL query
> syntax doesn't solve my problem either.
>
> I'm new to using Jackrabbit and am not much more than a novice with XPath,
> so I may be missing the obvious.
>
> Is there another way to structure this query with XPath?  Is there an
> alternate query mechanism in Jackrabbit that is more expressive than the JCR
> APIs provide?  Is there a more efficient mechanism than traversing the tree
> myself and doing the comparison on a node-by-node basis?
>
> Thanks!
>
> --
> Brian Stiles
>
>

Re: Comparing properties in xpath query

Posted by Brian Stiles <bs...@bstiles.net>.
Excellent.  I'll look into that.  Thanks!

--
Brian Stiles

On Aug 27, 2009, at 12:37 AM, Marcel Reutegger wrote:

> Hi,
>
> in JSR 283 there's an equi join that might be helpful. however, it may
> also return tuples with distinct nodes. e.g. let's assume you have a
> node A with props (a='foo' and b='foo') and a node B with props
> (a='bar' and b='foo')
>
> then the query will return [{A, A}, {A, B}]
>
> but that should lower the number of nodes already significantly and
> you can do some manual filtering on the result.
>
> regards
> marcel
>
> On Sat, Aug 22, 2009 at 00:33, Brian Stiles<bs...@bstiles.net>  
> wrote:
>> I'm trying to query the repository for nodes that have two  
>> properties with
>> the same value:
>>
>> //element(*, nt:unstructured)[@a=@b]
>>
>> where properties a and b have arbitrary string values.
>>
>> I understand that this is not supported in the JCR spec as the  
>> property can
>> only be compared to a literal value.  From what I can tell, the SQL  
>> query
>> syntax doesn't solve my problem either.
>>
>> I'm new to using Jackrabbit and am not much more than a novice with  
>> XPath,
>> so I may be missing the obvious.
>>
>> Is there another way to structure this query with XPath?  Is there an
>> alternate query mechanism in Jackrabbit that is more expressive  
>> than the JCR
>> APIs provide?  Is there a more efficient mechanism than traversing  
>> the tree
>> myself and doing the comparison on a node-by-node basis?
>>
>> Thanks!
>>
>> --
>> Brian Stiles
>>
>>