xsl-list
[Top] [All Lists]

How to increase the counter programmatically

2005-09-01 10:22:18
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>