Subject: Re: [xsl] calling template with name passed in a variable From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 21 Dec 2009 12:10:55 -0500 |
Let's say someone needs to handle a new type some day. He asks me how to do this and then I would like to avoid having to explain how code that is concerned with matching and applying his new template works. He doesn't have to know this, he probably doesn't even care.
I wish I could just say add your template anywhere and name it the same as the type it handles. Wouldn't that be cleaner?
This example is not the best one to illustrate the above situation because matching in this case is really simple but we could imagine much more complex matching logic involving many templates not just one.
As my output is a source code I prefer fatal errors to producing invalid output.
Note that the XSLT language is designed so that the processor knows all possible call requests and all possible callable templates at compile time. It can do optimization and rewriting based on this knowledge, which cannot be done if the call were dynamically resolved.
Ok.
In this case it looks like I would have to first generate new xsl based on the original xsl and then execute this new one.
For example having this definition in the original xsl (possibly added my someone else)
<xsl:template name="MyNewType1"> code for THIS type </xsl:template>
I would produce the following definition
<xsl:template match="xsd:element[@type='MyNewType1']"> <xsl:call-template name="MyNewType1/> </xsl:template>
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] calling template with nam, Michael Kay | Thread | [xsl] Number of elements with a giv, Faehndrich Philippe |
[xsl] regrouping split elements, James Cummings | Date | Re: [xsl] regrouping split elements, Martin Honnen |
Month |