[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: XSLT: Taking Value of One Attribute and Smearing i
Subject: Re: XSLT: Taking Value of One Attribute and Smearing it Across multiple times
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Fri, 04 May 2007 16:25:38 +0300
|
Hi Torsten,
The difference is that the putValue template will be called lon(n) times
while the recursion template will be called n times. For large values of
n that can be a problem both in term of execution time and stack memory.
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Torsten Scha_an wrote:
Dear Rex, George and David,
maybe I got it wrong, but wouldn't the following be a much simpler
solution?
<xsl:template match="offers">
<xsl:call-template name="recursion">
<xsl:with-param name="start"><xsl:value-of
select="fcst/@start_hr"/></xsl:with-param>
<xsl:with-param name="end"><xsl:value-of
select="fcst/@end_hr"/></xsl:with-param>
<xsl:with-param name="value"><xsl:value-of
select="fcst/@value"/></xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="recursion">
<xsl:param name="start"/>
<xsl:param name="end"/>
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="$start < $end">
<xsl:value-of select="$value"/>
<xsl:call-template name="recursion">
<xsl:with-param name="start"><xsl:value-of select="$start +
1"/></xsl:with-param>
<xsl:with-param name="end"><xsl:value-of
select="$end"/></xsl:with-param>
<xsl:with-param name="value"><xsl:value-of
select="$value"/></xsl:with-param>
</xsl:call-template>
<xsl:text>, </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Anyway, just to point it out again, in XSLT 1.0 the problem is solved
with recursive call-templates and passing the template a param (not
variable!).
Best, Torsten
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|