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

RE: Re: <xsl:choose> or variable syntax incorrect?

Subject: RE: Re: <xsl:choose> or variable syntax incorrect?
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Fri, 26 Sep 2003 15:19:55 -0400
RE:  Re: <xsl:choose>  or variable syntax incorrect?
[ Kathy Burke]

> First, I truly appreciate your responding. But please tell me 
> how I did not
> "explain the problem I've solving"? I honestly thought I did!
> 

Kathy, stop making this so hard!  You are trying to transform some input
into some output.  You have not really told us accurately and concisely
what the output should be, and you have not told us what you get when
you say that "it doesn't work".  For example, the bgcolor attribute
belongs on the td, not the tr. That is an HTML problem.  You need to get
your HTML right, then think about the transform. One of your posts
contained non-wellformed xml in a template.  That is an xml problem.
You need to say how you know it isn't working, like the error message or
the actual results.

Think simple.  Based on what you have said - and I know that ultimately
you want to do something more complex - here is a simple solution that
works in the sense that it creates either a red or a blue background
cell filled with the station name, depending on the presence of
boards/board elements.  It ought to be self-explanatory.

<xsl:template match='data'>
<html>
   <table>
      <xsl:apply-templates select='station'/>
   </table>
</html>
</xsl:template>

<xsl:template match="station">
   <xsl:variable name='rowcolor'>
      <xsl:choose>
         <xsl:when test='boards/board'>red</xsl:when>
         <xsl:otherwise>navy</xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
   <tr>
      <td bgcolor='{$rowcolor}'><xsl:value-of select='@name'/></td>
   </tr>
</xsl:template>

See?

Cheers,

Tom P

 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.