diff --git a/specifications/grammar-40/xpath-grammar.xml b/specifications/grammar-40/xpath-grammar.xml index 66dc4ca4b..f2efe9a74 100644 --- a/specifications/grammar-40/xpath-grammar.xml +++ b/specifications/grammar-40/xpath-grammar.xml @@ -1333,7 +1333,7 @@ VersionDecl ::= "xquery" (("encoding" StringLiteral) | ("version" StringLiteral ) - + @@ -1344,21 +1344,21 @@ VersionDecl ::= "xquery" (("encoding" StringLiteral) | ("version" StringLiteral - - - + + + - + diff --git a/specifications/xquery-40/src/expressions.xml b/specifications/xquery-40/src/expressions.xml index 2451a8fe1..f08e7c1ac 100644 --- a/specifications/xquery-40/src/expressions.xml +++ b/specifications/xquery-40/src/expressions.xml @@ -20686,70 +20686,40 @@ return $map?[?key ge 2] - - + + -

There are two formats with essentially the same semantics.

- -

The unbraced expression if (C) then T else E is equivalent to - the braced expression if (C) { T } else { E }.

-

The ternary expression C ?? T !! E is equivalent to the - braced expression if (C) { T } else { E }.

-

The ternary operator syntax is borrowed from Perl6.

-
-

The value V of a conditional expression using the - braced format is obtained by applying the following rules in order, finishing - as soon as V has a value:

+

The braced expression if (C) then {T} is equivalent to the + unbraced expression if (C) then T else ().

+ +

The value V of a conditional expression in the form if (C) then T + else E is obtained as follows:

+ + -

Let C be the effective boolean value of the test expression, as defined in

Let B be the effective boolean value of the test expression + C, as defined in .

-

If C is true, V is the - value of the EnclosedExpr in the ThenAction.

-
-

The ElseIfActions (if any) are processed in order as follows:

- -

Let C' be the effective boolean value of the test expression, as defined in .

-

If C' is true, V is the - value of the EnclosedExpr in the ElseIfAction - -

-
-
-
- -

If there is an ElseAction, then V - is the value of its EnclosedExpr.

+

If B is true, V is the + result of evaluating T.

- -

V is the empty sequence.

+

Otherwise, V is the + result of evaluating E.

-
- -
+ + + -
+ + -

Whichever format is used, the first step in processing a conditional expression is to find -the effective boolean value of the test expression, as defined in .

- -

The value of a conditional expression is defined as follows: If the -effective boolean value of the test expression is true, the value of the then-expression is returned. If the -effective boolean value of the test expression is false, -the value of the else-expression is returned.

Conditional expressions have a special rule for propagating dynamic errors: expressions whose value is not needed for @@ -20781,14 +20751,7 @@ then $part/wholesale else $part/retail]]> - -

The above expression can equivalently be written:

- - +

The following example returns the attribute node @discount provided the value of @price @@ -20798,15 +20761,15 @@ else $part/retail]]>

The following example tests a number of conditions:

- +]]>
@@ -20814,8 +20777,8 @@ else $part/retail]]>

In the unbraced format, both the then and else clauses are mandatory.

-

In the braced format, an else clause is always unambiguously - associated with the immediately containing IfExpr.

+

In the braced format, the expression terminates unambiguously with the closing + brace.