[xsl] Problem with Predicate selecting only first node rather than all but last

Subject: [xsl] Problem with Predicate selecting only first node rather than all but last
From: sara.mitchell@xxxxxxxxx
Date: Thu, 18 Jan 2001 19:37:34 -0500
I know problems like this have been posted to the list
before, but I can't seem to find the answers in the 
archive and I've been looking at this code too long. 
Hopefully, someone else will be able to point out 
the almost-surely obvious error in my code. 

In the following code, the variable $idx contains nodes that
have been sorted to be used in generating an index. The
variable $primes contains the unique index entries. 

Everything works correctly with one exception. If an indexentry
has 3 or more nodes in $idx, this code generates a link for
the first node and for the second node, but not for the third, or 
later nodes. 

 <xsl:variable name="entries" select="$idx//indexentry"/>
 <xsl:variable name="primes"
 <xsl:for-each select="$primes">
  <xsl:variable name="thisprime" select="./text()"/>
  <xsl:variable name="dupsall"
  <xsl:variable name="dups"
<!--  dups: <xsl:value-of select="count($dups)"/> -->
  <xsl:call-template name="doprimes">
   <xsl:with-param name="primedups" select="$dups"/>
   <xsl:with-param name="second" select="$dupsall"/>

To test this, I put in the line that is currently commented out
because I suspected that the select value for the variable $dups
was only selecting the first duplicate, not all duplicates (except
the last) which is what I want. I was right, the count for $dups 
is always 2 even if there are 3 or more present. 

I can't figure out how to change the predicate to select all the
duplicate nodes except for the last one. Even more confusing, 
when I uncomment the test line with $dups count, I actually get 
the correct output, all of the duplicates are found and generate
separate links even though the count for $dups still says 2.


Sara Mitchell 

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

Current Thread