XSLT 2.0 根据条件删除元素并在每个组中复制其余部分

XSLT 2.0 remove elements based on condition and copy rest within for-each-group

我希望按原样复制输入 XML 并删除具有相同“FULFILMENT_LINE_ID”值的冗余记录,同时删除“ORIG_SYS_PARENT_INSTANCE_REF”、“[=28=” ]”为冗余节点

像下面这样输入XML

<InputParameters xmlns:nstrgmpr="http://www.testing.com/learning" >
    <nstrgmpr:P_INSTALL_BASE_STG>
        <nstrgmpr:P_INSTALL_BASE_STG_ITEM>
            <nstrgmpr:ORIG_SYS_INSTANCE_REF>100000006534646</nstrgmpr:ORIG_SYS_INSTANCE_REF>
            <nstrgmpr:ITEM_NUMBER>9W0000365</nstrgmpr:ITEM_NUMBER>
            <nstrgmpr:FULFILMENT_LINE_ID>300000008528224</nstrgmpr:FULFILMENT_LINE_ID>
            <nstrgmpr:IB_RECORD_COUNT>3</nstrgmpr:IB_RECORD_COUNT>
        </nstrgmpr:P_INSTALL_BASE_STG_ITEM>
        <nstrgmpr:P_INSTALL_BASE_STG_ITEM>
            <nstrgmpr:ORIG_SYS_INSTANCE_REF>100000006534645</nstrgmpr:ORIG_SYS_INSTANCE_REF>
            <nstrgmpr:ITEM_NUMBER>9W0000365-1002-M</nstrgmpr:ITEM_NUMBER>
            <nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>100000006534645</nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>
            <nstrgmpr:RELATIONSHIP_TYPE>Component Of</nstrgmpr:RELATIONSHIP_TYPE>
            <nstrgmpr:FULFILMENT_LINE_ID>300000008528224</nstrgmpr:FULFILMENT_LINE_ID>
            <nstrgmpr:IB_RECORD_COUNT>3</nstrgmpr:IB_RECORD_COUNT>
        </nstrgmpr:P_INSTALL_BASE_STG_ITEM>
        <nstrgmpr:P_INSTALL_BASE_STG_ITEM>
            <nstrgmpr:ORIG_SYS_INSTANCE_REF>100000006534647</nstrgmpr:ORIG_SYS_INSTANCE_REF>
            <nstrgmpr:ITEM_NUMBER>9W0000328</nstrgmpr:ITEM_NUMBER>
            <nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>100000006534645</nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>
            <nstrgmpr:RELATIONSHIP_TYPE>Component Of</nstrgmpr:RELATIONSHIP_TYPE>
            <nstrgmpr:FULFILMENT_LINE_ID>300000008528229</nstrgmpr:FULFILMENT_LINE_ID>
            <nstrgmpr:IB_RECORD_COUNT>3</nstrgmpr:IB_RECORD_COUNT>
        </nstrgmpr:P_INSTALL_BASE_STG_ITEM>
        <nstrgmpr:P_INSTALL_BASE_STG_ITEM>
            <nstrgmpr:ORIG_SYS_INSTANCE_REF>100000006534648</nstrgmpr:ORIG_SYS_INSTANCE_REF>
            <nstrgmpr:ITEM_NUMBER>9W0000327</nstrgmpr:ITEM_NUMBER>
            <nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>100000006534645</nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>
            <nstrgmpr:RELATIONSHIP_TYPE>Component Of</nstrgmpr:RELATIONSHIP_TYPE>
            <nstrgmpr:FULFILMENT_LINE_ID>300000008528239</nstrgmpr:FULFILMENT_LINE_ID>
            <nstrgmpr:IB_RECORD_COUNT>3</nstrgmpr:IB_RECORD_COUNT>
        </nstrgmpr:P_INSTALL_BASE_STG_ITEM>
    </nstrgmpr:P_INSTALL_BASE_STG>
</InputParameters>

预期输出如下:

<InputParameters xmlns:nstrgmpr="http://www.testing.com/learning" >
    <nstrgmpr:P_INSTALL_BASE_STG>
        <nstrgmpr:P_INSTALL_BASE_STG_ITEM>
            <nstrgmpr:ORIG_SYS_INSTANCE_REF>100000006534645</nstrgmpr:ORIG_SYS_INSTANCE_REF>
            <nstrgmpr:ITEM_NUMBER>9W0000365-1002-M</nstrgmpr:ITEM_NUMBER>
            <nstrgmpr:FULFILMENT_LINE_ID>300000008528224</nstrgmpr:FULFILMENT_LINE_ID>
            <nstrgmpr:IB_RECORD_COUNT>3</nstrgmpr:IB_RECORD_COUNT>
        </nstrgmpr:P_INSTALL_BASE_STG_ITEM>
        <nstrgmpr:P_INSTALL_BASE_STG_ITEM>
            <nstrgmpr:ORIG_SYS_INSTANCE_REF>100000006534647</nstrgmpr:ORIG_SYS_INSTANCE_REF>
            <nstrgmpr:ITEM_NUMBER>9W0000328</nstrgmpr:ITEM_NUMBER>
            <nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>100000006534645</nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>
            <nstrgmpr:RELATIONSHIP_TYPE>Component Of</nstrgmpr:RELATIONSHIP_TYPE>
            <nstrgmpr:FULFILMENT_LINE_ID>300000008528229</nstrgmpr:FULFILMENT_LINE_ID>
            <nstrgmpr:IB_RECORD_COUNT>3</nstrgmpr:IB_RECORD_COUNT>
        </nstrgmpr:P_INSTALL_BASE_STG_ITEM>
        <nstrgmpr:P_INSTALL_BASE_STG_ITEM>
            <nstrgmpr:ORIG_SYS_INSTANCE_REF>100000006534648</nstrgmpr:ORIG_SYS_INSTANCE_REF>
            <nstrgmpr:ITEM_NUMBER>9W0000327</nstrgmpr:ITEM_NUMBER>
            <nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>100000006534645</nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF>
            <nstrgmpr:RELATIONSHIP_TYPE>Component Of</nstrgmpr:RELATIONSHIP_TYPE>
            <nstrgmpr:FULFILMENT_LINE_ID>300000008528239</nstrgmpr:FULFILMENT_LINE_ID>
            <nstrgmpr:IB_RECORD_COUNT>3</nstrgmpr:IB_RECORD_COUNT>
        </nstrgmpr:P_INSTALL_BASE_STG_ITEM>
    </nstrgmpr:P_INSTALL_BASE_STG>
</InputParameters>

XSLT 低于我使用的

    <!--User Editing Not Allowed for Sections: oracle-xsl-mapper:schema, top level xsl:params, version attribute of the stylesheet element. GENERATED BY OIC MAPPER, DO NOT DELETE THIS LINE-->
<xsl:stylesheet xmlns:ns1="http://xmlns.oracle.com/apps/scm/doo/taskLayer/activity/model/view/" xmlns:nsmpr0="http://xmlns.oracle.com/apps/scm/doo/processOrder/service/" xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc" xmlns:ns2="http://xmlns.oracle.com/apps/scm/doo/taskLayer/model/" xmlns:flt="http://xmlns.oracle.com/cloud/generic/service/fault" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:errors="http://xmlns.oracle.com/adf/svc/errors/" xmlns:ns0="http://xmlns.oracle.com/adf/svc/types/" xmlns:sdoXML="commonj.sdo/xml" xmlns:sdoJava="commonj.sdo/java" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:tns="http://www.w3.org/2005/08/addressing" xmlns:oracle-xsl-mapper="http://www.oracle.com/xsl/mapper/schemas" xmlns:nsmpr1="http://xmlns.oracle.com/apps/flex/scm/doo/processOrder/pjcDff/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:nstrgdfl="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:nssrcmpr="http://xmlns.oracle.com/types/GetFulfillmentRequest_OM_Trigger/1611909117418/InboundSOAPRequestDocument" xmlns:sdo="commonj.sdo" xmlns:nsmpr2="http://xmlns.oracle.com/apps/scm/doo/taskLayer/activity/model/" xmlns:nsmpr3="http://xmlns.oracle.com/cloud/adapter/atpdatabase/SHARE_Procedure_Invoke_REQUEST" xmlns:nssrcdfl="http://xmlns.oracle.com/procmon" xmlns:client="http://xmlns.oracle.com/apps/scm/doo/taskLayer/externalInterfaceLayer/DooTaskExternalInterfaceVirtualPartnersComposite/FulfillmentRequest" xmlns:nsmpr4="http://xmlns.oracle.com/apps/scm/doo/processOrder/model/" xmlns:nstrgmpr="http://www.testing.com/learning" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nsmpr5="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/fulfillLineContextsB/" xmlns:ignore01="http://www.oracle.com/XSL/Transform/java" xmlns:nsmpr6="http://xmlns.oracle.com/oxp/service/PublicReportService" xmlns:nsmpr7="http://xmlns.oracle.com/types/AssetReportBIPBILLTO_SCM_Invoke02/1623285961773/OutboundSOAPRequestDocument" xmlns:nsmpr8="http://xmlns.oracle.com/types/AssetReportBIP_SCM_Invoke01/1623285741394/OutboundSOAPRequestDocument" xmlns:nsmpr9="http://xmlns.oracle.com/cloud/adapter/REST/GetAssetDetails_SCM_Invoke_REQUEST/types" xmlns:nsmpr10="http://xmlns.oracle.com/cloud/adapter/REST/GetAssetRelationshipDetail_SCM_Invoke_REQUEST/types" xmlns:nsmpr11="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_GetHubOrganization_CX_REQUEST/types" xmlns:nsmpr12="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_SCM_GetSalesOrderBillToCustomer_REQUEST/types" xmlns:nsmpr13="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_SCM_GetSalesOrderForOrderHub_REQUEST/types" xmlns:nsmpr14="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_SCM_GetSalesOrderShipToCustomer_REQUEST/types" xmlns:nsmpr15="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Read_BIPBILLTOReport_REQUEST/types" xmlns:nsmpr16="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Read_BIPSHIPTOReport_REQUEST/types" xmlns:nsmpr17="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Write_BIPBILLTOReport_REQUEST/types" xmlns:nsmpr18="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Write_BIPSHIPTOReport_REQUEST/types" xmlns:nsmpr19="http://www.oracle.com/2014/03/ic/integration/metadata" xmlns:ns97="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Write_BIPBILLTOReport_REQUEST" xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd" xmlns:ns70="http://xmlns.oracle.com/cloud/adapter/REST/GetAssetRelationshipDetail_SCM_Invoke/types" xmlns:ns69="http://xml.oracle.com/types/REST/GetAssetRelationshipDetail_SCM_Invoke_REQUEST" xmlns:ns72="http://xmlns.oracle.com/cloud/generic/rest/fault/REST/Invoke_GetHubOrganization_CX" xmlns:ns75="http://xml.oracle.com/types/REST/Invoke_GetHubOrganization_CX_REQUEST" xmlns:ns78="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_SCM_GetSalesOrderBillToCustomer_REQUEST/RESTOUTRES" xmlns:ns80="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_SCM_GetSalesOrderBillToCustomer/types" xmlns:ns55="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/salesCreditCategories/" xmlns:ns81="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_SCM_GetSalesOrderBillToCustomer_REQUEST/RESTOUTREQ" xmlns:ns100="http://xmlns.oracle.com/pcbpel/adapter/opaque/" xmlns:ns89="http://xmlns.oracle.com/cloud/generic/rest/fault/REST/Invoke_SCM_GetSalesOrderShipToCustomer" xmlns:dvm="http://www.oracle.com/XSL/Transform/java/com.bea.wli.sb.functions.dvm.DVMFunctions" xmlns:ns71="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_GetHubOrganization_CX_REQUEST/RESTOUTRES" xmlns:ns49="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/priceAdjustmentCategories/" xmlns:ns67="http://xmlns.oracle.com/cloud/generic/rest/fault/REST/GetAssetRelationshipDetail_SCM_Invoke" xmlns:ns52="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/lotSerialNumberCategories/" xmlns:orajs2="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1530914355" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:orajs3="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1846217501" xmlns:ns73="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_GetHubOrganization_CX_REQUEST/RESTOUTREQ" xmlns:ns62="http://xmlns.oracle.com/cloud/adapter/REST/GetAssetDetails_SCM_Invoke/types" xmlns:ns3="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue" xmlns:ns54="http://xmlns.oracle.com/ics/tracking/ics_tracking_context.xsd" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns96="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Read_BIPSHIPTOReport_REQUEST" xmlns:ns101="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Write_BIPSHIPTOReport_REQUEST" xmlns:ns47="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/fulfillLineDetailCategories/" xmlns:ns58="http://xml.oracle.com/types/REST/GetAssetDetails_SCM_Invoke_REQUEST" xmlns:ns48="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/headerCategories/" xmlns:ns68="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/GetAssetRelationshipDetail_SCM_Invoke_REQUEST/RESTOUTREQ" xmlns:ns98="http://xmlns.oracle.com/cloud/ics/file/v1/types" xmlns:ns85="http://xml.oracle.com/types/REST/Invoke_SCM_GetSalesOrderForOrderHub_REQUEST" xmlns:ns51="http://xmlns.oracle.com/apps/scm/doo/taskLayer/activity/flex/activityCategories/" xmlns:ns86="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_SCM_GetSalesOrderForOrderHub/types" xmlns:ns84="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_SCM_GetSalesOrderForOrderHub_REQUEST" xmlns:ns59="http://xml.oracle.com/adapters/extension" xmlns:ns65="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/GetAssetRelationshipDetail_SCM_Invoke_REQUEST/RESTOUTRES" xmlns:ns76="http://xmlns.oracle.com/cloud/generic/rest/fault/REST/Invoke_SCM_GetSalesOrderBillToCustomer" xmlns:ns92="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_SCM_GetSalesOrderShipToCustomer_REQUEST/RESTOUTREQ" xmlns:ns88="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_SCM_GetSalesOrderShipToCustomer_REQUEST/RESTOUTRES" xmlns:ns83="http://xmlns.oracle.com/cloud/generic/rest/fault/REST/Invoke_SCM_GetSalesOrderForOrderHub" xmlns:ns95="http://TargetNamespace.com/fileReference/StageFile_Read_BIPSHIPTOReport" xmlns:ns94="http://xmlns.oracle.com/cloud/adapter/stagefile/StageFile_Read_BIPBILLTOReport_REQUEST" xmlns:orajs4="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1905736912" xmlns:connprop="http://xmlns.oracle.com/cloud/adapter/connectivityproperties" xmlns:ns50="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/paymentCategories/" xmlns:ns99="http://xmlns.oracle.com/cloud/staging/write" xmlns:ns60="http://xmlns.oracle.com/cloud/generic/rest/fault/REST/GetAssetDetails_SCM_Invoke" xmlns:ns63="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/GetAssetDetails_SCM_Invoke_REQUEST/RESTOUTREQ" xmlns:ns64="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/GetAssetDetails_SCM_Invoke_REQUEST/RESTOUTRES" xmlns:ns53="http://xmlns.oracle.com/apps/scm/doo/processOrder/flex/fulfillLineCategories/" xmlns:ns74="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_GetHubOrganization_CX/types" xmlns:orajs0="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath86288" xmlns:ns79="http://xml.oracle.com/types/REST/Invoke_SCM_GetSalesOrderBillToCustomer_REQUEST" xmlns:ns5="http://www.oracle.com/XSL/Transform/java/com.bea.wli.sb.resources.icsxpathfunctions.ICSInstanceTrackingFunctions" xmlns:ns90="http://xml.oracle.com/types/REST/Invoke_SCM_GetSalesOrderShipToCustomer_REQUEST" xmlns:ns91="http://xmlns.oracle.com/cloud/adapter/REST/Invoke_SCM_GetSalesOrderShipToCustomer/types" xmlns:orajs1="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.JsExecutor_xpath1677201779" xmlns:ns87="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_SCM_GetSalesOrderForOrderHub_REQUEST/RESTOUTREQ" xmlns:ns82="http://xmlns.oracle.com/cloud/adapter/connectivityproperties/REST/Invoke_SCM_GetSalesOrderForOrderHub_REQUEST/RESTOUTRES" xmlns:ns4="http://xmlns.oracle.com/cloud/adapter/REST/GetAssetDetails_SCM_Invoke_REQUEST" xmlns:ns93="http://TargetNamespace.com/fileReference/StageFile_Read_BIPBILLTOReport" xmlns:nsmpr20="http://xmlns.oracle.com/cloud/adapter/REST/GetSpokeSystemItems_SCM_Invoke_REQUEST/types" version="2.0" xml:id="id_1" exclude-result-prefixes=" ns1 nsmpr0 oraext ns2 xsd errors ns0 sdoXML sdoJava ora tns oracle-xsl-mapper nsmpr1 fn xsl xp20 nssrcmpr sdo nsmpr2 nssrcdfl client nsmpr4 xsi nsmpr5 ignore01" ignore01:ignorexmlids="true">
    <xsl:param name="gSHARE_Input_Param" xml:id="id_131"/>
    <xsl:param name="AssetReportBIP_SCM_Invoke01" xml:id="id_172"/>
    <xsl:param name="AssetReportBIP_SCM_Invoke01_REQUEST" xml:id="id_173"/>
    <xsl:param name="GetSpokeSystemItems_SCM_Invoke" xml:id="id_174"/>
    <xsl:param name="GetSpokeSystemItems_SCM_Invoke_REQUEST" xml:id="id_175"/>
    <xsl:param name="StageFile_Read_BIPSHIPTOReport" xml:id="id_176"/>
    <xsl:param name="StageFile_Write_BIPSHIPTOReport" xml:id="id_177"/>
    <xsl:param name="StageFile_Write_BIPSHIPTOReport_REQUEST" xml:id="id_178"/>
    <xsl:param name="gAssetAPIResponse" xml:id="id_179"/>
    <xsl:param name="gTempAssetRelationship" xml:id="id_180"/>
    <xsl:param name="self" xml:id="id_181"/>
    <xsl:param name="tracking_var_1" xml:id="id_182"/>
    <xsl:param name="tracking_var_2" xml:id="id_183"/>
    <xsl:param name="tracking_var_3" xml:id="id_184"/>
    <xsl:param name="vCheckAssetFlag" xml:id="id_185"/>
    <xsl:param name="vFulfilmentLineID" xml:id="id_186"/>
    <xsl:param name="vGUID_BILLTO" xml:id="id_187"/>
    <xsl:param name="vGUID_SHIPTO" xml:id="id_188"/>
    <xsl:param name="vIntegrationCode" xml:id="id_189"/>
    <xsl:param name="vOIC_Virtual_StagingDir" xml:id="id_190"/>
    <xsl:param name="vRelationshipCount" xml:id="id_191"/>
    <xsl:param name="vStatus" xml:id="id_192"/>
    <xsl:param name="vStatusDescription" xml:id="id_193"/>
    <xsl:template match="/" xml:id="id_11">
        <nstrgmpr:InputParameters xml:id="id_12">
            <xsl:apply-templates select="nstrgmpr:InputParameters/*"/>
        </nstrgmpr:InputParameters>
    </xsl:template>
    <xsl:template match="nstrgmpr:P_INSTALL_BASE_STG">
        <nstrgmpr:P_INSTALL_BASE_STG>
            <xsl:for-each-group select="nstrgmpr:P_INSTALL_BASE_STG_ITEM[nstrgmpr:ORIG_SYS_INSTANCE_REF != '']" group-by="nstrgmpr:FULFILMENT_LINE_ID">
                <xsl:choose>
                    <xsl:when test="count(current-group()) &gt; 1">
                        <xsl:apply-templates select="current-group()[2]/nstrgmpr:RELATIONSHIP_TYPE"/>
                        <xsl:apply-templates select="current-group()[2]/nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF"/>
                        <xsl:copy-of select="." copy-namespaces="no"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:copy-of select="." copy-namespaces="no"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each-group>
        </nstrgmpr:P_INSTALL_BASE_STG>
    </xsl:template>
    <xsl:template match="nstrgmpr:RELATIONSHIP_TYPE"/>
    <xsl:template match="nstrgmpr:ORIG_SYS_PARENT_INSTANCE_REF"/>
</xsl:stylesheet>

使用上述 XSLT 逻辑,我在输出

中得到相同的输入 XML

我已经在下面的编辑器中更新了我的输入和 xslt

https://xsltfiddle.liberty-development.net/bET2rXn/4

https://xsltfiddle.liberty-development.net/bET2rXn/5

   <xsl:template match="@*|node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>
    <xsl:template match="nstrgmpr:P_INSTALL_BASE_STG">
          <nstrgmpr:P_INSTALL_BASE_STG>
                <xsl:for-each-group select="nstrgmpr:P_INSTALL_BASE_STG_ITEM[nstrgmpr:ORIG_SYS_INSTANCE_REF != '']" group-by="nstrgmpr:FULFILMENT_LINE_ID">
                      <xsl:copy-of select="." copy-namespaces="no"/>
                </xsl:for-each-group>
          </nstrgmpr:P_INSTALL_BASE_STG>
    </xsl:template>

可能会让你更接近,很难说,所有的命名空间,长元素名称和长数据是否已经是你想要的结果。我想在您的实际应用程序中,声明的所有命名空间都在别处使用。

如果您希望您的其他模板删除要应用的某些元素,您需要将您的节点推送到它们,例如<xsl:apply-templates select="if (current-group()[2]) then current-group()[2] else ." /> 会将单个项目组的第一个和单个项目以及多个项目组的第二个项目推送到您的模板。