[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

conditional XSL to XSL

Subject: conditional XSL to XSL
From: Jeff Lansing <jeff@xxxxxxxx>
Date: Thu, 06 Apr 2000 12:29:25 -0700
x 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() &gt; 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=&#39;title&#39;]'
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.