[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Applying a named template to arbitrary content
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|