|
Subject:
|
Get count of a for loop
|
|
Posted By:
|
austinf
|
Post Date:
|
5/16/2006 2:41:28 AM
|
hi i would like to get the count of a for loop outside the loop
here is a sample code
<xsl:for-each select="Car">
<xsl:variable name="level" select="position()"/>
</xsl:call-template>
i would like the number of cars to be stored in a hidden variable on my jsp page. here i can include the hidden field inside the loop with last() called but that will repeat the hidden field the number of times the Car tag is present.
can some one tell me how to acccess the total from outside the for loop
thanks
|
|
Reply By:
|
mhkay
|
Reply Date:
|
5/16/2006 3:26:56 AM
|
I don't understand all the stuff about hidden variables on jsp pages, but you can count the number of Car elements before entering the for-each with the XPath expression select="count(Car)".
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|