Re: path-predicate question

Subject: Re: path-predicate question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 10 Aug 2000 15:27:53 GMT
> 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?

The latter.

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

is the same as

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

when you repeat [] expressions, the current node list, and thus
last() and position() and count() are reset each time.

So you want to do the filters in the other order

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

which picks out the first element and then tests its name, or so them
together

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

As you have it you first select the node list

preceding-sibling::*[starts-with(name(),'div')]

and then select the node list with the filter [position()=1] ie the
first node in the list (if the list was non empty). But when used
as a boolean test the only thing that matters is whether or not the list
is empty, so taking the first element of the list does not change the
boolean value.

David



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


Current Thread