xsl-list
[Top] [All Lists]

Setting table row color with xsl:choose and xsl:variable

2005-10-31 10:03:29
I would like to set the color of a table row based on the value in one of the 
data fields.  The long way, which works, is to repeat the entire <tr><td> 
pattern for each value.  Isn't it possible using some variation of the 
following code to just read the field's value, assign a CSS class to the row 
and continue with template matching for the <td>'s?



<xsl:template match="Event">         

<xsl:choose>

  <xsl:when test="Required = 'yes'">

    <xsl:variable name="rowClass">calendarltred</xsl:variable>

  </xsl:when>

  <xsl:when test="Special = 'meeting'">

    <xsl:variable name="rowClass">calendaryellow</xsl:variable>

  </xsl:when>

  <xsl:when test="Special = 'candysale'">

    <xsl:variable name="rowClass">calendarltblue</xsl:variable>

  </xsl:when>

  <xsl:otherwise>

    <xsl:variable name="rowClass">default</xsl:variable>

  </xsl:otherwise>

</xsl:choose>

    <tr class="{$rowClass}">

      <td>

        <xsl:apply-templates select="DayOfWeek" />

        <xsl:apply-templates select="MonthName" />

        <xsl:apply-templates select="DayNum" />

      </td>

...



Thanks, Alan

 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>