0
我正在使用xsl:copy-of
来显示完整的节点,但它在顶部和底部添加了其他行。如何删除xslt中的换行符
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<root>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>MessageSent.aspx</TraceIdentifier>
</TraceRecord>
</DataItem>
<DataItem>
<table>
<tr>
<td>This should not be a table</td>
<td>It must be a text</td>
</tr>
</table>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
</root>
XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:te="http://schemas.microsoft.com/2004/06/E2ETraceEvent"
exclude-result-prefixes="te">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<output>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body>
<table>
<thead>
<tr>
<td>Data</td>
</tr>
</thead>
<tbody>
<xsl:for-each select="//te:E2ETraceEvent">
<tr>
<td>
<table>
<xsl:for-each select=".//te:TraceData//te:DataItem">
<tr>
<td>
<xmp>
<xsl:copy-of select="./node()" />
</xmp>
</td>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</output>
</xsl:template>
</xsl:stylesheet>
输出
引号之间有上述和实际节点
"
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>MessageSent.aspx</TraceIdentifier>
</TraceRecord>
"
下方的空间和空行
所需的输出
引号之间有一个空格,但没有线路,节点
" <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>MessageSent.aspx</TraceIdentifier>
</TraceRecord>"
,我看到了让像 “ MessageSent.aspx TraceIdentifier> TraceRecord> –
Kash
2015-02-05 17:00:28
请发布足够的代码以使我们能够重现问题。您的XSLT没有输出任何引号,因此单独已经没有意义。 – 2015-02-05 17:50:43