cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Per Kreipke" <...@onclave.com>
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:

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

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
select="@type"/></xsl:with-param>
    </xsl:call-template>
  </xsl:for-each>
</xsl:apply-templates>


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

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

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

- <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.

Per.



Mime
View raw message