|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Newbie question:
> 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>
>
(a) You can't write half a node to the result tree, and (b) the stylesheet
has to be well-formed XML, which are two different ways of saying that you
can't do this, because the <table> start tag has to be matched by a </table>
end tag (Heaven only knows what the </td> is doing there).
So even though it seems as if:
<choose>
<when x><table aa></when>
<when otherwise><table bb></when>
...
</choose>
</table>
wll always generate a matching closing tag, this isn't the way XSLT works,
because it doesn't write tags, it writes nodes.
The simplest solution here is to use a variable:
<xsl:variable name="color">
<xsl:choose>
<xsl:when test='@ODD="O"'>#000066</xsl:when>
<xsl:when test='@ODD="N"'>#3366CC</xsl:when>
</xsl:choose>
</xsl:variable>
<table bgcolor="{$color}">
...
</table>
Mike Kay
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








