D
Daryl
Hello
I am using apply-templates and would like to pass a parameter to the
template using with-param. Using call-template passes the parameter,
but when I use apply-templates, the parameter seems to be lost. Can
parameters be passed with apply-templates? Any ideas?
<!--xml-->
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="tran2.xsl"?>
<doc>
<parameters>
<parameter name="a">
<options>2</options>
</parameter>
<parameter name="b"/>
<parameter name="c" >
<options>1</options>
</parameter>
<parameter name="d"/>
</parameters>
</doc>
<!--xsl called trans2.xsl-->
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" media-type="text/xml" indent="yes"/>
<xsl:template match="/">
<xsl:element name="treeview" >
<xsl:element name="element" >
<xsl:attribute name="name">doc</xsl:attribute>
<xsl:element name="contents">
<!--this works-->
<xsl:call-template name = "parameters">
<xsl:with-param name="testParam" select="1"/>
</xsl:call-template>
<!--this does not-->
<!--
<xsl:apply-templates match="parameters">
<xsl:with-param name="testParam" select="1"/>
</xsl:apply-templates>
-->
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
<!--paramaters tag. Can hold options -->
<xsl:template name="parameters" match="parameters">
<xslaram name="testParam" />
<xsl:if test="$testParam='1'">
Ok
</xsl:if>
<xsl:if test="$testParam=''">
failed
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Cheers in advance
Daryl
I am using apply-templates and would like to pass a parameter to the
template using with-param. Using call-template passes the parameter,
but when I use apply-templates, the parameter seems to be lost. Can
parameters be passed with apply-templates? Any ideas?
<!--xml-->
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="tran2.xsl"?>
<doc>
<parameters>
<parameter name="a">
<options>2</options>
</parameter>
<parameter name="b"/>
<parameter name="c" >
<options>1</options>
</parameter>
<parameter name="d"/>
</parameters>
</doc>
<!--xsl called trans2.xsl-->
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" media-type="text/xml" indent="yes"/>
<xsl:template match="/">
<xsl:element name="treeview" >
<xsl:element name="element" >
<xsl:attribute name="name">doc</xsl:attribute>
<xsl:element name="contents">
<!--this works-->
<xsl:call-template name = "parameters">
<xsl:with-param name="testParam" select="1"/>
</xsl:call-template>
<!--this does not-->
<!--
<xsl:apply-templates match="parameters">
<xsl:with-param name="testParam" select="1"/>
</xsl:apply-templates>
-->
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>
<!--paramaters tag. Can hold options -->
<xsl:template name="parameters" match="parameters">
<xslaram name="testParam" />
<xsl:if test="$testParam='1'">
Ok
</xsl:if>
<xsl:if test="$testParam=''">
failed
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Cheers in advance
Daryl