Re: [xsl] Functional Programming: How do I convert an xsl:for-each loop into a functional style?

Subject: Re: [xsl] Functional Programming: How do I convert an xsl:for-each loop into a functional style?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 21 Jan 2010 19:52:23 +0000
On 21/01/2010 19:33, Costello, Roger L. wrote:
Hi Folks,

Would you please give me an example of an XSLT transform that is not written in a functional style?

anything using saxon:assign


And then would you show an equivalent XSLT transform, but written in a functional style?

replace the assignment by something else, eg parameter passing.

I presume that it is better to write XSLT transforms in a functional style, yes?
Only in so far as it is usually better to use the idioms for which a language was designed. If you try to write your Java like fortran, it's painful and you're better off writing in Fortran but the converse is also true: if you are programming in a java style you may find java more natural than fortran.



XSLT has (some) aspects of a functional language although it lacks what is usually thought of as the definining characteristic of such a language that functions can be passed as values. Of course Dimitre's FXSL goes a long way to filling that gap by using element nodes as proxies for function terms, and the long awaited xpath 2.1 promises to go further with higher order function terms.


David

Current Thread