ForLoop.xslt:
- <?xml version="1.0" encoding="utf-8"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
- <xsl:output method="xml" indent="yes"/>
- <xsl:template name="for-loop">
- <xsl:param name="i"/>
- <xsl:param name="count"/>
- <xsl:if test="$i < $count">
- <!--Put what you want to do in for loop here.-->
- <xsl:element name="Loop">
- <xsl:value-of select="$i"/>
- </xsl:element>
- </xsl:if>
- <xsl:if test="$i < $count">
- <xsl:call-template name="for-loop">
- <xsl:with-param name="i">
- <xsl:value-of select="$i + 1"/>
- </xsl:with-param>
- <xsl:with-param name="count">
- <xsl:value-of select="$count"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- <xsl:template match="/">
- <xsl:element name="Chimomo">
- <xsl:call-template name="for-loop">
- <xsl:with-param name="i">1</xsl:with-param>
- <xsl:with-param name="count">10</xsl:with-param>
- </xsl:call-template>
- </xsl:element>
- </xsl:template>
- </xsl:stylesheet>
ForLoop.xml:
- <?xml version="1.0" encoding="UTF-8"?>
- <Chimomo></Chimomo>
The transformed xml:
- <?xml version="1.0" encoding="utf-8"?>
- <Chimomo>
- <Loop>1</Loop>
- <Loop>2</Loop>
- <Loop>3</Loop>
- <Loop>4</Loop>
- <Loop>5</Loop>
- <Loop>6</Loop>
- <Loop>7</Loop>
- <Loop>8</Loop>
- <Loop>9</Loop>