[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: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 19 Jul 2007 23:27:04 +0100
RE:  [xslt 2.0] Local functions
> 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.