Re: [xsl] two column table with alternating row colors using xsl xml and css

Subject: Re: [xsl] two column table with alternating row colors using xsl xml and css
From: nicholse@xxxxxxxxxxxxxxxx
Date: Thu, 7 Aug 2003 07:29:45 -0700 (PDT)
> Hi.
>
> try this:

snip
>         <style>
>          <!-- this is just an example, you can change this to whatever you
> like -->
>          .r0 { background-color: silver; color: black; }
>          .r1 { color: gray; }
>         </style>

snip
>     <tr class="r{position() mod 2}">
>       <td class="r{position() mod 2}">

Yes! this works well.

Also, maybe hard to understand/explain. I want two colums. In both columns
are companies starting col 1 top left to bottom right col 2 listed in
alpebetical order. I do not understand why this would not work. Processor
complains about me trying to put the </tr><tr> between two <td>'s of an
even and odd.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fmp="http://www.filemaker.com/fmpdsoresult";
exclude-result-prefixes="fmp">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="fmp:FMPDSORESULT">
<HTML>
<HEAD>
<TITLE/>
<STYLE>
<!-- this is just an example, you can change this to whatever you like -->
.r0 { background-color: silver; color: black; }
.r1 { color: gray; }
</STYLE>
</HEAD>
<BODY>
<TABLE>
<TR>
<xsl:apply-templates select="fmp:ROW"/>
</TR>
</TABLE>
</xsl:template>
<xsl:template match="fmp:ROW">
<xsl:for-each select="fmp:ROW">
<xsl:sort select="fmp:Co" />
<TD class="r{position() mod 2}">
<xsl:value-of select="fmp:Co"/>
</TD>
<xsl:if test="parent::node()[(position() mod 2) = 0]">
</TR><TR>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Thanks for both of your responses!
Eric

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


Current Thread