[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: [xslt 2.0] Local functions

Subject: Re: [xslt 2.0] Local functions
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 19 Jul 2007 16:52:00 -0700
Re:  [xslt 2.0] Local functions
Having higher order functions (as provided by FXSL) eliminates the
need for local functions. One can even create functions dynamically
(by composition or by currying).


As the need for local functions has never been expressed in this list for a period of 7 years, it is logical to conclude that this topic has been created in a somewhat artificial way from a not completely XSLT standpoint of view.

It is not surprizing at all that people who are influenced by
imperative programming did sometimes ago express the need for
assignable variables. Other people now need local functions.

While it may be convenient to throw phrases like "programming in the
large", "UML", etc., it would be really interesting to see a
convincing use case for these in relation to XSLT.

--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play



On 7/19/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> 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?

Generally speaking, I think functions local to a function (or template) are
not an especially good idea. I used them in Pascal, and the net result was
some very large functions containing lots of functions which in turn
contained their own functions, and the code became very hard to read. It was
very hard to tell what was in scope at any given time. Anonymous functions
would be a different question, if we had support for higher-order functions
in the language.

Functions local to a stylesheet module - essentially private objects of any
kind - feels like a stronger candidate.

And I would love to see some way of organizing all the template rules in a
mode into some self-contained structure that keeps them tidily in one place.

For large XSLT projects (20K lines and up) the fact that everything has
global scope is certainly problematic. Disciplined use of modules and
namespaces can help, but there's still a tendency to build a rather
ramshackle structure of imports and overrides to handle different special
cases. I think modularity through pipelining is the most important weapon to
counteract this: handle special cases and variants by inserting custom
transformations into the processing pipeline rather than through overrides.
Break transformations into a sequence of simpler transformations, and
document the input and output of each through schemas. Metastylesheets
(stylesheets that generate stylesheets) can also play an important role.

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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.