Re: [xsl] get immediat preceeding node, if it is a comment

Subject: Re: [xsl] get immediat preceeding node, if it is a comment
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 4 Oct 2002 14:25:19 +0100
> It seems that any predicates after the positional predicate refer to
> that node, not to the node that the predicates before the positional
> predicate refer to... 

yes but that's a special case. You can have any number of [] predicates
in a step and after each one the remaining nodes in the current node
list are those nodes for which the predicate was true.  while evaluating
the next [] position() and last() and count() all refer to the current
node list (ie the list of nodes that have survivied any previous []
predicates in the step)

> preceding-sibling::node()[normalize-space()][1][self::comment()]
> this gets 'test1' and 'test3' as we would expect

anything that involves [1] (anywhere) will select a node set of at most
one node. Your description in english suggests you used the expression


while <root> is your current node.

ie find all children that have the stated condition.

> So is it the case that all predicates to the right of the positional
> predicate refer to that node? (they change the context node)

Yes but there is nothing special about the positional predicate it is
just shorthand for the boolean test [position()=1].
All later predicates refer to nodes for which earlier predicates are


This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:

Current Thread