- From: Michael Kay <mhk@mhk.me.uk>
- Date: Mon, 21 Mar 2005 14:22:12 -0000
- To: "'Mukul Gandhi'" <mukul_gandhi@yahoo.com>, "'Sergio Andreozzi'" <sergio.andreozzi@cnaf.infn.it>
- Cc: <www-ql@w3.org>
> I have one question.. Can we write if without else in > XQuery? No, you can't. > > The XQuery grammer says: > IfExpr ::= "if" "(" Expr ")" "then" ExprSingle > "else" ExprSingle > > > If else is mandatory, then is'nt it a inconvenience..? XQuery is an expression language. In most expression languages, both branches of a conditional are mandatory. The WG decided to do it that way (a) so the else branch is explicit, (b) to avoid dangling-else ambiguities in the grammar (the alternative would have been an "end-if" keyword). You can always write "else ()". And in most cases, like this, you can replace for ... return if X then Y else () by for ... where X return Y Michael Kay http://www.saxonica.com/
Received on Monday, 21 March 2005 14:22:48 UTC