Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using an xsl:choose to change a tag that gets closed outside the choose

1 view
Skip to first unread message

tdma...@yahoo.com

unread,
Dec 4, 2009, 4:56:12 PM12/4/09
to
I am looking to use <xsl:choose> inside a for-each to change the
color of a cell in a html table. I want to
<tr> to become td bgcolor='xxxx'> in the case where the author is
'op.' However it fails because it can't be assured the output it well
formatted. How can I review to make this work.

I had hoped to do something like this, but can someone tell me the
proper way to do this

<xsl:choose>
<xsl:when test="cvs2cl:author='op'">
<td bgcolor='xxxx'>
</xsl:when>
<xsl:otherwise>
<td>
</xsl:otherwise>
</xsl:choose>

-----------------------------------

..................
<xsl:for-each select="cvs2cl:entry">
<tr>
<td>
<xsl:value-of select="cvs2cl:date"/>
</td>
<td> <---- Looking to have code change this <td> tag
<xsl:value-of select="cvs2cl:author"/>
</td>
<td>
<xsl:for-each select="cvs2cl:file">
<table>
<tr>
<td>
<xsl:value-of select="cvs2cl:name"/>
<xsl:text> - v</xsl:text>
<xsl:value-of select="cvs2cl:revision"/>
</td>
</tr>
</table>
</xsl:for-each>
</td>
<td>
<xsl:value-of select="cvs2cl:msg"/>
</td>
</tr>
</xsl:for-each>
...............


---------------------------------------

Martin Honnen

unread,
Dec 5, 2009, 6:44:47 AM12/5/09
to
tdma...@yahoo.com wrote:

> I had hoped to do something like this, but can someone tell me the
> proper way to do this
>
> <xsl:choose>
> <xsl:when test="cvs2cl:author='op'">
> <td bgcolor='xxxx'>
> </xsl:when>
> <xsl:otherwise>
> <td>
> </xsl:otherwise>
> </xsl:choose>

So you want the td element in any case and then you want to
conditionally add the attribute:
<td>
<xsl:if test="...">
<xsl:attribute name="bgcolor">xxxx</xsl:attribute>
</xsl:if>
...
</td>

--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

0 new messages