SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
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

# Comparisons

The simplest comparison operators are `eq`, `ne`, `lt` `le`, `gt`, `ge`. These compare two atomic values of the same type, for example two integers, two dates, or two strings. In the case of strings, the default collation is used (see saxon:collation). If the operands are not atomic values, an error is raised.

The operators `=`, `!=`, `<`, `<=`, `>`, and `>=` can compare arbitrary sequences. The result is true if any pair of items from the two sequences has the specified relationship, for example `$A = $B` is true if there is an item in `$A` that is equal to some item in `$B`. If an argument is a node, Saxon currently uses its string value in the comparison, not its typed value as required by the XPath 2.0 specification.

The operator `is` tests whether the operands represent the same (identical) node. For example, `title[1] is *[@note][1]` is true if the first `title` child is the first child element that has a `@note` attribute. If either operand is an empty sequence the result is an empty sequence (which will usually be treated as false).

The operators `<<` and `>>` test whether one node precedes or follows another in document order.

Next