[xsl] alternate bgcolor when node attribute changed

Subject: [xsl] alternate bgcolor when node attribute changed
From: "Morozova, Nelli" <nmorozova@xxxxxxxxxxxxxx>
Date: Wed, 18 Jul 2001 14:08:11 -0400
I have a question about how to alternate bgcolor attribute of <TR> element
if some attribute of a node is changed, so a group of rows with the same
attribute requestId=15 would have the same bgcolor (white - #ffffff) the
next group with different requestId=21 would has different bgcolor (light
blue - "#ccccff) and next group has again white bgcolor and so on, I cannot
use mod operator since requestId attribute is not changing evenly and
besides user can sort by any column. (So if requestId is changed in
comparison with previous row bgcolor should change otherwise it should
remain the same.)
The problem is: I don't know how can I find out bgcolor attribute of a
previous row in order to assign it to a variable.
I have variable to define attribute requestId of previous node:
<xsl:for-each select="/requests/child::*">		<!--request node->
<xsl:variable name="rqidprev">
<!--and I'm creating bgcolor attribute for <TR>-->:
	<xsl:variable name="lastbgcolor">#ffffff</xsl:variable>
	<xsl:attribute name="bgcolor">
			<xsl:when test="position()=1"><xsl:value-of
select="$lastbgcolor" /></xsl:when>
					<xsl:when test="attribute::requestId
= $rqidprev"><xsl:value-of select="$lastbgcolor" /></xsl:when>
	<TD></TD> elements here
and function for changing color:

<msxsl:script implements-prefix="local"><![CDATA[
    function selectColor(color)
		var newcolor;
		switch ( color ) {
			case "#ffffff" : 
				newcolor = "#ccccff";
			case "#ccccff" : 
				newcolor = "#ffffff";
			default : 
				newcolor = "#ffffff";
		return newcolor;

but variable lastbgcolor is hardcoded here, and because of that it doesn't
work properly it make blue the first row with different requestid and white
all other rows,
could anyone help please?
thank you,

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

Current Thread