|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] alternate bgcolor when node attribute changed
Hello,
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">
<xsl:value-of
select="preceding-sibling::request[position()=1]/attribute::requestId"/>
</xsl:variable>
<!--and I'm creating bgcolor attribute for <TR>-->:
<TR>
<xsl:variable name="lastbgcolor">#ffffff</xsl:variable>
<xsl:attribute name="bgcolor">
<xsl:choose>
<xsl:when test="position()=1"><xsl:value-of
select="$lastbgcolor" /></xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="attribute::requestId
= $rqidprev"><xsl:value-of select="$lastbgcolor" /></xsl:when>
<xsl:otherwise>local:selectColor($bgcolorprev)</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<TD></TD> elements here
</TR>
</xsl:for-each>
and function for changing color:
<msxsl:script implements-prefix="local"><![CDATA[
function selectColor(color)
{
var newcolor;
switch ( color ) {
case "#ffffff" :
newcolor = "#ccccff";
break;
case "#ccccff" :
newcolor = "#ffffff";
break;
default :
newcolor = "#ffffff";
break;
}
return newcolor;
}
]]></msxsl:script>
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,
Nelli
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








