This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
syntax sugar for call-template
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] syntax sugar for call-template
- From: "Clark C. Evans" <cce at clarkevans dot com>
- Date: Wed, 14 Feb 2001 17:58:18 -0500 (EST)
- Reply-To: xsl-list at lists dot mulberrytech dot com
> > | Making a template and calling a template are just too verbose.
> > | This seperate issue can be solved by an additional namespace "xf"
> > | with the following behavior:
> > |
> > | Anywhere, except as a child of "xsl:template",
> > |
> > | <xf:func x="y" /> is equivalent to <xsl:call-template name="func">
> > | <xsl:with-param name="x"
> > | select="y" />
> > | </xsl:call-template>
> > |
> > | and when a child of xsl:template,
> > |
> > | <xf:func x="y"> is equivalent to <xsl:template name="func">
> > | ... <xsl:param name="x"
> > | </xf:func> select="y" />
> > | ...
> > | </xsl:template>
> >
> > This approach would appear to have problems
> > passing literal result-tree-fragment arguments
> > to templates...
> >
> > <xsl:call-template name="foo">
> > <xsl:with-param name="content">
> > <ul>
> > <li>One</li>
> > <li>Two</li>
> > </ul>
> > </xsl:with-param>
> > </xsl:call-template>
> >
> > Your example would imply this would be:
> >
> > <xf:foo content="<ul><li>...</li></ul>"/>
>
> First, this is not a *replacement* for the current syntax,
> it is a short-hand that makes template calling and definition
> more bareable for simple, "string" arguments.
>
> Second, one would obviously have to do the appropriate escaping
> when passing result-tree fragments. I'm not saying this is
> pretty, however, I'm proposing a short-hand, not a replacement.
> <xf:foo content="<ul><li>...</li></ul>" />
Sorry that I implied that passing a result-tree fragment
using this mechanism would be possible (not that you can
do much with result-tree fragments besides treating them
as strings).
But this isn't the point. The point is that the
template calling mechanism is too verbose. It can
be shortened up significantly in a backward-compatible
manner using the abbreviation described.
Like I said:
<xf:func arg="val" /> is-equivalent-to <call-template name="func">
<with-param name="arg"
select="val" />
</call-template>
Note that I did NOT say
<xf:func arg="val" /> is-equivalent-to <call-template name="func">
<with-param name="arg">
val
</with-param>
</call-template>
;) Clark
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list