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

Re: [xsl] determining position based on predicate


Subject: Re: [xsl] determining position based on predicate
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 15 Oct 2010 18:11:27 +0100

On 15/10/2010 18:05, Terry Ofner wrote:
<xsl:when position()=count(.[lesson/lessontitle='Lesson A'])-1">

.[anything] will select either this node (if the predicate is true) or nothing otherwise, so the count is always 0 or 1.


I'd guess you intended count(../tocItem[lesson/lessontitle='Lesson A'])
although it might be ore efficient to work out that number into a variable before starting the loop or perhaps your xslt system will be smart enough to notice that the value doesn't depend on the current item if that was selected with the child axis.


David


Current Thread
Keywords