Reputation: 5293
how to implement counter type functionality in xslt
Upvotes: 2
Views: 1242
Reputation: 27
You can use recursion to simulate counter functionality, but you have not specified any input or output format, so providing some general code.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<!-- TODO: Auto-generated template -->
<xsl:call-template name="counter">
<xsl:with-param name="start" select="1" />
<xsl:with-param name="stop" select="10" />
<xsl:with-param name="increment" select="1" />
</xsl:call-template>
</xsl:template>
<xsl:template name="counter">
<xsl:param name="start" />
<xsl:param name="stop" />
<xsl:param name="increment" />
Value:<xsl:value-of select="$increment"/>
<xsl:if test="$increment < $stop">
<xsl:call-template name="counter">
<xsl:with-param name="start" select="$start" />
<xsl:with-param name="stop" select="$stop" />
<xsl:with-param name="increment" select="$increment+1" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0
Reputation:
XSLT is based upon Functional programming hence you can not use counters you can try Recursions if it can be of your help
Upvotes: 2