Re: [xsl] dynamic template invocation

Subject: Re: [xsl] dynamic template invocation
From: ac <ac@xxxxxxxxxxxxx>
Date: Tue, 08 Sep 2009 06:58:06 -0400

Metaprogramming is fine but apart from your proposition being non standard, it seems a bit like using a bulldozer to pick-up a dime, in this case.

HOR are great and I am looking forward to their standardization and wide availability. MAPing functions is especially interesting.

I like Haskell and even F#, but they are not XSLT. Templates are also a bit different from functions.

Setting the mode seems like a very simple and natural extension of the existing paradigm.

Thank you for your interesting suggestions.


XSLT itself is good base for metaprogramming, XSLT even now can
perform self analyzing & self modification according to input xml,
params or lookup at document xsd - see

On Tue, Sep 8, 2009 at 7:30 AM, Dimitre Novatchev<dnovatchev@xxxxxxxxx> wrote:
Dear ac,

Higher Order Functions (HOF) are powerful enough for the solution of
any problem.

One needs just a little bit of practice in functional programming
(using a suitable language as Haskell) in order to gain the necessary

HOF's are in the process of being specified by the corresponding W3 WG
 as a standard feature in XQuery, XPath and XSLT.

Dimitre Novatchev
Truly great madness cannot be achieved without significant intelligence.
To invent, you need a good imagination and a pile of junk
Never fight an inanimate object
You've achieved success in your field when you don't know whether what
you're doing is work or play
I enjoy the massacre of ads. This sentence will slaughter ads without
a messy bloodbath.

On Mon, Sep 7, 2009 at 7:15 PM, ac<ac@xxxxxxxxxxxxx> wrote:
Hi Dimitre,

It is a nice solution with a clever and elegant <xsl:variable
name="templates" select="document('')/xsl:template" />

One can always pre-include the stylesheets into an integrated one, in a
"pre-pass" to get access to the included/imported templates, which may not
be so trivial especially for imported stylesheets.

The context also needs to be parametrized, but mostly it does not seem to
provide dynamic template mode selection which brings back the requirement to
use call-template on templates that typically have both name and match
attributes, when running various process modes on the same source nodes (eg.
payroll trial, log, post, archive, purge), either with as xsl:choose or a
There are different ways to get around the problem but none of them as
elegant as <xsl:apply-templates mode="$mode"/> or variations thereof.

I have encountered quite a few other "similar" use cases, as when processing
music, for example, with analysis, scoring, loging, debugging, performing
modes, and for image and video processing, as well as for animation, case
management, process modeling, ...

I was suggesting and wandering if others feel that it may be a natural and
useful improvement for the standard.

What do you think?

Thank you.


Search about FXSL. This feature is there (in  a way that is allowed by
the XSLT 1.0 language) since 2002.


Current Thread