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

RE: Recursively looping through a template only X numb

Subject: RE: Recursively looping through a template only X number of times?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 28 Nov 2006 17:15:16 -0000
RE:  Recursively looping through a template only X numb
> However, if I do that...
> 
> <xsl:variable name="TOCTemplateLoopCount" select="0" /> 
> <xsl:template name="rulelistTOC">
> 	<xsl:variable name="TOCTemplateLoopCount"
> select="$TOCTemplateLoopCount+1"/>
> 	...
> </template>
> 
> It seems to get re-set to '0' on each pass of the template as 
> it is evaluated to '0 + 1' each time. I'm confused as to why that is.

The variable isn't being reset. You have two completely different variables,
that just happen to share the same name. It's exactly as if you had written

<xsl:variable name="TOCTemplateLoopCount-1111" select="0" /> 
<xsl:template name="rulelistTOC">
   <xsl:variable name="TOCTemplateLoopCount-2222"
select="$TOCTemplateLoopCount-1111 + 1"/>

You want to use template parameters. Declare xsl:param inside the template,
and use xsl:with-param to set a value on the call.

Michael Kay
http://www.saxonica.com/

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.