需要根据XML变量值更改文本的颜色



我想根据变量中返回的值有条件地更改XML文件中显示文本的颜色
它将是"是"或"否"。

这是XML:

<tr style="height: 18px;">
<td style="width: 163px; height: 18px;"><strong>Validation Required?</strong></td>
<td style="width: 50px; height: 18px;"><xsl:value-of select="Validation_Required"></xsl:value-of></td>
<td style="width: 652px; height: 18px;" colspan="4"></td>
</tr>

我希望Validation_Required?值的文本在其值为"是"时显示为红色,在其为"否"时显示黑色。

到目前为止,我对这种方法运气不佳:

<xsl:when test="Validation_Required='Yes'">

我想知道是否有人能为我指明正确的方向。

XSLT中的变量是用$前缀访问的,所以要访问变量Validation_Required,必须给它加前缀。

将代码更改为

<tr style="height: 18px;">
<td style="width: 163px; height: 18px;"><strong>Validation Required?</strong></td>
<td style="width: 50px; height: 18px;">
<xsl:choose>
<xsl:when test="$Validation_Required='Yes'">
<span style="color:rgb(255, 0, 0);">
<xsl:value-of select="$Validation_Required"></xsl:value-of>
</span>
</xsl:when>
<xsl:when test="$Validation_Required='No'">
<span style="color:rgb(0, 0, 0);">
<xsl:value-of select="$Validation_Required"></xsl:value-of>
</span>
</xsl:when>
</xsl:choose>
</td>
<td style="width: 652px; height: 18px;" colspan="4"></td>
</tr>

基于CCD_ 5变量的值来改变一个CCD_。

最新更新