Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Within the predicate, just as within an
$sequence[position() * 2 <= last()]
There is a special rule for predicates, namely that if the value of the predicate is a number
N
, then it is treated as a shorthand for the condition
[position()=
N
]
, which selects the
N
th item in the sequence.
For path expressions of the form
A/B
, the rules are the same as the rules for predicates. The expres sion B is evaluated once for each node in the sequence produced by evaluating A, and while B is being evaluated, that node is the context item, the position of that node in the sequence is the context position, and the number of items in the sequence is the context size. However, it's very hard to construct a useful path expression that actually uses
position()
or
last()
on the right-hand side of the
/
operator. Using them inside a predicate such as
A/B[last()]
doesn't count, of course, because the focus changes again once you're inside the predicate.
It's also important to be aware that certain expressions
don't
change the focus. Specifically, the focus is not changed within a
for
,
some
, or
every
expression (these expressions are described in Chapter 10). So the expression: