RE: [xsl] [xslt 2.0] Local functions

Subject: RE: [xsl] [xslt 2.0] Local functions
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 19 Jul 2007 08:59:40 +0100
> To that end, I'm working on a translator from a language with 
> a higher level syntax (ie. either reduced XML or no XML at 
> all) into XSLT 2.0.

Before inventing your own, take a look at Ed Willink's NiceXSL at

http://nicexsl.sourceforge.net/ 

An earlier attempt was Paul Tchistopolskii's XSLScript, which was at

http://www.pault.com/XSLScript/pault/prod/XSLScript

but that seems to be off the air.

Apart from technical details of the syntax chosen, the more interesting
question to ask is: why didn't these attempts catch on, and what's going to
be different about yours?

I think the main factor that inhibits take-up of such tools is that you
can't really get by without learning the underlying language - you need this
knowledge firstly to communicate with others about the language (e.g to read
books and participate in forums), and secondly to understand error messages.
So you're asking people to learn two languages instead of one. That's a high
entry cost for the sake of saving a few keystrokes. (And with XSLT 2.0, the
saving in keystrokes is a lot less because the worst verbosities, like the
5-line function call, have disappeared.)

> 
> It occurs to me that it is possible to simulate local 
> functions in XSLT 2.0 (which effectively could be declared 
> inside xsl:template and xsl:function elements and the local 
> function elements themselves).
> 
> Now, given that it can be done, question is :-
> 
> Would it be desirable if XSLT 2.0 were to support local functions?

There's any number of things that could be done, for example declaring
functions as private or public, prohibiting override except by something
with a compatible signature, etc etc. But if you want something to catch on
in the community without it being in the W3C language spec, you need (a) a
very compelling benefit, and (b) strong compatibility so people can use the
feature without getting locked in. But don't let me discourage you from
experimenting.

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

Current Thread