|
Subject: [xsl] Alternating row background color - a twist From: "Hardy Merrill" <HMerrill@xxxxxxxxxxxxxxxx> Date: Tue, 28 Dec 2004 09:13:06 -0500 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Convert string to nodeset, Thorsten Scherler | Thread | Re: [xsl] Alternating row backgroun, M. David Peterson |
| Re: [xsl] end-of-sentence full stop, W. Eliot Kimber | Date | Re: [xsl] Alternating row backgroun, M. David Peterson |
| Month |