You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Alexander Klimetschek <ak...@day.com> on 2009/11/16 13:49:12 UTC

Re: Query property constraints - How can I join multiple logical operators in any order?

On Mon, Nov 16, 2009 at 10:44, Oleg <ov...@googlemail.com> wrote:
> What for brackets are allowed in the property constraints to separate
> logical operators? I want to build e.g. following query statement:
>
> //*[(@a = 'value1' and @b = 'value2' or @c = 'value3') and (@d = 'value4' or
> @e = 'value5')]
>
> Is the syntax with round brackets correct?

Yes.

> I known that AND has more
> strength than OR and some brackets are needed sometimes for the right query
> expression. Right?

The operator precedence in XPath 1.0 is (from lowest to highest) is:
or, and, = / !=, <= / < / >= / > [1], hence your "a and b or c"
(shortened) will be interpreted like "(a and b) or c".

Personally I always use brackets in any language to avoid any
mistakes. Leaving them out is just a convenience, after all.

[1] http://www.w3.org/TR/xpath#NT-OrExpr

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Query property constraints - How can I join multiple logical operators in any order?

Posted by Oleg <ov...@googlemail.com>.
Thanks a lot Alex!



Alexander Klimetschek wrote:
> 
> On Mon, Nov 16, 2009 at 10:44, Oleg <ov...@googlemail.com> wrote:
>> What for brackets are allowed in the property constraints to separate
>> logical operators? I want to build e.g. following query statement:
>>
>> //*[(@a = 'value1' and @b = 'value2' or @c = 'value3') and (@d = 'value4'
>> or
>> @e = 'value5')]
>>
>> Is the syntax with round brackets correct?
> 
> Yes.
> 
>> I known that AND has more
>> strength than OR and some brackets are needed sometimes for the right
>> query
>> expression. Right?
> 
> The operator precedence in XPath 1.0 is (from lowest to highest) is:
> or, and, = / !=, <= / < / >= / > [1], hence your "a and b or c"
> (shortened) will be interpreted like "(a and b) or c".
> 
> Personally I always use brackets in any language to avoid any
> mistakes. Leaving them out is just a convenience, after all.
> 
> [1] http://www.w3.org/TR/xpath#NT-OrExpr
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://n4.nabble.com/Query-property-constraints-How-can-I-join-multiple-logical-operators-in-any-order-tp622036p622125.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.