cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <jheini...@virbus.de>
Subject Woody: moded templates (Re: WoodyTransformer: radio buttons)
Date Tue, 11 Nov 2003 17:10:32 GMT
On 11.11.2003 15:15, Vadim Gritsenko wrote:

> BTW, is anybody against replacing <xsl:template 
> name="woody-field-common"/> with <xsl:template match="wi:*" 
> mode="common"> ? It's not possible to override in the including 
> stylesheet named templates, but you can override match="" templates.

Some time ago I also started to do this, but I lost these changes (did I 
do this only in build/webapp and made a buil clean afterwards? :-( ). 
The named templates are not the problem if you use <xsl:import> instead 
of <xsl:include>. The real problem are special cases.

<xsl:template match="wi:field">
   <xsl:call-template name="doSomething"/>
</xsl:template>

<xsl:template name="doSomething">
   <xsl:choose>
     <xsl:when test="case1">..</xsl:when>
     <xsl:when test="case2">..</xsl:when>
     <xsl:otherwise>..</xsl:otherwise>
   </xsl:choose>
</xsl:template>

while with modes:

<xsl:template match="wi:field">
   <xsl:apply-templates select="." mode="doSomething"/>
</xsl:template>

<xsl:template match="wi:field[case1]" mode="doSomething">
</xsl:template>

<xsl:template match="wi:field[case2]" mode="doSomething">
</xsl:template>

<xsl:template match="wi:field" mode="doSomething">
</xsl:template>

and now imagein importing this stylesheet in another one. While you have 
to rewrite the complete named template, with the moded stylesheet you 
can overload exactly one special case.

I volunteer doing this!

Joerg


Mime
View raw message