【问题标题】:Additional information: 'xsl:template' cannot be a child of the 'TABLE' element附加信息:“xsl:template”不能是“TABLE”元素的子元素
【发布时间】:2015-03-26 01:33:08
【问题描述】:

我的 xsl 文件中有此错误:“xsl:template”不能是“TABLE”元素的子元素。

可能是我的 xsl 文件,还是 c#?

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="Table1">
  <HTML>
    <BODY>
      <TABLE BORDER="2">
        <TR>
          <TD>Item_Code</TD>
          <TD>Item_Description</TD>
          <TD>Current_Count</TD>
          <TD>On_Order</TD>
        </TR>
        <xsl:template select="book"/>
      </TABLE>
    </BODY>
  </HTML>
</xsl:template>
<xsl:template match="Table1">
  <TR>
    <TD><xsl:value-of select="Item_Code"/></TD>
    <TD><xsl:value-of select="Item_Description"/></TD>
    <TD><xsl:value-of select="Current_Count"/></TD>
    <TD><xsl:value-of select="On_Order"/></TD>
  </TR>
</xsl:template>
</xsl:stylesheet>

【问题讨论】:

    标签: html xml templates xslt


    【解决方案1】:

    对于&lt;xsl:template select="book"/&gt; 尝试替换&lt;xsl:apply-templates select="book"/&gt;

    如果你刚刚拍了拍你的额头并哭了 D'oh!,那么平静地去吧,不要再犯罪了。

    否则,您会发现一个好的 XSLT 教程会对您有很大帮助。

    【讨论】:

    • 干杯,这么快!
    • 现在我收到一个 c# 编译错误! // 测试代码 // // 加载样式表。 XslCompiledTransform xslt = new XslCompiledTransform(); xslt.Load("style1.xsl");
    • 您可能希望在 Stack Overflow 上将后续问题作为单独的问题提出。
    猜你喜欢
    • 2015-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 2021-10-26
    • 2014-01-16
    • 2011-11-07
    • 2021-05-10
    相关资源
    最近更新 更多