SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
| Introduction
| Constants
| Variable References
| Function Calls
| Axis steps
| Parentheses and operator precedence
| Filter expressions
| Path expressions
| Cast as, Treat as
| Set difference and intersection
| Union
| Arithmetic expressions
| Range expressions
| Comparisons
| Instance of and Castable as
| Conditional Expressions
| Quantified Expressions
» | For Expressions
| Boolean expressions: AND and OR
| Sequence expressions
Function Library
Standards Conformance

# For Expressions

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.

Next