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

How to increase the counter programmatically

Subject: How to increase the counter programmatically
From: "Thang X. Le" <tle@xxxxxxxxxxx>
Date: Thu, 01 Sep 2005 10:22:18 -0700
counter increase
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

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.