Steve wrote:
Hey there, I have a template for creating ajax links:
<xsl:template name="a">
<xsl:with-param name="href" />
<xsl:with-param name="text" />
<a href="{$href}" onClick="showData('{$href}');return
false;"><xsl:value-of select="$text" /></a>
</xsl:template>
is there some shorter way to use this (XSL 1.0) template than...
<xsl:call-template name="a">
<xs:param name="href" select="'x'"/>
<xs:param name="text" select="'y'"/>
</xsl:call-template>
It depends. You may not need a named template at all. Or you can use the
context node if you like, or you pass the context node, on in one of the
parameters, which may make things shorter. In XSLT 2.0 things get even
easier, where you can define functions.
If you use this browser based, you cannot rely on EXSLT extensions like
exslt:function. If you use it server side, you can lookup the
documentation of your processor whether (and how) it supports
exslt:function or not.
Translating your above example to a template match, would be (without
knowing your source, guessing):
<xsl:template match="*[x|y]">
a href="{y}" onClick="showData('{y}');return
false;"><xsl:value-of select="y" /></a>
</xsl;tempalte>
Using the context node, it would become:
<xsl:call-template name="a" />
with the same structure as the matching template for the template.
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>
--~--