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]
Other format: [Raw text]

Re: testing for following siblings


Hi Paul,

> Another confusion ... I'm trying to determine when the current node
> has no following siblings. One expression that seems to work is:
>
>     not(following-sibling::*)

Yes. This gathers together all the following sibling elements of the
context node into a node set. The not() function converts that node
set to a boolean -- true if there are any nodes in a node set and
false if there aren't -- and then negates that boolean. So you get
true if you don't manage to find any following sibling elements.

> but the following expressions don't "work", and I thought they would
>
>     following-sibling::* = ''

This tests whether any following sibling element has a string value of
an empty string. It gathers together a node set of the following
sibling elements and compares them each to the empty string. If any of
them are the empty string, then it returns true. If there aren't any
following sibling elements, or if none of them are empty strings, then
it returns false.

>     following-sibling::* = '/..'

This tests whether any following sibling element has a string value of
'/..' (you put quotes around it, so it's a string). As above, if there
aren't any following sibling elements, or if none of them have the
string value '/..', then it returns false.

Possibly what you were trying to test here was:

  following-sibling::* = /..

But = doesn't compare node sets as a whole (i.e. it won't say "the
node set of following sibling elements is the same as the empty node
set"). Instead it compares pairs of nodes from the two node sets --
it's the same as "is there a node in the node set of following
siblings with the same value as one of the nodes in the empty node
set?". Since there's nothing in the second node set, the answer is
always false.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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]