[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problem with Predicate selecting only first node rathe

Subject: 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
predicate nodes duplicate
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"
select="$entries/idx1[not(./text()=following::idx1/text())]"/>
 <xsl:for-each select="$primes">
  <xsl:variable name="thisprime" select="./text()"/>
  <xsl:variable name="dupsall"
select="$entries[idx1[(./text()=$thisprime)]]"/>
  <xsl:variable name="dups"
select="$dupsall[not(position()=count($dupsall))]/idx1"/> 
<!--  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"/>
  </xsl:call-template>
 </xsl:for-each> 

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.

Thanks,

Sara Mitchell 

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.