[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Shorthand.

Subject: Re: Shorthand.
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 25 Jul 2007 20:43:31 +0200
Re:  Shorthand.
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.