Honza,
in several messages you have written, I can see similar desires. You are
always trying somethink like "dynamic" xslt processing. It is generraly
bad idea, I guess. Original intensions of XSLT are based on need of XML
"transformation" more or less in the "plain" meaning of this word.
Of course, it is the major limitation, but it makes sense. Processors
may be as simple as possible and optimized for well-defined task.
Using data "by reference" (in xsl:include xsl:value-of,
xsl:call-template etc.) is not possible (cruel world:) and designing
templates in this way is concept misunderstanding, I guess.
There are two general approaches bypassing this limitation.
Unfortunatelly no one is perfect and both require some preprocessing,
which may be significant drawback.
1. preprocessing of XML data
Yes, it would be very fine to have XML data in the format matching
desired output :)
2. Decide what you are going to do before you run the processor and feed
it with appropriate data, including stylesheets.
we prefer the second solution. According your example, out template
would have always the same name (e.g. 'inner') and is included like
<xsl:include href="arg:/inner"/>. In this case you have to decide which
template you need pass into sablotron before running it.
Do not use XSLT for programming, you'll always meet some significant
limitation.
Have a nice day
Pavel
Honza Pazdziora wrote:
> On Wed, Feb 14, 2001 at 01:48:42PM -0500, James Eberhardt wrote:
>
>> As far as I know, the name attribute value can not be a variable (for
>> apply-templates or call-template). This is according to the XSL spec.
>
>
> Thanks, appreciate the confirmation.
>
>
>> If you have a limited number of templates you could call, you should use a
>> <xsl:choose> statement. It's a bit more verbose, but it will get the job
>> done.
>
>
> Yes, it's working rather nicely, I'm only affraid what will happen
> when I hit hundreds of various call-templates. To explain, where I'm
> heading: I'm trying to stack stylesheets, and would like to pass
> names of templates as parameters to lower level templates, something
> like
>
> higher level XSLT:
>
> <!-- list of invoices is to be displayed as dotted list -->
> <xsl:template match="invoice_list">
> <xsl:call-template name="dotted_list">
> <xsl:with-param name="what">invoice</xsl:with-param>
> </xsl:call-template>
> </xsl:template>
>
> <!-- and here's how invoice looks like -->
> <xsl:template match="invoice">
> some processing of invoice data
> </xsl:template>
>
> lower level XSLT, included from the above:
>
> <!-- dotted list just makes the dots and for the rest
> (the content) calls the $what template -->
> <xsl:template name="dotted_list">
> <xsl:param name="what"/>
> <UL>
> <xsl:for-each select="row">
> <LI>
> <xsl:choose>
> <xsl:when test="$what='invoice'">
> <xsl:call-template name="invoice"/>
> </xsl:when>
> <xsl:when test="$what='person'">
> <xsl:call-template name="person"/>
> </xsl:when>
> <xsl:when test="$what='address'">
> <xsl:call-template name="address"/>
> </xsl:when>
> </xsl:choose>
> </LI>
> </xsl:for-each>
> </UL>
> </xsl:template>
>
> and when I decide the lower level presentation should be changed to
> something else than <UL><LI /></UL>, I'd feed Sablotron different file
> with different definition of "dotted_list".
>
> The <xsl:choose> is probably the best I can get.
>
> Yours,
--
Pavel Hlavnicka
Ginger Alliance Ltd.
Prague; Czech Republic