Subject: RE: [xsl] xsl:variable with hex color values From: "Williamson, Chris" <cwilliamson@xxxxxxxxx> Date: Fri, 20 May 2005 14:55:26 -0400 |
Just a follow up.. You could also do something like this if you are not willing to use css. (errr) <xsl:attribute-set name="bgColorFlop"> <xsl:attribute name="bgcolor"> <xsl:choose> <xsl:when test="position() mod 2 = 0">Red</xsl:when> <xsl:otherwise>Black</xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:attribute-set> <!--Your loop logic/apply-template and table here--> <xsl:for-each> <td xsl:use-attribute-sets="bgColorFlop" align="right"> <xsl:value-of select="./Program" /> </td> </xsl:for-each> -----Original Message----- From: Williamson, Chris [mailto:cwilliamson@xxxxxxxxx] Sent: Friday, May 20, 2005 2:46 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] xsl:variable with hex color values We centralize the choose logic in an attribute set and then just call that attribute set from the td tag, replacing a css class on the different rows. We do this on all of our tables and it works well for us. Hope this helps. <xsl:attribute-set name="bg1Tobg2"> <xsl:attribute name="class"> <xsl:choose> <xsl:when test="position() mod 2 = 0">bg_2</xsl:when> <xsl:otherwise>bg_1</xsl:otherwise> </xsl:choose> </xsl:attribute> </xsl:attribute-set> <!--Your loop logic/apply-template and table here--> <xsl:for-each> <td xsl:use-attribute-sets="bg1Tobg2" align="right"> <xsl:value-of select="./Program" /> </td> </xsl:for-each> -----Original Message----- From: Rolando Isidoro [mailto:rli@xxxxxxxxxx] Sent: Friday, May 20, 2005 2:34 PM To: XSL Mulberrytech Subject: [xsl] xsl:variable with hex color values Hi, I'm trying implementing a XSL which distinguishes odd and even row of a table by using different colors. My solution involves the testing of the number or the position, something like this: <xsl:choose> <xsl:when test="position() mod 2"> <td bgcolor = "..."> .... </td> </xsl:when> <xsl:otherwise> <td bgcolor = "..."> .... </td> </xsl:otherwise> </xsl:choose> the existing code inside each of the <td>'s differs only in the background color, which resolves into big time redundancy. Is there any way to assign the color value to a variable and then using it in the bgcolor attribute? I've tried using something like <xsl:variable name="bg" select="Black"> and then <td bgcolor = "$bg"> but it doesn't seem to work. I've tried with hex color values, which is my objective, and it didn't work either. Thanks, Rolando
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:variable with hex col, Rudolf P . Weinmann | Thread | Re: [xsl] xsl:variable with hex col, Rolando Isidoro |
[xsl] uml to svg?, Dave Pawson | Date | [xsl] Another Special Character Que, Spencer Tickner |
Month |