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

RE: Newbie question:

Subject: RE: Newbie question:
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Tue, 21 Mar 2000 09:58:12 -0000
RE: Newbie question:
> So I wish to do something like this, but it does not work...
> 
> <xsl:choose>
> <xsl:when test='@ODD="O"'><table bgcolor="#000066"></td></xsl:when>
> <xsl:when test='@ODD="N"'><table bgcolor="3366CC"></td></xsl:when>
> </xsl:choose>
> 
(a) You can't write half a node to the result tree, and (b) the stylesheet
has to be well-formed XML, which are two different ways of saying that you
can't do this, because the <table> start tag has to be matched by a </table>
end tag (Heaven only knows what the </td> is doing there).

So even though it seems as if:

 <choose>
   <when x><table aa></when>
   <when otherwise><table bb></when>
   ...  
 </choose>
 </table>

wll always generate a matching closing tag, this isn't the way XSLT works,
because it doesn't write tags, it writes nodes.

The simplest solution here is to use a variable:

  <xsl:variable name="color">
  <xsl:choose>
  <xsl:when test='@ODD="O"'>#000066</xsl:when>
  <xsl:when test='@ODD="N"'>#3366CC</xsl:when>
  </xsl:choose>
  </xsl:variable>
  <table bgcolor="{$color}">
     ...
  </table>

Mike Kay


 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.