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

Alternating row background color - a twist

Subject: Alternating row background color - a twist
From: "Hardy Merrill" <HMerrill@xxxxxxxxxxxxxxxx>
Date: Tue, 28 Dec 2004 09:13:06 -0500
row background color
The typical way of alternating the background color of every other row
in an HTML table is something like this:

<xsl:for-each select="msxsl:node-set($sorted_legislators)">
	<tr>
		<xsl:if test="position() mod 2 = 0">
			<xsl:attribute
name="bgcolor">#eeeeee</xsl:attribute>
		</xsl:if>

------------------------------------

My situation is this - the for-each is based on legislators sorted by
district - here's a sample (not real) xml to illustrate:

<legislators>
    <legislator>
         <name>Joe</name>
         <district_id>1</district_id>
    </legislator>
    <legislator>
         <name>Bob</name>
         <district_id>2</district_id>
    </legislator>
    <legislator>
         <name>Pete</name>
         <district_id>2</district_id>
    </legislator>
</legislators>

There will be one *or more* legislators for each district.  Instead of
alternating the background color for every *legislator*, I want to
alternate the background color for every *district*.  In other words, I
want Joe in district_id 1 to have white background, but I want both Bob
and Pete in district_id 2 to have a gray background.  But since I can't
change the value of a variable (can't increment a counter), I don't know
what I can base the bgcolor alternation on.

The xsl:for-each is based on a select of a variable containing all
legislators sorted by district.

I know there is probably an easy way to do this, but I don't know it. 
Help!

Thanks.

Hardy Merrill

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.