Subject: RE: [xsl] [xslt 2.0] Local functions From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 19 Jul 2007 23:27:04 +0100 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [xslt 2.0] Local function, Andrew Welch | Thread | Re: [xsl] [xslt 2.0] Local function, Dimitre Novatchev |
Re: [xsl] [OT] [xslt 2.0] Differenc, Wendell Piez | Date | Re: [xsl] [xslt 2.0] Local function, Dimitre Novatchev |
Month |