XML
--------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xslt" ?>
<Root>
<Title>Looping function example</Title>
<Limit>10</Limit>
</Root>
XSLT
----------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<head>
<title> <xsl:value-of select="Root/Title" /> </title>
</head>
<body>
<!--CALLING FUNCTION -->
<h3><xsl:value-of select="Root/Title" /></h3>
<xsl:call-template name="LoopingFunc">
<xsl:with-param name="limit" select="Root/Limit" />
</xsl:call-template>
</body>
</html>
</xsl:template>
<!--LOOPING FUNCTION -->
<xsl:template name="LoopingFunc">
<xsl:param name="limit"/>
<xsl:if test="$limit > 0">
<h5>
<xsl:value-of select="$limit"/>
</h5>
<xsl:call-template name="LoopingFunc">
<xsl:with-param name="limit" select="$limit - 1" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Out put
----------------
Looping function example
10
9
8
7
6
5
4
3
2
1
No comments:
Post a Comment