有个问题,查了下xsl的文件,想问下如何判断获取的值中是否包含某一元素。
代码: <xsl:for-each select="/root/tbody/tr[td[1] > '1' ]">
<tr>
<xsl:for-each select="td[position() > 2 ]">
<xsl:variable name="colNum" select="td[position()]"/>
<xsl:choose>
<xsl:when test="position()=1">
<td>
<xsl:value-of select="."/>
</td>
</xsl:when>
<xsl:when test="position()>3">
---在这里我想加个判断,就是如果说这列的数据中如果包含百分号的话,就原样输出,如果没有的话,就执行下边的这个format—number
<td align="right">
<xsl:value-of select="format-number(.,'#,##0.00')"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="."/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:for-each>问下这块儿应该怎么写,以前没有接触过,不太会写这里
代码: <xsl:for-each select="/root/tbody/tr[td[1] > '1' ]">
<tr>
<xsl:for-each select="td[position() > 2 ]">
<xsl:variable name="colNum" select="td[position()]"/>
<xsl:choose>
<xsl:when test="position()=1">
<td>
<xsl:value-of select="."/>
</td>
</xsl:when>
<xsl:when test="position()>3">
---在这里我想加个判断,就是如果说这列的数据中如果包含百分号的话,就原样输出,如果没有的话,就执行下边的这个format—number
<td align="right">
<xsl:value-of select="format-number(.,'#,##0.00')"/>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="."/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:for-each>问下这块儿应该怎么写,以前没有接触过,不太会写这里
<xsl:for-each select="/root/tbody/tr[td[1] > '1' ]">
<tr>
<xsl:for-each select="td[position() > 2 ]">
<xsl:choose>
<xsl:when test="position()=1">
<td>
<xsl:value-of select="."/>
</td>
</xsl:when>
<xsl:when test="position()>3">
<xsl:variable name="isPercent" select="contains(.,'%')"/>
<xsl:when test="$isPercent=true">
<td align="right">
<xsl:value-of select="."/>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="."/>
</td>
</xsl:otherwise>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:value-of select="."/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:for-each>