Operators and Keywords

Here is the complete list of operators and keywords in XPath:

!= (not equal)

Compares its two operands and returns true if the first operand is not equal to the second. (Complete details on how comparisons work are in the section Boolean Operators” in Chapter 3.)

()

Contains a parenthesized expression. In addition to using parentheses in mathematical expressions, parentheses are required around test conditions in the if operator.

* (occurrence indicator)

Represents zero or more of an item.

* (multiplication)

Multiplies its two operands together. In XPath 1.0, the two operands must be numbers or values that can be converted to numbers.

[2.0] In XPath 2.0, we can multiply xs:yearMonthDurations and xs:dayTimeDurations by numeric values. Valid combinations are:

  • xs:yearMonthDuration * xs:double

  • xs:dayTimeDuration * xs:double

+ (occurrence indicator)

Represents zero or one of an item.

+ (addition)

Adds its two operands. In XPath 1.0, the two operands must be numbers or values that can be converted to numbers.

[2.0] In XPath 2.0, we can add dates, times, and durations in addition to numeric values. Valid combinations are:

  • xs:yearMonthDuration + xs:yearMonthDuration

  • xs:dayTimeDuration + xs:dayTimeDuration

  • xs:dateTime + xs:yearMonthDuration

  • xs:dateTime + xs:dayTimeDuration

  • xs:date + xs:yearMonthDuration

  • xs:date + xs:dayTimeDuration

  • xs:time + xs:dayTimeDuration

+ (unary plus)

Returns its operand with the sign unchanged. This operator doesn’t change its operand at all.

[2.0], (sequence operator) ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.