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

Re: nested templates?

Subject: Re: nested templates?
From: "Kurt Cagle" <cagle@xxxxxxxxx>
Date: Wed, 16 May 2001 14:03:32 -0500
nested template
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@xxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, May 16, 2001 3:35 PM
Subject: RE:  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


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.