Operators


The following table lists the XPath operators.

The number on the left indicates the precedence of the operator. A higher number means that the operator binds more tightly. So «A or B and C » means «A or (B and C) ».

If two operators have the same precedence, then they are evaluated from left to right. So «A - B + C » means «(A - B) + C ».

Precedence

Operator(s)

Meaning

1

«, »

Concatenates two sequences, or forms a sequence from individual items

2

«for »

«for $item in SEQ return f($item) »

applies the function f (which might be any expression) to each item in the sequence SEQ, returning the concatenation of the results

2

«some »

«some $item in SEQ satisfies f($item) »

returns true if there is at least one item in SEQ for which the function f (which might be any expression) returns true

2

«every »

«every $item in SEQ satisfies f($item) »

returns true if there is no item in SEQ for which the function f (which might be any expression) returns false

2

«if »

«if (TEST) then EXPR1 else EXPR2 »

returns the result of evaluating either expression EXPR1 or expression EXPR2, depending on whether expression TEST is true or false

2

«or »

Boolean disjunction: true if at least one of the operands is true

3

«and »

Boolean conjunction: true if both the operands are true

4

«eq »

«ne »

«lt »

«le »

«gt »

«ge »

Compares two atomic values. Returns true if the value on the left is equal (or not equal, less than, less than or equal, greater than, or greater than or equal) to the value on the right

4

«= »

«!= »

«< »

«<= »

«> »

«>= »

Compares two sequences. Returns true if the sequence on the left contains a value that is equal (or not equal, less than, less than or equal, greater than, or greater than or equal) to some value contained in the sequence on the right

4

«is »

Tests whether two expressions return the same node.

4

«<< »,

«>> »

Tests whether the node returned by the expression on the left precedes or follows the node returned by the expression on the right, in document order

5

«to »

Returns a range of integers, for example «1 to 5 » returns the sequence «1, 2, 3, 4, 5 ».

6

«+ »,

«- »

Performs addition or subtraction of two numbers or durations, or adds/subtracts a date/time and a duration, or finds the difference between two dates or times

7

«* »,

«div »

Multiplies or divides two numbers, or multiplies/divides a duration by a number to give another duration

7

«idiv »

Integer division. Divides two numbers and rounds down to an integer

7

«mod »

Modulus: returns the remainder after dividing the left-hand operand by the right-hand operand and rounding down to an integer

8

«union »,

« »

Combines two sequences of nodes to give a new sequence containing any node that is present in either sequence, with duplicates eliminated and sorted into document order

9

«intersect »

Combines two sequences of nodes to give a new sequence containing every node that is present in both the supplied sequences, with duplicates eliminated and sorted into document order

9

«except »

Combines two sequences of nodes to give a new sequence containing every node that is present in the first sequence but not in the second, with duplicates eliminated and sorted into document order

10

«instance of »

Returns true if the value on the left is an instance of the type on the right

11

«treat as »

Asserts that the value on the left is an instance of the type on the right; fails at runtime if it is not

12

«castable as »

Tests whether the value on the left is capable of being converted successfully to the type on the right

13

«cast as »

Converts the value on the left to the type on the right

14

unary «- »,

unary «+ »

Unary minus changes the sign of a number or duration. Unary plus does nothing, provided the value is a number or a duration

15

«/ »

«E1/E2 » evaluates the expression E2 for every node in the result of evaluating E1, concatenates the results, eliminates duplicates, and sorts the remaining nodes in document order. Applies only to expressions that return nodes

15

«// »

Shorthand for «/descendant-or-self::node() / ». Loosely, selects the descendants of a node.

16

« [ ] »

«E1[E2] » selects the items in E1 that satisfy the predicate E2. A numeric predicate «[N ] » is shorthand for «[position() = N] »




XSLT 2.0 Programmer's Reference
NetBeansв„ў IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications (2nd Edition)
ISBN: 764569090
EAN: 2147483647
Year: 2003
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net