RE: XSLT Draft: Modes vs. Variables

Subject: RE: XSLT Draft: Modes vs. Variables
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 27 Apr 1999 09:27:31 +0100
> From: Oren Ben-Kiki [mailto:oren@xxxxxxxxxxxxx]
> Unifying macros and templates is neat. I would like to know, however, what
> the expected behavior is when a named template has a match pattern. Is the

> call to the template ignored unless the current node matches 
> the pattern?

My reading of this was that the template is invoked if either (a) it is
called by name, or (b) it matches the pattern.

It did occur to me that this unification of templates and macros could be
taken a step further, since "modes" seem to be a combination of matching by
pattern and matching by name. In fact, 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 are some subtle differences, for example <xsl:call-template> leaves
the current node list unchanged while <xsl:apply-templates select=".">
changes it (so within the called template <xsl:value-of select="position()">
will presumably always be 1): but we still seem to have two facilities with
a lot of overlap. It's not clear that the two bundled features of "keep the
same context" and "select template by name" have anything to do with each
other, it would make as much sense to have a select-by-name that changes the
context, or a select-by-pattern that keeps it. 

Mike Kay

PS: the rules for evaluating expressions say that the context includes a
"current node list". But as far as I can see the only expressions that use
the current node list are position() and last(), so in fact the only
information we need to carry about the current node list is the position of
the current node and the size of the list. Anyone disagree?


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


Current Thread