0

执行xsl后,报错:

因为: xsl:template 元素不得包含 xsl:template 元素;SystemID: 文件:/C:/xslt/CombineToOutput.xsl; 第 19 行;Column#: -1 元素只能在样式表的顶层使用;SystemID: 文件:/C:/xslt/CombineToOutput.xsl; 第 19 行;Column#: -1(编译样式表失败。检测到 2 个错误。)(编译样式表失败。检测到 2 个错误。)

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>
4

1 回答 1

2

错误信息很清楚。

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

包含

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

这在 XSLT 中是不允许的。只需移动内部模板,使其不再包含在外部模板中。

于 2012-09-30T08:19:06.787 回答