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

Identifying alternate rows.

Subject: Identifying alternate rows.
From: Jitu <jibhatia@xxxxxxxxxxx>
Date: Wed, 11 Dec 2002 15:00:22 +0530
alternate rows
I have a xml file of the nature :
<row>
       <firstname> James <firstname>
      <lastname> Gosling <lastname>
      <nickname> Jame <nickname>
</row>
<row>
       <firstname> John <firstname>
      <lastname> Green <lastname>
      <nickname> Greeny <nickname>
</row>
<row>
       <firstname> Rojer <firstname>
      <lastname> Gee <lastname>
      <nickname> Roj <nickname>
</row>

I will be displaying this in a table format using XSL and output is HTML.

For this i am using xsl:for loop and outputting data.
I need to highlight alternating rows.

My problem is that in xsl i cannot change value of a variable once declared (based on my limited experience with xsl). So i cannot declare a variable and then keep incrementing it in my for loop, and then figure out if it is has a odd number value or not inside the loop. Every odd number value can indicate to me that the row has to be highlighted.

Here is what xsl for my for loop would look like (I hope i have written it correctly here...):
...
<table>
<xsl:for-each select="row">
<tr> <!-- For every odd numbered row instead of <tr> i would output <tr bgcolor='green'> -->
<td> <xsl:value-of select="firstname" /></td>
<td> <xsl:value-of select="lastname" /></td>
<td> <xsl:value-of select="nickname" /></td>
</tr>
</xsl:for-each>
</table>
...


I am trying to generate a typical report which will have hundreds of rows. Every alternate row must be colored differently.

How can i achieve this.

Thanks for your help


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.