In named templates parameters can be used in the same way as in the case of match templates.
|
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="/"> <xxx> <xsl:call-template name="x"> <xsl:with-param name="a" select="10"/> </xsl:call-template> <xsl:call-template name="x"> <xsl:with-param name="a" select="33"/> </xsl:call-template> </xxx> </xsl:template> <xsl:template name="x"> <xsl:param name="a"/> <yyy> <xsl:value-of select="10 * $a"/> </yyy> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa> <bbb id="id1"/> <ccc id="id2"/> </aaa> |
Output
<xxx> <yyy>100</yyy> <yyy>330</yyy> </xxx> |
| Previous chapter: | Axes |
| Next chapter: | Variables and Parameters |
| Previous page: | Naming match templates |
| Next page: | - - - |