Chandrashekar, XSLT variables are not mutable, unlike those in most
programming laguages -- this follows the thinking in functional languages
not allowing side-effects. Thus, doing something repeatedly is usually
achieved (in XSL 1.0) via recursion.
In your case:
<xsl:template match="/">
<xsl:call-template name="fun1">
<xsl:with-param name="end" select="1000"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="fun1">
<xsl:param name="end" select="0"/>
<xsl:param name="start" select="0"/>
<xsl:if test="$start < $end">
<xsl:call-template name="fun2"/>
<xsl:call-template name="fun1">
<xsl:with-param name="end" select="1000"/>
<xsl:with-param name="start" select="$start + 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="fun2">
...etc
</xsl:template>
--A
From: "ChandraShekar, A" <ChandraShekar(_dot_)A(_at_)siemens(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: [xsl] Increment a variable
Date: Thu, 18 Aug 2005 10:04:39 +0530
Hello,
I don't know whether this question is stupid question or not?
How can I achieve following c++ code in XSLT.
void fun1()
{
for(int i=0;i<1000;i++)
{
fun2(i);
}
}
void fun2(int var)
{
if ( var == 0 )
{
var++;
// do something
}
else
{
Var++;
// do something
}
if ( var == 100 )
{
Var = 0;
// do something
}
}
_________________________________________________________________
Don?t just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
--~------------------------------------------------------------------
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>
--~--