我无法让XSLT仅返回XML中的类别值。为什么lastupdate和路径被返回? ...我怎样才能阻止呢?提前致谢。XSLT显式节点选择无返回
XML文档
<?xml version="1.0"?>
<categories count="3">
<lastupdate>08/12/2010 12:27</lastupdate>
<path>C:\</path>
<category>Music</category>
<category>News</category>
<category>Sport</category>
</categories>
我的XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="categories">
<html>
<body>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<xsl:apply-templates/>
</td>
</tr>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="category">
<a>
<xsl:value-of select="." />
</a>
</xsl:template>
</xsl:stylesheet>
输出HTML
<html>
<body>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>08/12/2010 12:27C:\
<a>Music</a>
<a>News</a>
<a>Sport</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
你的输出表明,这是不完整的XSLT your're运行。我怀疑你的xslt中有更多东西将`lastupdate`和`path`复制到你的输出中。 – Filburt 2010-12-08 15:20:52
我同意。桌子从哪里来?从您发布的代码中不清楚 – 2010-12-08 15:22:39
从他样本中的缩进来看,他将表格放在body和apply-templates之间,这也将解释输出。 – TToni 2010-12-08 15:25:37