jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: Query property constraints - How can I join multiple logical operators in any order?
Date Mon, 16 Nov 2009 12:49:12 GMT
On Mon, Nov 16, 2009 at 10:44, Oleg <ovaraksin@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

Mime
View raw message