This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: conditional XSL to XSL
- To: xsl-list at mulberrytech dot com
- Subject: Re: conditional XSL to XSL
- From: Jeff Lansing <jeff at dtai dot com>
- Date: Fri, 07 Apr 2000 17:56:43 -0700
- References: <md5:257AD1F638DB211073F746282AB48371>
- Reply-To: xsl-list at mulberrytech dot com
Jeff Lansing wrote:
> Michael Kay wrote:
>
> > > <xsl:template match="{$match-value}">
> >
> > The match attribute of xsl:template is not one of the (small number of)
> > attributes that are interpreted as attribute value templates.
> >
> <deleted stuff/>
> the only problem would seem to be getting the right stuff
> into these 'value1' and 'value2' strings.
>
Following a suggestion of David Carlisle, regarding another poster's
question, to "drop out of xpath, to xslt", I can now solve this problem with:
<x:template match="el">
<x:variable name="match-value">
<x:if test="@attr = 'x'">tr[@class='title']</x:if>
<x:if test="not(@attr = 'x')">tr[@class='title' and position() > 1]</x:if>
</x:variable>
<xsl:template match="{$match-value}">
<xsl:value-of select="foo"/>
<!--whole bunch of other complicated stuff-->
</xsl:template>
</x:template>
which yields these two templates in any of xalan,
xt, or saxon (oracle differs trivially in having ' for '):
<xsl:template match="tr[@class='title']">
<xsl:value-of select="foo"/>
</xsl:template>
<xsl:template match="tr[@class='title' and position() > 1]">
<xsl:value-of select="foo"/>
</xsl:template>
as desired.
Why? What about the note in 7.6.2, which seems to forbid
this in two different ways? Perhaps in this context of aliased
named spaces <xsl:template ...> is not really a named XSLT
object, and the value of its match attribute isn't really an
expression or pattern.
Jeff
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list