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

Re: ANN: How to Create XSLT Functions that Manipulate

Subject: Re: ANN: How to Create XSLT Functions that Manipulate Functions
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sat, 25 Sep 2010 12:03:22 -0700
Re:  ANN: How to Create XSLT Functions that Manipulate
Seems OK as an introduction, however:

1. The function map() is traditionally defined in almost all FP
languages to take as first argument a function that operates on a
*single item* of the sequence -- not on all items.

Therefore, either do not use the name "map" -- to avoid the confusion
with the esatblished meaning of map(), or re-define it:


    <xsl:function name="f:map" as="item()*">
      <xsl:param name="pFun" as="element()"/>
      <xsl:param name="pList1" as="item()*"/>

      <xsl:sequence select=
       "for $this in $pList1 return
          f:apply($pFun, $this)"
      />
    </xsl:function>


2. It is useful to define the function f:apply() --witha at least the
one-argument overload version:

  <xsl:function name="f:apply">
   <xsl:param name="pFunc" as="element()"/>
   <xsl:param name="arg1"/>

    <xsl:apply-templates select="$pFunc" mode="f:FXSL">
      <xsl:with-param name="arg1" select="$arg1"/>
    </xsl:apply-templates>
  </xsl:function>


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



On Sat, Sep 25, 2010 at 11:37 AM, Costello, Roger L. <costello@xxxxxxxxx>
wrote:
>
> Hi Folks,
>
> I wrote a short article that shows, step by step, how to create XSLT
functions that manipulate functions (i.e., how to create higher-order
functions):
>
>
> Introduction
>
> A powerful programming technique is to create functions that can accept
functions as arguments or return functions as values. Functions that
manipulate functions are called higher-order functions. This article shows how
to implement higher-order functions using XSLT 2.0.
>
> More ...
>
>
http://www.xfront.com/higher-order-functions-in-XSLT/How-to-Create-XSLT-Funct
ions-that-Manipulate-Functions.pdf
>
> /Roger

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.