This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Applying a named template to arbitrary content
- To: xsl-list at mulberrytech dot com
- Subject: Re: Applying a named template to arbitrary content
- From: Steve Tinney <stinney at sas dot upenn dot edu>
- Date: Mon, 13 Mar 2000 09:41:51 -0500
- References: <4.2.0.58.20000312200839.0160b700@gw.xippix.com>
- Reply-To: xsl-list at mulberrytech dot com
> I'm trying to make a generic template which will, in effect,
> simply insert stuff before and after the content. In one case, I
> want to do it to apply font styling parameters etc. where needed:
This is hard to do in XSLT 1.0, but quite a few people have asked for
it, so maybe evaluating the name of the template to call will come in a
future version of the language.
For now, one approach is that of Mike Kay---you can check the archive
for details, but the meat of it is this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="xyz" match="xsl:template[@name='xyz']">
<xsl:message>Hello xyz.</xsl:message>
</xsl:template>
<xsl:template match="/">
<xsl:variable name="tname" select="'xyz'"/>
<xsl:apply-templates
select="document('')/*/xsl:template[@name=$tname]"/>
</xsl:template>
</xsl:stylesheet>
The other approach is to rethink your problems and solutions. For
example, much of what you seem to want to do could probably also be
achieved by use of xsl:attribute-set, or increased use of CSS in
combination with 'class' attributes on your HTML output.
Steve
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list