Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
I want to do a for-each over a series of nodes, extract some detail from each node, append the detail onto a string, then finally display the composite string result. Is there an easy way to do this in XSLT?
Thanks
Hi manwood
You would probably want to call templates recursively to build up your string, as you cannot re-assign values to a variable.
Here is an example of a call-template structure
<!-- Using call-template --> <table><tr><td> <xsl:call-template name="Fibonacci"> <xsl:with-param name="prev" select="1" /> <xsl:with-param name="next" select="1" /> <xsl:with-param name="itemsLeft" select="10" /> </xsl:call-template> </td></tr></table></xsl:template><xsl:template name="Fibonacci"> <xsl:param name="prev"/> <xsl:param name="next"/> <xsl:param name="itemsLeft"/> <xsl:value-of select="$prev"/><br/> <xsl:if test="$itemsLeft > 0"> <xsl:call-template name="Fibonacci"> <xsl:with-param name="prev" select="$next" /> <xsl:with-param name="next" select="$prev+$next" /> <xsl:with-param name="itemsLeft" select="$itemsLeft - 1" /> </xsl:call-template> </xsl:if></xsl:template>
To build up your string you could keep passing on the current string as a parameter in the recursion
>Tommy
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
How can I build up a string iteratively in XSLT?
Hi
I want to do a for-each over a series of nodes, extract some detail from each node, append the detail onto a string, then finally display the composite string result. Is there an easy way to do this in XSLT?
Thanks
Hi manwood
You would probably want to call templates recursively to build up your string, as you cannot re-assign values to a variable.
Here is an example of a call-template structure
To build up your string you could keep passing on the current string as a parameter in the recursion
>Tommy
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.