xsl-list
[Top] [All Lists]

Re: [xsl] XSLT: Taking Value of One Attribute and Smearing it Across multiple times

2007-05-04 06:42:55
Hello Torsten:

When I run the script as you had provided, I am merely getting an output as:

100100,

However for George, I am getting the right output. I am unfamiliar
with the recursive templates and so am trying to understand both of
your responses.

Thanks,
Rex

On 5/4/07, Torsten Schaßan <schassan(_at_)hab(_dot_)de> 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 &lt; $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


--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--