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

Subject: [xsl] RE: Problem With Different Colors for Alternate Rows
From: "Schwartz, Rechell R, ALCAS" <rrschwartz@xxxxxxx>
Date: Tue, 5 Nov 2002 08:46:19 -0500
All,

Since I didn't receive any ideas on workarounds for this, I'll assume that what I'm trying to do is not technically feasible. I was wondering if anyone can give me input about a possible workaround. I was wondering if I can output the HTML as an XML file, and then apply a second XSLT stylesheet on the HTML file that would loop through each row of the table and make alternativing rows different colors. Any ideas on how each of the two stylesheets should look like would be appreciated.

Rechell

>  -----Original Message-----
> From: 	Schwartz, Rechell R, ALCAS  
> Sent:	Thursday, October 31, 2002 10:53 AM
> To:	'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:	Problem With Different Colors for Alternate Rows
> 
> All,
> 
> 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:
> 
> <Food_List>
> <Main_Food_List>
> <Main_Course>
> Chicken
> </Main_Course>
> </Main_Food_List>
> <Side_Dish>
> Potatoes
> </Side_Dish>
> <Desert>
> <Fancy_Desert>
> Chocolate Truffles
> </Fancy_Desert>
> </Desert>
> </Food_List>
> 
> Sample XSLT Stylesheet:
> <?xml version="1.0" ?>
> <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
> <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>
> 
> <xsl:template match="Side_Dish">
> <TR><TD>Side Dish:</TD><TD xsl:value-of select="."/></TD></TR>
> </xsl:template>
> 
> <xsl:template match="Fancy_Desert">
> <TR><TD>Desert:</TD><TD xsl:value-of select="."/></TD></TR>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> 
> Required HTML Output
> <TABLE>
> <TR><TD colspan="2">MENU</TD></TR>
> <TR><TD class="oddRowStyle">Main Dish:</TD><TD class="oddRowStyle">Chicken</TD></TR>
> <TR><TD class="evenRowStyle">Side Dish:</TD><TD class="oddRowStyle">Potatoes</TD></TR>
> <TR><TD class="oddRowStyle">Desert:</TD><TD class="oddRowStyle">Chocolate Truffles</TR>
> </TABLE>
> 
> 
> 
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread