This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: path-predicate question


> 
> <xsl:when
> test="preceding-sibling::*[starts-with(name(),'div')][position()=1]">

The [position()=1] predicate is redundant, since if there are any nodes in
the node-set, there will be a first one, and in a boolean context you are
only interested in whether the node-set is empty.
> 
> The question is: Is this statement true only when the immediately
> preceding sibling is a div or is it also true when there are any div
> preceding siblings?

position() in a predicate is the position in the node-set after filtering
using all previous predicates. So the latter. If you want the former,
reverse the order of the predicates.

  If the latter, then how do I select the first div
> preceding sibling, skipping any non-div siblings?  Does
> 
> <xsl:value-of
> select="preceding-sibling::*[starts-with(name(),'div')][positi
> on()=1]"/>
> 
> do the trick?

Yes.

> If so, then the [position()=1] part of the predicate
> behaves differently when used with 'test' than with 'select', no?
> 

No.

Mike Kay 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]