xsl-list
[Top] [All Lists]

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

2003-09-26 12:19:55
[ 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