[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] New XSLT 3.0 Working Draft


Subject: Re: [xsl] New XSLT 3.0 Working Draft
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 11 Jul 2012 11:31:29 +0100

On 11/07/2012 10:12, Ihe Onwuka wrote:

Sorry I meant partial application and you must forgive my syntax because I have no idea what it should be but in

<xsl:variable name="f" as="function(xs:integer, xs:integer) as
xs:integer" select="1"/>

if  the function in the above variable is a function that adds two
integers then $f(3) returns 4 (i.e $f becomes a function that
increments it's argument by 1).



If f is a function that takes two arguments and adds them, so that f(2,3) is 5, then f(?,1) is a function that takes a single argument and adds one to it.


You might write this as

<xsl:variable name="fAdd"
select="function($x as xs:integer, $y as xs:integer) as xs:integer {$x + $y}"/>
<xsl:variable name="fIncrement" select="$fAdd(?, 1)"/>
<xsl:value-of select="$fIncrement(4)"/>


which would output "5".

Michael Kay
Saxonica


Current Thread