This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Generic Templates (Was: Re: nested templates?)
- To: mail at jenitennison dot com
- Subject: [xsl] Generic Templates (Was: Re: nested templates?)
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- Date: Fri, 18 May 2001 06:36:32 -0700 (PDT)
- Cc: xsl-list at lists dot mulberrytech dot com
- Reply-To: xsl-list at lists dot mulberrytech dot com
Jeni Tennison wrote:
> > That is a design flaw. I should be able to do this:
> >
> > <xsl:call-template name="{input/type}" />
>
> As I pointed out, you probably want to use matching templates rather
> than named ones to achieve this effect. I guess the reasoning behind
> not allowing you to call templates where you make up the names on the
> fly is that if you make up a name for a template that doesn't exist,
> the stylesheet will fail. If you know all the names in advance, then
> you can use xsl:choose to choose between them.
As I pointed out in an earlier message
(http://sources.redhat.com/ml/xsl-list/2001-05/msg00276.html),
you don't need to know either the template names in advance, or use xsl:choose to
choose between them. There is a technique to dynamically invoke a template that is
unknown and not-yet-written, using a unique match pattern.
Thus, we can have many useful generic templates -- a single generic template that
implements both the min() and max() functions, templates for binary search, generic
sort, etc... These templates are written without knowing in advance what the
"greater-than" or "less-than" or whatever a necessary relation/action is and they
allow the caller to specify dynamically through a parameter the template that
implements this relation/action.
I am attempting to submit some templates (among them 5 generic ) to the EXSLT group
and ***hope*** to succeed soon, because despite the kind help I got from Jim Fuller,
writing the necessary documentation for submitting EXSLT functions is much more
difficult than implementing the functions themselves.
Dimitre Novatchev.
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list