Subject: [xsl] alternate bgcolor when node attribute changed From: "Morozova, Nelli" <nmorozova@xxxxxxxxxxxxxx> Date: Wed, 18 Jul 2001 14:08:11 -0400 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] namespace, cutlass | Thread | Re: [xsl] alternate bgcolor when no, Jeni Tennison |
Re: [xsl] PDF creation using FO and, Matt Sergeant | Date | Re: [xsl] More Multi-Document Mambo, David Carlisle |
Month |