[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Finding the first among equals using XPath


Subject: Re: [xsl] Finding the first among equals using XPath
From: "Peter Riocreux" <peter.riocreux@xxxxxxxxx>
Date: Thu, 22 Jun 2006 21:14:59 +0100

something like

<xsl:for-each select="W">
  <xsl:for-each select="X[not(@Y=../following-sibling::X/@Y)]">
    something

Thanks David (and everyone else who replied, but David got there first!) - exactly the kind of thing I was after. The .. inside the predicate should not be there but you did say "something like"....

I was working along the right lines before, but was trying to count
the nodeset of siblings of the context node with the same attribute
value, which involved a predicate inside the predicate and  I needed
the broader vision.

I have written lots of XSL, but only basic stuff and now I am
revisiting some of it I am keen to do a better job, so I would be
grateful if someone would confirm my understanding of the above
(without the ..)

I think it is saying select all X for whom it is not true that the
value of the attribute Y is equal to the value of the same attribute
on any following sibling X. In which case it is choosing the last X
with each value of Y. The .. is not needed because the context in
which the attribute is seen is an X and so searching for its siblin Xs
is at the same level.

Is that all correct?

Cheers,

Peter (A very happy one who you may see asking more dumb questions on this list)


Current Thread
Keywords
xsl