J
Julien Phalip
Hi everyone!
I am doing an XSL transformation from the following XML file:
<foo>
<attribute>a</attribute>
</foo>
The xslt file is:
<xsl:include href="a.xsl"/> <!-- Defines the template 'a' -->
<xsl:include href="b.xsl"/> <!-- Defines the template 'b' -->
<xsl:include href="c.xsl"/> <!-- Defines the template 'c' -->
<xsl:template name="foo">
<xsl:if test="attribute = 'a'">
<xsl:call-template name="a"/>
</xsl:if>
<xsl:if test="attribute = 'b'">
<xsl:call-template name="b"/>
</xsl:if>
<xsl:if test="attribute = 'c'">
<xsl:call-template name="c"/>
</xsl:if>
etc...
</xsl:template>
But now I am starting to have a lot of templates, and it requires to
add another "if" statement every new template I create.
So I would like to make this XSLT file simpler by doing something
like:
<xsl:template name="foo">
<xsl:call-template name="{./attribute}"/>
</xsl:template>
But this doesn't work. I get the error "Could not find template named:
{./attribute}".
Can anybody help me with that?
Thanks a lot,
Julien
I am doing an XSL transformation from the following XML file:
<foo>
<attribute>a</attribute>
</foo>
The xslt file is:
<xsl:include href="a.xsl"/> <!-- Defines the template 'a' -->
<xsl:include href="b.xsl"/> <!-- Defines the template 'b' -->
<xsl:include href="c.xsl"/> <!-- Defines the template 'c' -->
<xsl:template name="foo">
<xsl:if test="attribute = 'a'">
<xsl:call-template name="a"/>
</xsl:if>
<xsl:if test="attribute = 'b'">
<xsl:call-template name="b"/>
</xsl:if>
<xsl:if test="attribute = 'c'">
<xsl:call-template name="c"/>
</xsl:if>
etc...
</xsl:template>
But now I am starting to have a lot of templates, and it requires to
add another "if" statement every new template I create.
So I would like to make this XSLT file simpler by doing something
like:
<xsl:template name="foo">
<xsl:call-template name="{./attribute}"/>
</xsl:template>
But this doesn't work. I get the error "Could not find template named:
{./attribute}".
Can anybody help me with that?
Thanks a lot,
Julien