This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: path-predicate question
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: RE: path-predicate question
- From: Kay Michael <Michael dot Kay at icl dot com>
- Date: Thu, 10 Aug 2000 17:08:43 +0100
- Reply-To: xsl-list at mulberrytech dot com
>
> <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