C# 将包装器div添加到XSL XML

C# 将包装器div添加到XSL XML,c#,xml,xslt,C#,Xml,Xslt,我有以下XSL转换器,用于生成一些XHTML。生成的XHTML然后在C#中解析为XML,这样就可以将其注入到另一个XHTML文档中。问题在于,从XLS输出的XHTML没有根XML节点,只有兄弟节点(元素)。我尝试手动添加div,但得到错误System.Xml.Xsl.xsloadException:顶级元素“div”可能没有空命名空间。我如何使用XSL添加它,以便div包装所有的 <?xml version="1.0" encoding="utf-8"?> <xsl:style

我有以下XSL转换器,用于生成一些XHTML。生成的XHTML然后在C#中解析为XML,这样就可以将其注入到另一个XHTML文档中。问题在于,从XLS输出的XHTML没有根XML节点,只有兄弟节点(元素)。我尝试手动添加div,但得到错误System.Xml.Xsl.xsloadException:顶级元素“div”可能没有空命名空间。我如何使用XSL添加它,以便div包装所有的

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="msxsl"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:output method="xml" indent="yes"/>      
  <xsl:key name="groups" match="/NewDataSet/QueryResultData" use="MemberReportGroup4Description" />

  <xsl:template match="/NewDataSet">
    <xsl:apply-templates select="QueryResultData[generate-id() = generate-id(key(''groups'', MemberReportGroup4Description)[1])]"/>
  </xsl:template>
  <xsl:template match="stock">
</xsl:template>
<div>
  <xsl:template match="QueryResultData">
    <table id="{MemberReportGroup4Description}">
      <tr>
            <th colspan="6" scope="col"><div align="left"><h1>Store #<xsl:value-of select="MemberReportGroup4Description"/></h1></div></th>
          </tr>
      <tr class="heading">
        <th colspan="2" scope="col">User Name</th>
        <th scope="col">Viewed Percentage</th>
        <th scope="col">Enrollment Date</th>
        <th scope="col">Status</th>
        <th scope="col">Requirement Completion Date</th>
      </tr>
      <xsl:for-each select="key(''groups'', MemberReportGroup4Description)">
        <tr>
          <td><xsl:value-of select="MemberFirstName"/></td>
          <td><xsl:value-of select="MemberLastName"/></td>
          <td><xsl:value-of select="ViewedPercentage"/></td>
          <td><xsl:value-of select="EnrollmentDate"/></td>
          <td><xsl:value-of select="Status"/></td>
          <td><xsl:value-of select="MemberReportGroup4Description"/></td>
        </tr>
      </xsl:for-each>
    </table>
  </xsl:template>\
  </div>
</xsl:stylesheet>

贮藏#
用户名
浏览百分比
报名日期
地位
要求完成日期
\

您应该在此处添加您的

<xsl:template match="/NewDataSet">
  <div>
    <xsl:apply-templates select="QueryResultData[...]"/>
  </div>
</xsl:template>