Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] How to increase the counter programmatically

From: "Thang X. Le" <tle@----------->
To:
Date: 9/1/2005 5:26:00 PM
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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent