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

RE: Dynamically calling a template

Subject: RE: Dynamically calling a template
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 6 Feb 2007 22:43:30 -0000
RE:  Dynamically calling a template
> I was striving for the hypothetical (but illegal) solution of 
> <xsl:call-template name="$variable" /> (names cannot be variable).

Three suggestions:

(a) Have multiple task-oriented stylesheets each of which imports a
stylesheet containing common components. Start the transformation by
invoking a task-oriented stylesheet. The common code can call back using
<xsl:call-template name="name" /> provided that each task-oriented
stylesheet provides an implementation of "name": it doesn't have to be the
same code in each one.

(b) Use FXSL. This provides genuine higher-order programming, allowing you
to pass functions around as parameters, so you can call a function that was
supplied to you by your caller.

(c) Use the central idea behind FXSL, without actually using FXSL itself (it
has become quite a powerful monster). The central idea is to use an element
as a surrogate for a template. Instead of doing <xsl:call-template
name="$variable"/>, you do <xsl:apply-templates name="$variable"/>, where
$variable holds an element that will be matched by the template you want to
invoke (so there's a one-to-one correspondence between these elements and
their corresponding templates).


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-2011 All Rights Reserved.