[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Different Colors for Alternating Rows

Subject: RE: Different Colors for Alternating Rows
From: "Schwartz, Rechell R, ALABS" <rrschwartz@xxxxxxx>
Date: Fri, 27 Jun 2003 14:21:37 -0500
xslt alternating rows

Your solution was the most promising so far. The time to execute was less than half of what I had before, but unfortunately that is still long (now it's about 3 minutes, compared to 7.5 minutes).

The solutions that looked like they held promise from a performance point of view, but which didn't seem to work due to array index out of bound errors were the ones that recursively re-applied the template match for select="following-sibling:tr[1]." (I wonder if somehow it's faster to get the following-sibling than the previous sibling.)

Thanks very much,
Rechell Schwartz

-----Original Message-----
From: Américo Albuquerque [mailto:melinor@xxxxxxx] 
Sent: Friday, June 27, 2003 11:48 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Different Colors for Alternating Rows


> -----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:apply-templates select="node()|@*"/>

  <xsl:template match="table">
      <xsl:apply-templates mode="oddeven" select="tr[td[not(a or

  <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
      <!-- 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:template match="td" mode="odd">
      <xsl:apply-templates select="@*"/>
      <xsl:attribute name="class">oddMedium</xsl:attribute>

  <xsl:template match="td" mode="even">
      <xsl:apply-templates select="@*"/>
      <xsl:attribute name="class">evenMedium</xsl:attribute>

Hope this helps you

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

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.