[Home] [By Thread] [By Date] [Recent Entries]
Here is another XSLT 1.0 solution:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/input">
<output>
<xsl:for-each select="data/item">
<xsl:apply-templates select="../following-sibling::repeat">
<xsl:with-param name="item" select="." />
<xsl:with-param name="position" select="position()" />
</xsl:apply-templates>
</xsl:for-each>
</output>
</xsl:template><xsl:template match="repeat"> <xsl:param name="item"/> <xsl:param name="position"/> <item>
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="local-name() = 'value-of'">
<xsl:value-of select="$item/value" />
</xsl:when>
<xsl:when test="local-name() = 'position-of'">
<xsl:value-of select="$position" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</item></xsl:template> </xsl:stylesheet> Regards, Mukul On 6/7/06, Neil Crofts <neil.crofts@xxxxxxxxx> wrote: I'm trying to transform some XML which is supposed to act as an iterator/repeat statement without much success at the moment. I was wondering if anyone had some advice about the best way to approach this sort of problem. For example, my source XML looks a bit like the following:
|

Cart



