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

Re: comment on 'mode' and also Re: Processing modes

Subject: Re: comment on 'mode' and also Re: Processing modes
From: James Clark <jjc@xxxxxxxxxx>
Date: Thu, 15 Apr 1999 18:41:26 +0700
xsl apply template mode single

Alistair MacDonald wrote:
> 
> >>> Lars Marius Garshol <larsga@xxxxxxxxxx> 04/15 8:19 am >>>
> > My understanding of processing modes is that
> >    <xsl:apply-templates modes="by-number"/>
> > should only apply template rules that have the by-number mode and
> > ignore all template rules that have no mode.
> 
> That should be 'mode', not 'modes'. The match sequence will be a template that
> HAS the required 'mode' and, if that fails a template with NO mode.

If you specify a mode on xsl:apply-template, then template rules in the
stylesheet with no mode are not considered: only the built-in rules are
applied.


> Why ? Because, as I said, modes aren't sticky and have to be
> *EXPLICITLY* passed on. However, <foo> was matched by the IMPLICIT
> rule, which didn't explicitly pass on the mode. This, compined
> with the fact that there is no way of find the *XSL* parameters
> to the triggering <xsl:apply-templates ... /> means that 'mode'
> is *almost* useless. (It *DOES* have uses, but trying to use it
> effectively means implementing lots of "do-nothing" templates
> which just call apply-templates with the same mode as they had!)

Why do you need lots of "do-nothing" template rules. You need one
"do-nothing" template rule:

<xsl:template match="*" mode="by-number">
  <xsl:apply-templates mode="by-number"/>
</xsl:template>

> There is no reason why 'mode' should not be sticky, since it
> could easily be cancelled ('mode=""') and, if no mode is matched
> it defaults to the empty mode.

There are two separate issues:

(a) whether modes should be sticky

(b) whether the built-in rule remains in the same mode or switches back
to the initial mode

The sticky versus non-sticky modes issue is very similar to the dynamic
versus lexical scoping issue.  Sticky modes like dynamic scoping is
seductive but a bad idea. With non-sticky modes you can tell just by
looking at the stylesheet which templates are applicable for a given use
of xsl:apply-templates.

On the built-in rule issue, I think there are arguments both ways. 
Whichever way you do it, you can get the other behaviour by adding a
single additional template rule for each mode.

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.