ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
RE: [xsl] Recursively looping through a template only X number of times?
by Michael Kay other posts by this author
Nov 28 2006 9:15AM messages near this date
[xsl] Recursively looping through a template only X number of times? | RE: [xsl] Recursively looping through a template only X number of times?
& XSLT >  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/


--~------------------------------------------------------------------
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@[...].com> 
--~--
Thread:
Darrel Austin
Michael Kay
Brian Martinez
Darrel Austin
Darrel Austin

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved