cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Per Kreipke" <>
Subject XSL: xsl:call-template question...
Date Fri, 18 Aug 2000 20:43:39 GMT
Q: Is it possible to call templates whose names are derived dynamically?

E.g. If I have a hierarchy:

  <object type="circle">
    <center x="10" y="20"/>
  <object type="square">

I'd like to derive the name of the template (and <xsl:include> it) for
'circle' and 'square' dynamically in the XSLT file. Snippet:

<xsl:apply-templates match="objects">
  <xsl:for-each select="channel">
    <xsl:call-template select="channel/@type">
      <xsl:with-param name="type"><xsl:value-of

- Note the attempt to use 'select' in <xsl:call-template>. Unsuccessful

- <xsl:call-template name="channel/@type"> also unsuccessful (exception).

- <xsl:variable name="what" select="channel/@type"/>
  <xsl:call-template name="$what">

- <xsl:call-template name="{channel/@type}"> also unsuccessful.

Does anyone have any ideas on how to do this?

One way to do this would be to hard code a <xsl:choose> list of 'renderers'
but that defeats the purpose of letting the data specify the format.


View raw message