xsl-list
[Top] [All Lists]

Re: Moded Templates

2003-01-06 13:16:14
Hi Will,

After looking at the spec ( http://www.w3.org/TR/xslt#modes ) and
searching the "biglist", I could not find the answer to my question.
Besides a "qualified name" what other values can be used when
specifying a mode, is there a way to define a template using an 'or'
(|) or a wildcard (*),

No. The only legal values for the mode attribute in XSLT 1.0 is a
qualified name. One way around that is to have default templates for
the modes that you want default behaviour for. Something like:

<xsl:template match="*" mode="A">
  <xsl:apply-templates select="." mode="B" />
</xsl:template>
<xsl:template match="*" mode="B">
  <xsl:apply-templates select="." mode="C" />
</xsl:template>
<xsl:template match="A" mode="C">
  ...
</xsl:template>
<xsl:template match="B" mode="C">
  ...
</xsl:template>

This way whenever templates are applied to A or B elements in mode A
or B, the template for mode C will be used.

In XSLT 2.0, the mode attribute on xsl:template can take a list of
qualified names, specified by spaces. So in XSLT 2.0 you will be able
to do:

<xsl:template match="A" mode="A B C">
  ...
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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