您收到错误,因为在 XSLT 1.0 中,匹配模式无法引用变量。
您可以通过以下方式优雅而有效地避免这种情况:
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:multimap="http://sap.com/xi/XI/SplitAndMerge"
xmlns:n0="http://sap.com/xi/SAPGlobal20/Global">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="keepItems" match="n0:ServiceRequestFollowUpDocumentReplicationRequest/ServiceRequestFollowUpDocumentReplicateRequestMessage/ServiceRequest/Item" use="ID" />
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- Überspringe ServiceRequestItem, deren ID nicht im ServiceRequest-Element ist -->
<xsl:template match="ServiceRequestItem[not(key('keepItems', ID))]"/>
</xsl:stylesheet>