RE: [xsl] Increment a variable

Subject: RE: [xsl] Increment a variable
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Thu, 18 Aug 2005 05:14:25 +0000
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 &lt; $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.A@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
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
		}
	}

_________________________________________________________________
Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Current Thread