Remi COCULA wrote:
When using xsl:call-template it seems that we can't use a parameter as the
name of the template to call.
Example :
<xsl:template name="cadre">
<xsl:param name="p_contenu"/>
<xsl:call-template name="{$p_contenu}"/>
</xsl:template>
It does'nt work : Xalan logs this error (sorry it's french)
2003-12-22 03:16:28 - path="/gcdev" :gc:
javax.xml.transform.TransformerConfigurationExcept ion:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: Valeur incorrecte : {$p_contenu}
utilisée pour l'attribut QNAME : name
Any suggestion to fix this problem?
hi,
this is not an error : the name of a template *must* be a QName, as
xalan output shows
however, you may use the following design pattern, known as "template
tag" to get the requested behaviour :
<xsl:stylesheet xmlns:xsl="..."
xmlns:tt="*** template tag ***">
....
<xsl:template name="cadre">
<xsl:param name="p_contenu"/>
<xsl:apply-templates
select="document('')/*/tt:template[@name=$p_contenu]"/>
</xsl:template>
<tt:template name="theName"/>
<xsl:template match="tt:template[@name='theName']">
<!--your stuff here-->
</xsl:template>
<tt:template name="anotherName"/>
<xsl:template match="tt:template[@name='anotherName']">
<!--your stuff here-->
</xsl:template>
--
Cordialement,
///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------