这是我尝试过的方法,否则总是有效的。如果type = 'WEEKLY‘,我需要它输出"W“
<xsl:for-each select="times/weekly_monthly">
<tr>
<td>
<xsl:choose>
<xsl:when test="type='WEEKLY'">W</xsl:when>
<xsl:otherwise>
otherwise always works
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each> 如果我去掉choose,它就可以很好地迭代。这是xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type= "text/xsl" href= "test.xsl"?>
<!-- Edited by XMLSpy® -->
<times>
<weekly_monthly>
<type>
WEEKLY
</type>
</weekly_monthly>
<weekly_monthly>
<type>
MONTHLY
</type>
</weekly_monthly>
<weekly_monthly>
<type>
NULL
</type>
</weekly_monthly>
</times>发布于 2012-11-20 06:51:05
这是因为<type>节点包含空格。使用normalize-space()函数,即:
normalize-space(type) = 'WEEKLY'或contains()函数:
contains(type, 'WEEKLY')https://stackoverflow.com/questions/13463715
复制相似问题