xsl-list
[Top] [All Lists]

Fwd: multiple/default template modes

2004-06-06 23:21:03
Hi All,

I'm not sure if this is a FAQ question, but i've looked and I can't find exactly what I'm trying to do.

I have several xsl templates which may all apply to a certain xml node. our front-end team uses apply-templates calls to pull out info from the xml file they want. For example,

<h1> <xsl:apply-templates select="title" mode="normal"/></h1>

if they want an editable version of the title (<input type=text ..../>)
they use:

<h1> <xsl:apply-templates select="title" mode="editable"/></h1>

Point is, I would like to be able to provide a default mode for different contexts. Therefore, a call like
<h1> <xsl:apply-templates select="title" /></h1>  <!-- no mode -->
would use a default template. Currently, this is implemented by duplicating the template with no mode. ie- <xsl:template match="title" mode="editable">... xsl here ... </xsl:template> <xsl:template match="title" mode="normal">... xsl here ... </xsl:template> <xsl:template match="title">... xsl here ... </xsl:template> <!-- this is a duplicate of either editable or normal depending on context -->

Obviously, this increase the size of our xsl files and is just plain ugly. Is it possible to have a xsl:template match more than 1 mode?
The pseudocode of what we want is:
<xsl:template match="title" mode="editable | normal">... xsl here ... </xsl:template>
or more like
<xsl:template match="title" mode="normal | -no mode specified-">... xsl here ... </xsl:template>

I have a feeling this isn't possible from reading the faq's but i thought i'd throw it out.

Thanks for any help. In fact, thanks for all the help this list has provided me over the past several months. As a newcomer to xsl, it has been invaluable to my growth to be in touch with so many intelligent, helpful xsl developers.

Thanks again,
Jonathan




<Prev in Thread] Current Thread [Next in Thread>