> 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
This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:43:43 UTC