Subject: Re: [xsl] nested templates? From: "Kurt Cagle" <cagle@xxxxxxxxx> Date: Wed, 16 May 2001 14:03:32 -0500 |
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: [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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] nested templates?, Chris Bayes | Thread | RE: [xsl] nested templates?, Chris Bayes |
Re: [xsl] nested templates?, Alex Black | Date | [xsl] Sorting Sibling Nodes !!!, Ciaran Byrne |
Month |