How to increase the counter programmatically
Hi, In a <xsl:for-each> loop, I know how to find the processing order (counter) by calling position(). But how can I find the counter when it's supposed to increase only in specific conditions? For example: <xsl:for-each select="//products/product"> <!-- Do some processing here --> <xsl:if test="condition"> <!-- What is the counter here? --> </xsl:if> </xsl:for-each> Now, I know that if the "condition" is simple and straightforward, I can just do this and use position() as counter: <xsl:for-each select="//products/product[condition]"> <!-- Do some processing here --> <!-- Now position() will be the ordinal counter --> </xsl:for-each> But what if the condition is more complex and require extra steps? For example, I may want to store a few nodesets in variables, and use these variables in the 'test' clause and body of <xsl:if>. I've tried twisting it to use <xsl:template> but it seems the basic problem is still there. Basically this can be solved easily if I can do something like $counter = $counter + 1. I know this is not on with XSLT, so what are my alternatives? Thanks, Thang Le
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format