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

Re: Is xsl:for-each "syntactic sugar"?

Subject: Re: Is xsl:for-each "syntactic sugar"?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 07 May 2010 02:41:15 +0100
Re:  Is xsl:for-each "syntactic sugar"?
On 07/05/2010 00:02, Costello, Roger L. wrote:
> Hi Folks,
>
> 1. Everything that can be done using xsl:for-each can be done using a recursive function. (True or False)


anything that can be done on a computer can be done with a recursive function so clearly the statement is true, but not very informative.
More to the point, xsl:for-each is (if you want to view it that way) syntactic sugar for apply-templates in a unique mode, with a single template that matches all nodes.


>
> 2. There are things that can be done using a recursive function that cannot be done using xsl:for-each. (True or False)


the two things are not comparable. "recursive function" is an abstract concept not related to any particular programming language. "xsl:for-each" is a particular syntactic construct in xslt. You can not do anything with xsl:for-each on its own, its expressive power is just related to what you use in the body, which can of course include calling recursive functions.

>
> 3. xsl:for-each is syntactic sugar. (True or False)

As above, it can be seen as syntactic variation on apply-templates, however you have to work quite hard to get exactly the same behaviour with respect to variable scope.

>
> 4. Favor recursive functions over xsl:for-each. (True or False)

One might always expect that compilers have an easier job to optimise specific language constructs rather than using generic programming constructs which have notionally the same behaviour. Thus one would presumably expect to find that xsl:for-each is going to be pretty efficient.
>
> /Roger


David

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.