This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Functional programming in XSLT (revised)
- To: "'Jeni Tennison'" <mail at jenitennison dot com>
- Subject: RE: [xsl] Functional programming in XSLT (revised)
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Fri, 16 Mar 2001 16:59:39 -0000
- Cc: <xsl-list at lists dot mulberrytech dot com>, "'Alexey Gokhberg'" <alexei at bluewin dot ch>
- Reply-To: xsl-list at lists dot mulberrytech dot com
> > Having said that, I made saxon:function available at the top-level
> > only, because I didn't want to spend the rest of my life explaining
> > the concept of local functions, and juistifying why they should have
> > access to local variables declared outside the function body.
>
> Would you mind doing it just once? I hadn't really considered the
> possibility of local exsl:function before, and would like to
> understand what its implications would be if we were to introduce it.
Consider the knight's tour and the code on page 622 of XSLT Prog Ref.
A local function here
f($a, $b, $diff)
would allow this to be written as
<xsl:if test="f(1, 0, -17)">
...
</xsl:if>
<xsl:if test="f(1, 7, -15)">
...
</xslif>
etc, saving a lot of repetitive coding, and meaning that only one place has
to change rather than 8 when the logic changes.
A global function here is little use, because it doesn't have access to the
local variables.
Mike Kay
Software AG
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list