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: "Michael J. Hudson" <mhudson at blueprint-technologies dot com>
- Date: Mon, 10 Apr 2000 14:49:18 -0400
- Organization: Blueprint Technologies, Inc.
- References: <200004100512.BAA13109@mulberrytech.com>
- Reply-To: xsl-list at mulberrytech dot com
Jeff Lansing wrote:
>
> 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>
Something to add to what you wrote above... you could actually get rid
of the need
for the variable match-value altogether by using the 'attribute'
command, which actually
cleans up the code a bit as well... thus:
<x:template match="el">
<xsl:template>
<x:attribute name="match">
<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:attribute>
<xsl:value-of select="foo"/>
<!--whole bunch of other complicated stuff-->
</xsl:template>
</x:template>
Now, I know... it was already figured out that the use of the variable
within the match
attribute wasn't the problem in the first place... but, I just thought
that this solution
might give some ideas of other ways that you could do this as well.
-------------------------------------
Michael J. Hudson
Software/Framework Engineer
mhudson@blueprinttech.com
cell-phone: 703.932.6412
voice-mail: 703.827.0638 ext. 4786
fax: 703.734.0987
Blueprint Technologies
"The E-Solution Architect"
http://www.blueprinttech.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list