|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] conditional XSL to XSL
Here is some minimal test input:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<el attr="x"/>
<el attr="y"/>
</doc>
Here is my stylesheet:
<x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"
xmlns:xsl="anything" version="1.0">
<x:output method="xml" indent="yes"/>
<x:namespace-alias stylesheet-prefix="xsl" result-prefix="x"/>
<x:template match="/">
<xsl:stylesheet version="1.0">
<x:apply-templates/>
</xsl:stylesheet>
</x:template>
<x:template match="el">
<x:if test="@attr = 'x'">
<xsl:template match="tr[@class='title']">
<xsl:value-of select="foo"/>
<!--whole bunch of other complicated stuff-->
</xsl:template>
</x:if>
<x:if test="not(@attr = 'x')">
<xsl:template match="tr[@class='title' and position() > 1]">
<xsl:value-of select="foo"/>
<!--whole bunch of other complicated stuff-->
</xsl:template>
</x:if>
</x:template>
</x:stylesheet>
Here is my problem (very real, even if the above seems contrived):
I would like to eliminate duplication in the above stylesheet by
conditionally
setting a variable, call it 'match-value', and using it in the
"xsl:template" thingy,
which I think would work like this:
<xsl:template match="{$match-value}">
<xsl:value-of select="foo"/>
<!--whole bunch of other complicated stuff-->
</xsl:template>
So if that's right I would need to set the variable something like this:
<x:variable name="match-value">
<x:if test="@attr = 'x'">
<x:value-of select="'value1'"/>
</x:if>
<x:if test="not(@attr = 'x')">
<x:value-of select="'value2'"/>
</x:if>
</x:variable>
But I'm just not being able to get the right stuff into 'value1' (or
'value2');
I've tried things like:
'tr[@class="title"]'
and
'tr[@class='title']'
but I'm not getting any of saxon/xt/xalan to accept any thing like
these.
Jeff
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








