This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Functional programming in XSLT (revised)


> > 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]