[xsl] limit count() to nodes with a position() < the postion of the current node

Subject: [xsl] limit count() to nodes with a position() < the postion of the current node
From: "M. David Peterson" <conners_dad@xxxxxxx>
Date: Mon, 8 Sep 2003 23:22:33 -0600
Hi all,

Ive got an interesting one for you...

Ive got the following key...

<xsl:key name="linkCount" match="lid" use="."/>

that uses the following xml...

<history>
    <visit>
      <loc>life</loc>
      <subloc>main</subloc>
      <date>9/8/2003 10:49:58 PM</date>
      <lid>AAD001</lid>
    </visit>
</history>

to give me the total count of all nodes that have the value of the current 
context...

<xsl:value-of select="count(key('linkCount', lid))"/>

This works perfectly as it returns the total count of all nodes that have 
the same value as the current context node...

But I want to take this one step further and return the count of all nodes 
that have a position() that is less than the position of the current node. 
Taking the position() of the context node out of the equation I thought it 
would as simple as this (I used 5 as a test parameter)...

<xsl:key name="linkCount" match="lid[position() &lt; 5]" use="."/>

I expected it to return the count of the nodes that matched the current 
context node as long as there postion was less than 5.  But it didn't.  It 
returned the total count for the entire xml tree.

So, my questions are...  1)What do I need to change to get the above example 
to work and 2)How could I then take it one step further and use the 
position() of the current context node as the parameter to test against the 
position() of the test nodes?

Your help is much appreciated!

Best Regards,

M.David 

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


Current Thread