0

what operation is more relevant in XQuery: AND or OR?

For example: (a and b or c) is equal to 1 o 2?

  1. (a and b) or c
  2. a and (b or c)

Cheers, Deborah

deb
  • 425
  • 1
  • 9
  • 24
  • I dont know about xquery but **[THIS](http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages)** says it should be `(a and b) or c` – Batu.Khan Apr 14 '14 at 08:01

1 Answers1

2

I guess that by "is more relevant" you mean what other people would phrase as "binds more tightly" or "has higher precedence". In XQuery, a and b or c is parsed as (a and b) or c, not as a and (b or c).

This may be seen in productions 46 and 47 of the XQuery grammar:

[46] OrExpr ::= AndExpr ( "or" AndExpr )*

[47] AndExpr ::= ComparisonExpr ( "and" ComparisonExpr )*

It may also be exhibited in an XQuery engine by evaluating the expression false() and true() or true(). That this is a result of operator precedence and not of left-to-right evaluation can be seen by re-ordering the expression and evaluating true() or true() and false().

Community
  • 1
  • 1
C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65