You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Bas Passon <BP...@parite.nl> on 2000/10/24 11:36:50 UTC
problems counting in loops
Hello,
I have got a small problem, counting in xsl, see the following fragment of
code
<xsl:variable name="count" select="1"/>
<xsl:for-each select="item">
...do something
<xsl:variable name="count" select="$count+1"/>
</xsl:for-each>
for some reason the count variable stays 1. What am i doing
wrong. I looked at the XPath docs, but this is a valid
expr.
Thnx
Bas
Re: problems counting in loops
Posted by Konstantin Piroumian <KP...@flagship.ru>.
problems counting in loopsBy XSL rules you cannot assign a new value to a
variable.
To implement this kind of counting you have to use recursion.
Btw, to count the number of elements you can use the count() function:
<xsl:variable select="count(items)"/>
Regards,
Kot.
----- Original Message -----
From: Bas Passon
To: Cocoon Mailinglist (E-mail)
Sent: 24 ??????? 2000 ?., ??????? 13:36
Subject: problems counting in loops
Hello,
I have got a small problem, counting in xsl, see the following fragment of
code
<xsl:variable name="count" select="1"/>
<xsl:for-each select="item">
...do something
<xsl:variable name="count" select="$count+1"/>
</xsl:for-each>
for some reason the count variable stays 1. What am i doing
wrong. I looked at the XPath docs, but this is a valid
expr.
Thnx
Bas