xslt使用,实现未知XML表字段内容的,表格输出,
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table cellspacing="0" cellpadding="5" align="Center" rules="all" border="1" style="border-width:1px;border-style:solid;font-size:9pt;width:80%;border-collapse:collapse;">
<tr>
<!--输出表头信息-->
<xsl:apply-templates select="/Toolkit/RTable[1]/*" mode="title"/>
</tr>
<xsl:for-each select="/Toolkit/RTable">
<tr>
<!--出各行数据内容-->
<xsl:variable name="p" select="position()"/>
<xsl:apply-templates select="/Toolkit/RTable[position() = $p]/*" mode="ItemDetail"/>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="/Toolkit/RTable[1]/*" mode="title">
<td align="char" bgcolor="#999999">
<b>
<xsl:value-of select="local-name()"/>
</b>
</td>
</xsl:template>
<xsl:template match="/Toolkit/RTable/*" mode="ItemDetail">
<td>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table cellspacing="0" cellpadding="5" align="Center" rules="all" border="1" style="border-width:1px;border-style:solid;font-size:9pt;width:80%;border-collapse:collapse;">
<tr>
<!--输出表头信息-->
<xsl:apply-templates select="/Toolkit/RTable[1]/*" mode="title"/>
</tr>
<xsl:for-each select="/Toolkit/RTable">
<tr>
<!--出各行数据内容-->
<xsl:variable name="p" select="position()"/>
<xsl:apply-templates select="/Toolkit/RTable[position() = $p]/*" mode="ItemDetail"/>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="/Toolkit/RTable[1]/*" mode="title">
<td align="char" bgcolor="#999999">
<b>
<xsl:value-of select="local-name()"/>
</b>
</td>
</xsl:template>
<xsl:template match="/Toolkit/RTable/*" mode="ItemDetail">
<td>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:value-of select="."/>
</td>
</xsl:template>
</xsl:stylesheet>