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

Subject: Re: [xsl] Problem with Predicate selecting only first node rather than all but last
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 19 Jan 2001 09:15:08 GMT
> . I was right, the count for $dups 
> is always 2 even if there are 3 or more present. 

without any input or complete stylesheet its a bit hard to test this,
I fleshed out your code so that it does run (run the following
stylesheet giving anything, eg itself, as input) Your code does
seem to work, I get
  dups: 2 
  dupsall: 3 
  dups: 4 
  dupsall: 5 
  dups: 0 
  dupsall: 1 
  dups: 3 
  dupsall: 4

for the example included, which is I think what you want.

I left the code as it was but it does seem excessivelt complicated for
what it does, all the variable definitions etc. Also if your idx1
elements only have text, then 
can be more simply written

could be written as 

(which means perhaps that your idx1 elements don't just contain text,
otherwise there is not a lot of point in collecting all these nodes
which you know in advance are the same)


<xsl:stylesheet xmlns:xsl="";

<xsl:output method="xml" indent="yes"/>

<xsl:variable name="x">

<xsl:variable name="idx" select="document('')/*/*[indexentry]"/>

 <xsl:variable name="entries" select="$idx//indexentry"/>
 <xsl:variable name="primes"

<xsl:template match="/">
 <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)"/> 
  dupsall: <xsl:value-of select="count($dupsall)"/> 


This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit

 XSL-List info and archive:

Current Thread