File: Data.xml
<sample>test</sample>
File: Transform.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="no" />
<xsl:template name="hyphens">
<xsl:param name="howMany">1</xsl:param>
<xsl:if test="$howMany > 0">
<xsl:text>-</xsl:text>
<xsl:call-template name="hyphens">
<xsl:with-param name="howMany" select="$howMany - 1" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="sample">
Print 1 hyphen:
<xsl:call-template name="hyphens" />
Print 3 hyphens:
<xsl:call-template name="hyphens">
<xsl:with-param name="howMany" select="3" />
</xsl:call-template>
Print 20 hyphens:
<xsl:call-template name="hyphens">
<xsl:with-param name="howMany" select="20" />
</xsl:call-template>
Print 0 hyphens:
<xsl:call-template name="hyphens">
<xsl:with-param name="howMany" select="0" />
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
Output:
Print 1 hyphen:
-
Print 3 hyphens:
---
Print 20 hyphens:
--------------------
Print 0 hyphens:
|