Subject: RE: Different Colors for Alternating Rows
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Fri, 27 Jun 2003 16:47:54 +0100
|
Hi
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
> Schwartz, Rechell R, ALABS
> Sent: Thursday, June 26, 2003 4:08 PM
> To: Schwartz, Rechell R, ALABS; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: Different Colors for Alternating Rows
>
>
> Before I throw in the towel on this one, I tried my own
> approach, which I thought should work, but didn't. Any
> insights would be appreciated.
Try this, it worked with the example provided
<xsl:template match="node()|@*">
<!--identity transform-->
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="table">
<xsl:copy>
<xsl:apply-templates mode="oddeven" select="tr[td[not(a or
@class)]]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="tr" mode="oddeven">
<xsl:variable name="pos" select="position() mod 2"/>
<!-- the non selected nodes are precessed by the identity template and
are selected here. -->
<xsl:apply-templates select="preceding-sibling::tr[td[a or
@class]][generate-id(following-sibling::tr[td[not(a or
@class)]])=generate-id(current())]"/>
<xsl:copy>
<!-- you could use xsl:choose if you want, I use a boolean test to set
the correct mode -->
<xsl:apply-templates mode="odd" select="node()[$pos=1]"/>
<xsl:apply-templates mode="even" select="node()[$pos=0]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="td" mode="odd">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="class">oddMedium</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="td" mode="even">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="class">evenMedium</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
Hope this helps you
(...)
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
- RE: Different Colors for Alternating Rows, (continued)
- Jarno . Elovirta - Thu, 26 Jun 2003 05:03:00 -0400 (EDT)
- Schwartz, Rechell R, ALABS - Thu, 26 Jun 2003 09:36:16 -0400 (EDT)
- Schwartz, Rechell R, ALABS - Thu, 26 Jun 2003 11:09:09 -0400 (EDT)
- Américo Albuquerque - Fri, 27 Jun 2003 11:50:55 -0400 (EDT) <=
- Kevin Jones - Sat, 28 Jun 2003 05:37:23 -0400 (EDT)
- dsk - Sat, 28 Jun 2003 09:24:23 -0400 (EDT)
- Schwartz, Rechell R, ALABS - Fri, 27 Jun 2003 15:22:51 -0400 (EDT)
- Schwartz, Rechell R, ALABS - Mon, 30 Jun 2003 16:50:06 -0400 (EDT)
|
|