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

RE: Increment a variable

Subject: RE: Increment a variable
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Thu, 18 Aug 2005 05:14:25 +0000
xslt param increment
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:  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

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.