“For” Expressions

XPath 2.0 adds a “for” expression:

for $varname in (expression) return (expression)

N.B. This is in XPath. For example, it might appear in a select attribute.

Use cases?

fn:sum(for $i in order-item return $i/@price * $i/@qty)

XSLT 2.0 retains the xsl:for-each instruction.