RE: [xsl] Problem With Different Colors for Alternate Rows

Subject: RE: [xsl] Problem With Different Colors for Alternate Rows
From: Adam Griffin <agriffin@xxxxxxxxxxxx>
Date: Thu, 31 Oct 2002 11:57:05 -0500
Small FYI
If I remember right, CSS2 specs call for the ability to alternate row colors
on a table (YEA!).

table:row[%3] {color:red}

would make every 3rd row red of a table. 

Unfortunately, support is poor at the moment. I know IE and NS don't support
yet (BOO!). as often as this is needed i would hope the browser makers would
be making this a priority.  Maybe we won't need the work-arounds in the


-----Original Message-----
From: Schwartz, Rechell R, ALCAS [mailto:rrschwartz@xxxxxxx]
Sent: Thursday, October 31, 2002 10:53 AM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Problem With Different Colors for Alternate Rows


I am having difficulty programming a stylesheet that is supposed to return
the result set as a list of HTML rows in alternating colors.All of the
examples that I have seen address how to do this if every data row is is
derived from the same type of XML tag. But in my example, each row may come
from a completely different section of the XML. Following is a sample XML
similar to the one that I am using. Also, another constraint is if any row
is missing, it is inhibited, and the alternating color rule must still be
preserved. I have tried numerous ways of passing parameters, but have been
unable to modify the the row count after a match was found ofr each item.
Any help would be GREATLY appreciated.

Sample XML:

Chocolate Truffles

Sample XSLT Stylesheet:
<?xml version="1.0" ?>
<xsl:stylesheet version='1.0'
xmlns:xsl='' >
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="Food_List/Main_Food_List/Main_Course"/>
<xsl:apply-templates select="Food_List/Side_Dish"/>
<xsl:apply-templates select="Food_List/Desert/Fancy_Desert"/>

<xsl:template match="Main_Course">
<TR><TD>Main Course:</TD><TD xsl:value-of select="."/></TD></TR>

<xsl:template match="Side_Dish">
<TR><TD>Side Dish:</TD><TD xsl:value-of select="."/></TD></TR>

<xsl:template match="Fancy_Desert">
<TR><TD>Desert:</TD><TD xsl:value-of select="."/></TD></TR>


Required HTML Output
<TR><TD colspan="2">MENU</TD></TR>
<TR><TD class="oddRowStyle">Main Dish:</TD><TD
<TR><TD class="evenRowStyle">Side Dish:</TD><TD
<TR><TD class="oddRowStyle">Desert:</TD><TD class="oddRowStyle">Chocolate

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread