|
Subject: RE: Newbie question: From: Kay Michael <Michael.Kay@xxxxxxx> Date: Tue, 21 Mar 2000 09:58:12 -0000 |
> 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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| sort,count,number,group solved, quagly | Thread | errors when validating stylesheets , Carsten Ullrich |
| Re: xsl:fo, Sebastian Rahtz | Date | RE: How to get XML tag attribute, Kay Michael |
| Month |