The expression for $x in E1 return E2
returns the sequence that results from evaluating
E2
once for every item in the sequence E1
. Note that E2
must
use the range variable $x
to refer to the item being
tested; it does not become the context item. For example, sum(for $v in order-item return
$v/price * $v/quantity)
returns the total value of (price times quantity) for all the
selected order-item
elements.