[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Porting own template language to xslt


Subject: Re: [xsl] Porting own template language to xslt
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 16 Mar 2006 12:22:40 +0000

On 3/16/06, Peter Flynn <pflynn@xxxxxx> wrote:
> On Thu, 2006-03-16 at 11:16 +0000, Michael Kay wrote:
> > I think that using xsl:for-each is the natural way to do this.
>
> Interestingly I just had a Prof of CS call me for help (he's learning
> XSLT) and he thought it was completely unnatural -- semantically --
> to use for-each just to switch contexts for a single node; that it
> should be kept for iteration over 1+ nodes.

No, it makes perfect sense once you get it.  Why should the for-each
care whether you select 1 node or 1000?... you are still doing
something "for each" node selected.

Switching variables is a different matter, eg

<xsl:for-each select="$someVar">
  do something
  <xsl:for-each select="$someOtherVar">
    do something else

"for-each" doesn't really fit there, so maybe there's scope for
something there... but usually when I find something in XSLT that I
don't think is quite right, after using it a few times (and perhaps
after a few posts to xsl-list) I realise I was wrong and the design of
XSLT is in fact, genious :)


Current Thread
Keywords