Steve wrote:
I'm using MSXML
Example:
xsl---
<xsl:template name="a">
<xsl:param name="href" />
<xsl:param name="text" />
<a href="{$href}" onClick="showData('{$href}');return
false;"><xsl:value-of select="$text" /></a>
</xsl:template>
<xsl:template match="/">
<xsl:call-template name="a">
<xsl:with-param name="href" select="'process.asp'" />
<xsl:with-param name="text" select="'Click me, baby'" />
</xsl:call-template>
</xsl:template>
--
output----
<a href="process.asp" onClick="showData('process.asp');return
false;">Click me, baby</a>
------
I have no obstacles except its length. exslt:function seems like it
would suffice. Reading up now.
One of the drawbacks of using XSLT 1.0 is its verbosity. If you are
using this server side, you can replace your XSLT processor with an XSLT
2.0 compliant one (there's a .NET version of Saxon and Gestalt
available, and a recent mail on this list revealed that the AltovaXML
(free, contains xslt 2.0 compliant processor) can also be called from
.NET apps).
If you can't upgrade for any reason (though only few reasons should
exist against upgrading ;) and when you locked yourself in with MSXML
anyway, you can use JScript for any functions you would like to create.
Your example does not enlighten what was unclear from your first
examples: why you actually need a named template. The way you show it
above perfectly fits for inlining. It depends on the way you pass the
parameters, or how you organized the rest of your stylesheet whether you
need the verbosity of named templates and/or with-params or not.
On the other side, this *is* the way to create function-like behavior,
but be aware of the pitfall to use it too often and make your stylesheet
look as if you wrote an imperative / procedural program (meaning: in
many occasions, named templates can be replaced by matching templates,
possibly with modes).
The only way to really help you here, is when you show more about the
context how you are using it.
Cheers,
-- Abel Braaksma
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--