我很少对xslt感兴趣,并尝试过使用各种方法检查节点是否有孩子。我有以下几点:XSL - 如果节点有孩子,如何做一件事,否则做另一件事
<xsl:if test="child::list">
以上的部分工作,但问题是我已经在这个方法中使用when
与otherwise
试过,但它不工作。它看起来像这样:
<xsl:when test="child::list">
,我猜是错误的,因为它不工作。
的代码如下:
<xsl:for-each select="td">
<td>
<xsl:when test="child::list">
<table cellpadding='0' cellspacing='0'>
<thead>
<tr>
<xsl:for-each select="list/item/table/thead/tr/th">
<th><xsl:value-of select="self::node()[text()]"/></th>
</xsl:for-each>
</tr>
<xsl:for-each select="list/item/table/tbody/tr">
<tr>
<xsl:for-each select="td">
<td><xsl:value-of select="self::node()[text()]"/></td>
</xsl:for-each>
</tr>
</xsl:for-each>
</thead>
</table>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="self::node()[text()]"/>
</xsl:otherwise>
</td>
</xsl:for-each>
任何帮助将不胜感激...
哦没关系。感谢您的回应。现在一切正常。 :) – 2013-04-25 11:04:20