2012-09-30 67 views
-1

執行XSL,得到一個錯誤之後:XSL錯誤:一個xsl:template元素不能包含一個xsl:template元素

because of: An xsl:template element must not contain an xsl:template element; SystemID: file:/C:/xslt/CombineToOutput.xsl; Line#: 19; Column#: -1 Element must be used only at top level of stylesheet; SystemID: file:/C:/xslt/CombineToOutput.xsl; Line#: 19; Column#: -1 (Failed to compile stylesheet. 2 errors detected.) (Failed to compile stylesheet. 2 errors detected.)

的XSLT

<?xml version="1.0" encoding="utf-8"?> 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
       xmlns="http://www.openapplications.org/oagis/9"> 

    <!-- STICKER INFO COMBINETOOUTPUT--> 
    <xsl:template match="/"> 
     <xsl:apply-templates select="child::node()/*[name()!='DbResponse']"/>  
    </xsl:template> 

    <xsl:template match="node()|@*"> 
     <xsl:copy> 
      <xsl:apply-templates select="node()|@*"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="*:PurchaseOrder"> 
     <xsl:apply-templates select="*:PurchaseOrderLine/Item/CustomerItemID/ID"/> 

     <xsl:template match="*:PurchaseOrderLine/Item/CustomerItemID/ID"> 
      <xsl:variable name="ArtNr" select="/*/ProcessPurchaseOrder/DataArea/PurchaseOrder/PurchaseOrderLine/Item/CustomerItemID/ID"/> 
      <xsl:variable name="WepNr" select="/*/DbResponse/ResultSet/Row[Cell[@name='ARTNR']=$ArtNr]/Cell[@name='WEPNR']"/> 
      <xsl:copy> 
       <xsl:if test="$WepNr!=''"> 
        <LineNumber><xsl:value-of select="$WepNr"/></LineNumber> 
       </xsl:if> 
       <xsl:apply-templates select="@*|node()"/> 
      </xsl:copy> 
     </xsl:template> 
    </xsl:template> 

</xsl:stylesheet> 
+1

我在這裏遇到麻煩,理解爲什麼你不能理解這個錯誤信息,這個答案的狀態非常清楚。 – 2012-09-30 10:58:23

回答

1

該錯誤消息是清楚的。

<xsl:template match="*:PurchaseOrder"> 

包含

<xsl:template match="*:PurchaseOrderLine/Item/CustomerItemID/ID"> 

,這是不是在XSLT不允許的。只需移動內部模板,以便它不再包含在外部模板中。

相關問題