This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Newbie question:
> A beginner question again :-) Can I put <table > command in the body of a
> <xsl:when test ... > tag ? I mean, I wish to change the Background color of
a
> table, depending on the value of a tag.
> So I wish to do something like this, but it does not work...
>
> <xsl:choose>
> <xsl:when test='@ODD="O"'><table bgcolor="#000066"></td></xsl:when>
> <xsl:when test='@ODD="N"'><table bgcolor="3366CC"></td></xsl:when>
> </xsl:choose>
>
Yap! It doesn't work because you cannot leave the <table> tag open.
But you should be able to change your code into:
<table>
<xsl:choose>
<xsl:when test='@ODD="O"'><xsl:attribute name="bgcolor"
value="#000066"/></xsl:when>
<xsl:when test='@ODD="N"'><xsl:attribute name="bgcolor"
value="#3366CC"/></xsl:when>
</xsl:choose>
<!-- table content goes here -->
</table>
or
<xsl:variable name="bgcolor">
<xsl:choose>
<xsl:when test='@ODD="O"'>#000066</xsl:when>
<xsl:when test='@ODD="N"'>#3366CC</xsl:when>
</xsl:choose>
</xsl:variable>
<table bgcolor="{$bgcolor}">
<!-- table content here -->
</table>
(I hope I got the syntax right :)
-- Raffaele
-----------------------------------------------------
raff@aromatic.org (::) http://www.aromatic.org/~raff/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list