for and let clauses in the same expression
When a FLWOR expression contains both for and let clauses, the variable bindings that are generated by let clauses are added to the variable bindings that are generated by the for clauses.
In the following example, the for clause
includes a variable called
$a
and an expression that
constructs the sequence (1, 2, 3)
. The let clause
includes a variable called $b
and an expression that
constructs the sequence (4, 5, 6)
:for $a in (1, 2, 3)
let $b := (4, 5, 6)
return <output>{$a, $b}</output>
The for and let clauses
in this example result in three tuples of bindings. The number of
tuples is determined by the for clause. ($a = 1, $b = 4 5 6)
($a = 2, $b = 4 5 6)
($a = 3, $b = 4 5 6)
The return clause
in the example executes once for each tuple of bindings. The expression
results in the following output:
<output>1 4 5 6</output>
<output>2 4 5 6</output>
<output>3 4 5 6</output>