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

# Range expressions

The expression `E1 to E2` returns a sequence of integers. For example, `1 to 5` returns the sequence `1, 2, 3, 4, 5`. This is useful in `for` expressions, for example the first five nodes of a node sequence can be processed by writing `for $i in 1 to 5 return (//x)[$i]`.

If you prefer, you can write this as `(//x)[position() = 1 to 5]`. This works because comparison of a single integer (`position()`) to a sequence of integers (`1 to 5`) is true if the integer on the left is equal to any integer in the sequence.

Next