I am using the xsl:copy-of
to display the complete node but it adds additional lines to the top and bottom.
XML
<?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>
Output
between quotes there is a space and empty lines above and below the actual node
"
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>MessageSent.aspx</TraceIdentifier>
</TraceRecord>
"
Desired Output
between quotes there is a space but no line, inside of the node
" <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Information">
<TraceIdentifier>MessageSent.aspx</TraceIdentifier>
</TraceRecord>"
Changing the part
./node()
to*
should solve the issueAlso you may probably ask how to remove the namespace that adds into the table tag
Based on Remove namespace declaration from XSLT stylesheet with XSLT add following parts
and change
to