This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: nested templates?
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] nested templates?
- From: "Kurt Cagle" <cagle at olywa dot net>
- Date: Wed, 16 May 2001 14:03:32 -0500
- References: <NABBLNLEFKJBBIBELMLOIECONFAA.Chris@Bayes.co.uk>
- Reply-To: xsl-list at lists dot mulberrytech dot com
I remember early in the development process that nested templates were a
part of the test implementations, and in all honesty they didn't really add
much to the structure and were conceptually a pain to deal with. You can do
the same thing with a modal call:
<xsl:template match="foo">
<xsl:apply-templates select="." mode="bar"/>
</xsl:template>
<xsl:template match="foo" mode="bar">
<!-- do boo.bar -->
</xsl:template>
and you gain the added benefit of still being reference the modal "bar" type
of foo from other templates. <xsl:for-each> can certainly be over-used
(badly) but again I think that what works best here is to teach people to
use for-each primarily as a context switcher. It does come into play more
often with node-sets, however; I have a message board system which orders a
list of messages in descending order prior to displaying a page of such
orders:
<xsl:variable name="orderedList">
<xsl:for-each select="$messages">
<xsl:sort select="date" order="descending"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:variable>
Creating an entire template just to copy the contents of a list seemed
overkill here, so for-each worked fine.
-- Kurt Cagle
----- Original Message -----
From: "Chris Bayes" <Chris@Bayes.co.uk>
To: <xsl-list@lists.mulberrytech.com>
Sent: Wednesday, May 16, 2001 3:35 PM
Subject: RE: [xsl] nested templates?
>
> >But, hypothetically, what would be the difference between these
> >hypothetical nested-and-scoped templates, and the not-so-hypothetical
(but
> >often misapplied, and hence warned-against) xsl:for-each?
>
> Well probably not much really you can do anything with anything but I
guess
> it's just a view of the playing field. for-each restricts you to a one
> dimensional view of things unless you use it to change context (the
playing
> field you are on). But then you should call it something else. Team-bus
> comes to mind.
> I think nested templates could be quite powerful and a lot more logical.
>
> >I suppose it would be okay for beginners to use nested templates? :->
>
> Hey why not? But then they would be using them for different reasons than
> for-each
>
> I think it would make things a little less verbose and implementation
surely
> wouldn't be that difficult. Just a couple more levels on the stack.
>
> I dunno it just seems more logical for some situations. I haven't thought
it
> through though. It just struck me as something that should be. I guess
> there is a reason why it wasn't allowed.
>
> Ciao Chris
>
> XML/XSL Portal
> http://www.bayes.co.uk/xml
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list