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

Re: Re: mapping (Was: Re: Re: . in for)

Subject: Re: Re: mapping (Was: Re: Re: . in for)
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Mon, 14 Jan 2002 17:09:56 +0100
call template apply template difference
Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote
> > 3. Higher order functions. I'm walking on thin ice here but i
> >  believe this requires the possibility to compose lambda expressions
> Wrong.

Thank you for the correction, as you and others pointed out i was
seriously confused here. 

Now when you introduced your functional programming techniques you
used it in conjunction with the term "generic template", which got
stuck. Let me repeat the essentials of this technique from my point
of view here, so we may discuss differences later:

   <xsl:stylesheet version="1.0"

     <!-- Artificial element used to refer to a function -->

     <!-- The function "myfunc", implemented as template -->
     <xsl:template match="fp:ref-to-myfunc">

     <!-- The "generic template" which takes a function
        reference as parameter -->
     <xsl:template name="some-framework-template">
       <xsl:param name="funcref"/>
       <!-- invoke the function passed as parameter -->
       <xsl:apply-template select="$funcref"/>

     <!-- Random sample template ... -->
     <!xsl:template match="stuff">
       <!-- ... for demonstrating how to call the "generic
         template", passing a specific function as parameter -->
       <xsl:call-template name="some-framework-template">
         <xsl:with-param name="funcref"
Am i on the right track (perhaps apart from nomenclature)? I know
that the mechanism for invocation could be varied somewhat.

The usual use case is that the "generic template" implements
some algorithm, often in a recursive form. You presented
sorting, summation+running totals for orders and some other
stuff; it could also be used for example for numeric integration.
Actually this shows that functional programming on the XSLT
level is already reality in XSLT 1.0 to some extend (with the
caveat that for functions returning function references,
the xx:node-set() extension function is necessary; is this

The interesting point is now: how could we profit from functional
programming elements on the XPath level? Your generic sort template
is probably a good candidate. Most of the generic solutions for
iterating over a node set are probably covered by other new standard
stuff, so they're not as convincing as they used to be.

For others: Unless i'm mistaken there is still no easy way to sort
order positions by price*quantity (or price*key('exchange-rate',currency))
in XSLT 2.0, so the generic sort template is still useful.   

> And to say that the "FP stuff" is not usable means not to understand what FP
> is.
It was meant in the sense that for many people "more compact" is
also "more usable". Imagine you could pass an expression as parameter
to your generic sort template without having to encapsulate it in a
template first.


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

Current Thread


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.
First Name
Last Name
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.