I'm still a bit perplexed.
that's usually the way with my answers until Jeni re-words them (I don't
know why I bother:-)
If you evaluate a nodeset in a string context
then only the first
node in the nodeset is considered.
note that node sets are sets so unordered.
If you evaluate in a string context then the first node in document
order is taken.
However within a step position referes to the order in the direction
specified by the axis that started the step.
following-sibling::div[(_at_)class = 'slide']/@id is the same as
following-sibling::div[(_at_)class = 'slide'][1]/@id.
these are the same, yes.
On the other hand,
preceding-sibling::div[(_at_)class = 'slide']/@id is the same as
preceding-sibling::div[(_at_)class = 'slide'][last()]/@id.
yes that [last()] is part of a step using a reverse axis.
the "first node" semantics is the same as using (...)[1]
preceding-sibling::div[(_at_)class = 'slide']/@id
if used as a string selects more than one node (potentially)
so it is first evaluated as
(preceding-sibling::div[(_at_)class = 'slide']/@id)[1]
which takes the first node from teh set in document order.
in this case, that happens to be the same as
(preceding-sibling::div[(_at_)class = 'slide'])[1]/@id
as every div which has a class=slide also has an id attribute, so taking
the first id attribute is the same as taking the first div and then
taking its id.
with the () the [1] is acting on the node set, so uses document order,
but in
preceding-sibling::div[(_at_)class = 'slide'][1]
th e[1] is part of the step and so referes to the order specified by the
axis of the step. Note that [] appearing in steps and [] being
predicates on node sets are in fact completely separate parts of teh
Xpath grammar, they just happen to use the same concrete syntax.
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list