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

Re: XSLT Draft: Modes vs. Variables

Subject: Re: XSLT Draft: Modes vs. Variables
From: James Clark <jjc@xxxxxxxxxx>
Date: Wed, 28 Apr 1999 07:47:07 +0700
xslt call vs apply template
Oren Ben-Kiki wrote:

> >... there seems to be very little
> >difference between a template declared as
> >
> ><xsl:template match="node()" mode="bo-peep" priority="[infinity]">
> >
> >and one declared as
> >
> ><xsl:template name="bo-beep">.
> 
> There's one crucial difference: calling:
> 
> <xsl:apply-templates mode="bo-beep" select="..."/>
> 
> Has no equivalent using named templates. Note that the following:
> 
> <xsl:for-each select="...">
>     <xsl:call-template name="bo-beep"/>
> </xsl:for-each>
> 
> Is _not_ the same thing, since there must be only one template name
> 'bo-beep' in the 'for-each' case.

Huh?  It would be an error if there was more than one template rule
declared as:

<xsl:template match="node()" mode="bo-peep"
priority="[infinity]">...</xsl:template>

and, given such a template rule,

  <xsl:apply-templates mode="bo-peep" select="..."/>

would always apply the same template.  If xsl:call-template had a select
attribute, then it would be exactly equivalent to what in the current WD
is:

<xsl:for-each select="...">
  <xsl:call-template name="bo-beep"/>
</xsl:for-each>

The WG considered lots of different alternatives (including not having
<xsl:call-template> and <xsl:template name="..."> at all, having a
select attribute on xsl:call-template, combining xsl:apply-templates and
xsl:call-template) before settling on the current design.
The model behind the current design is that there are two ways to invoke
templates, by name and by pattern matching. To invoke templates by name
use xsl:call-template.  To invoke templates by pattern matching use
xsl:apply-templates.  The match and mode attributes on xsl:template
control when the template can be invoked by pattern matching.  The name
attribute on xsl:template controls when the template can be invoked by
name.

James



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.