xsl-list
[Top] [All Lists]

Tracking line counts uniquely by section

2002-11-07 14:00:31
All,

I am using the following code (adapted from code graciously provided by Ken 
Holman) to generate alternate row colors for rows in a table using the identity 
transformation. I would now like to take the next step and add the following 
change:

The table is comprised of multiple sections and after each section header, I 
want to be able able to start the row counter back to 1 so that the line 
following the section header always has the same color: The distingushing 
characteristics of the section headers are that they have a class attribute 
called "headerStyle", and therefore need to be exempted form receiving
an odd or even row style, and rows following the section header line all need 
to have the same color.

I was trying to get it to work by using paramters and recursion but got stuck. 
Any assistance would be greatly appreciated.

Thanks,
Rechell

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 version="1.0">
<xsl:output method="html" indent="yes"/>

<xsl:template match="node()|@*"> <!--identity transform-->
   <xsl:copy>
     <xsl:apply-templates select="node()|@*"/>
   </xsl:copy>
</xsl:template>

<xsl:template match="tr[ position() mod 2 = 0 ]/td">
   <xsl:copy>
    <xsl:attribute name="class">oddRowStyle</xsl:attribute>
     <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
</xsl:template>

<xsl:template match="tr[ position() mod 2 = 1 ]/td">
   <xsl:copy>
    <xsl:attribute name="class">evenRowStyle</xsl:attribute>
     <xsl:apply-templates select="node()|@*"/>
   </xsl:copy>
</xsl:template>

</xsl:stylesheet>

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



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