This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Call Template with variable name


"Yash" <yashdeep at ekartha dot com> wrote:

> Why is there a syntax problem with the following:
> <xsl:call-template name="$abc"/>
> i.e. is there a way to call a template whose name is specified with the
> variable 'abc'?

No -- not in XSLT 1.0 and probably not in XSLT 2.0 judging from the working draft
I've seen.

However, almost the same effect can be accomplished using the mechanism of generic
templates, as described in:

http://lists.fourthought.com/pipermail/exslt/2001-May/000169.html

A number of generic templates can be downloaded from:

http://www.topxml.com/downloads/default.asp?id=v2001611171627

I believe that in a good XPath language there must be higher order functions, this
will be so if the language supports a "function reference" type. The base for such
design decision is already contained in the "XPath 2.0 Data Model" -- the reference
node type, and in the XSLT 2.0 Working Draft -- the stylesheet functions (functions
written in XSLT).

The next natural step is by combining the two to have a reference node to a
xsl:function, and to allow such a reference to be de-referenced and used for the
evaluation of the dereferenced function. 

Then it will be possible to have an XPath expression of the following kind:
 
$funcRef(argument*) 

where the function pointed to by $funcRef, will be specified at transformation (run)
time and could in general be different on every different evaluation of this XPath
expression.

or maybe

<xsl:call-template name="$template-reference"/>

The usefulness of higher order functions cannot be overestimated. This significantly
increases the power and expressiveness of a language. Using functions as arguments
serves as glue to dynamically combine existing functions in unanticipated ways to
generate new functions, which greatly increases the expressive power, code
reusability and function interoperability, and ultimately, the programmer's
productivity.

Hope this helped.

Cheers,
Dimitre Novatchev.

__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]