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,

-- 
------------------------------------------------------------------------
 Honza Pazdziora | [EMAIL PROTECTED] | http://www.fi.muni.cz/~adelton/
 .project: Perl, mod_perl, DBI, Oracle, auth. WWW servers, XML/XSL, ...
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------

Reply via email to