[xsl] Re: Use recursion effectively in XSL

Subject: [xsl] Re: Use recursion effectively in XSL
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 25 Oct 2002 02:34:41 -0700 (PDT)
--- Frank Carlos  wrote:
 
> Using XSL transformations effectively and efficiently requires
> understanding how to use XSL as a functional language, and this means
> understanding recursion. This article introduces the key concepts of
> recursion and its particular use in XSL. Techniques for optimizing
> XML
> translations and avoiding errors while using recursion are also
> explained.
> Each concept and technique is accompanied with example code for the
> reader's reference.
> 
> Use recursion effectively in XSL
>
http://www-106.ibm.com/developerworks/xml/library/x-xslrecur/?t=gr,lnxw914=XSLrecusionTips


This article is a useful introduction into the topic of using recursion
in XSLT. As such it would be valuable to a large group of
beginning-XSLT programmers.

I have just a few minor notes:

1. Is XSL a functional language?
No need to even ask this question, because the answer is definitely,
positively yes.

The fact that the most knowledgeable specialists in functional
programming like Phil Wadler (one of the creators of Haskell having
very fundamental contributions to FP (e.g. the theory and introduction
of Monads in functional programming)) give a definite positive answer
to this question -- well, this should stop all unfruitful arguments.
Phil even calls XQuery (a language, which does not have support for
higher order functions) a functional language [1].

2. Common uses of recursion in XSL
As I said, this is a good introductory material. However, it stops
short of mentioning of the very useful and extremely powerful generic
paradigm of folding/unfolding operations over a list. At least
mentioning this and providing some references would be very helpful.

3. Optimizing recursion patterns in XSL
The same remark applies to this sections -- Divide and Conquer,
Segmentation and their combination have been known for many years (e.g.
"Algorithms in C++" by Sedgewick) [2]. 

An article discussing exactly these technique was published 6 months
ago in topxml.com:

"Two-stage recursive algorithms in XSLT", [3]

The Divide and Conquer algorithmic principle has been discussed
extensively on this list, and snippets have been published in
topxml.com.

References for further reading would be very helpful.

To summarise, I find this article very useful and necessary for a
considerable part of the XSLT programming community. While it doesn't
go deep enough and lacks a necessary more general context, of which the
described ideas are a natural part, this article is a very first step
in the right direction.

References:

[1] "XQuery, a typed functional language for querying XML", Philip
Wadler. Lecture notes for the Summer School on Advanced Functional
Programming, Oxford, August 2002. 
http://www.research.avayalabs.com/user/wadler/papers/xquery-afp/xquery-afp.pdf

[2] "Algorithms in C++", Robert Sedgewick, Addison-Wesley, ISBN:
0-201-35088-2

[3] Two-stage recursive algorithms in XSLT, By Dimitre Novatchev and
Slawomir Tyszko, 
http://www.topxml.com/xsl/articles/recurse/




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread