Joerg Heinicke wrote:
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!
+1, I was also thinking to something along these lines, with some additional modes such as "before-widget" and "after-widget" that would allow, by overaloading in the including stylesheet, to redefine how and where the "*" and validation messages appear relative to a widget.
We can however keep the named template as a convenience to ease writing the moded templates (which would be just a <xsl:call-template> in their standard form).
This should be done using
<xsl:apply-imports/>
Joerg
