RE: [xsl] HOF in XPath/XSLT 2.1?

Subject: RE: [xsl] HOF in XPath/XSLT 2.1?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 13 Oct 2009 22:30:40 +0100
> I'm looking at implementation of XQuery 1.1 higher-order 
> functions, and specifically inline functions, in Saxon 9.2. 
> I'm wondering if that addition is strictly for XQuery, or if 
> it will be also present in XPath 2.1 (and therefore 
> indirectly, by extension, XSLT 2.1), and whether XSLT 2.1 
> will provide any similar facilities, such as local 
> <xsl:function> declarations, or perhaps even unnamed 
> <xsl:function> expressions?

The XSL WG has discussed this and is I think very likely to include
higher-order functions in XSLT 2.1 and XPath 2.1, but the exact details are
not yet decided (and indeed, the formal decision to go ahead is not yet
made).

When I looked at this I was initially inclined to think that unnamed/local
xsl:function declarations would be appropriate, but when I tried to work out
a few use cases, it wasn't clear that they added much. That's because local
functions are most commonly needed as an argument to a function call, which
is in XPath territory; and if the local function has to be bound to a
variable before it can be used, then you gain very little over defining a
global named function. There's a possibility that a local xsl:function could
be useful for returning a constructed function as the result of a function,
but I'm not convinced.

Incidentally, we're getting a bit ahead of ourselves here, in that the spec
of higher order functions in XQuery 1.1 has not yet been published by W3C.
John Snelson and I have both breached the usual protocol, he by publishing
the proposal that he put forward to the WG, and me by releasing an
implementation, before the WG has said anything in public.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

Current Thread