|
Subject: RE: [xsl] xsl:variable with hex color values From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 20 May 2005 20:49:19 +0100 |
Another solution to add to the list you've been given: In XSLT 2.0 you can
do
<td bgcolor="{if (position() mod 2) then 'black' else 'white'}">
...
</td>
If you want to be terse and don't mind being obscure, you can write things
in XSLT 1.0 like
<td bgcolor="#{substring('FFFFFF000000', (position() mod 2 * 6) + 1, 6)}">
...
</td>
Michael Kay
> -----Original Message-----
> From: Rolando Isidoro [mailto:rli@xxxxxxxxxx]
> Sent: 20 May 2005 19:34
> 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, Aron Bock | Thread | RE: [xsl] xsl:variable with hex col, Williamson, Chris |
| RE: [xsl] XSLT 2.0 - finding nodes , Michael Kay | Date | Re: [xsl] select a node: child of a, Anthony |
| Month |