juls_pro_37: XSLT 1.0 Löschen eines Knotens

Hi,

würde gerne den gesamten Knoten "ItemDeliveryInformation" löschen, wenn die ItemDeliveryInformation/InvoiceNumber ungleich der HeaderInformation/InvoiceNumber ist.

Was mache ich hier falsch?

XML:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SALESINVOICE>
  <Interchange>    
    <Interchange_Control_Number>5637258642</Interchange_Control_Number>
  </Interchange>
  <HeaderInformation>    
    <InvoiceNumber>INV0000442</InvoiceNumber>    
  </HeaderInformation>
  <LineInformation>
    <Item>
      <LineNum>1</LineNum>     
      <ItemDeliveryInformation>
        <InvoiceNumber>INV0000442</InvoiceNumber>
        <LineNumDeliveryNote>12</LineNumDeliveryNote>
        <PackingSlipId>PAC0000258</PackingSlipId>
        <DeliveryDate>2020-02-20</DeliveryDate>
        <DeliveredQuantity>200.00</DeliveredQuantity>
      </ItemDeliveryInformation>
      <ItemDeliveryInformation>
        <InvoiceNumber>INV0000441</InvoiceNumber>
        <LineNumDeliveryNote>12</LineNumDeliveryNote>
        <PackingSlipId>PAC0000258</PackingSlipId>
        <DeliveryDate>2020-02-20</DeliveryDate>
        <DeliveredQuantity>300.00</DeliveredQuantity>
      </ItemDeliveryInformation>
    </Item>
    <Item>
      <LineNum>2</LineNum>     
      <ItemDeliveryInformation>
        <InvoiceNumber>INV0000442</InvoiceNumber>
        <LineNumDeliveryNote>12</LineNumDeliveryNote>
        <PackingSlipId>PAC0000258</PackingSlipId>
        <DeliveryDate>2020-02-20</DeliveryDate>
        <DeliveredQuantity>200.00</DeliveredQuantity>
      </ItemDeliveryInformation>
      <ItemDeliveryInformation>
        <InvoiceNumber>INV0000441</InvoiceNumber>
        <LineNumDeliveryNote>12</LineNumDeliveryNote>
        <PackingSlipId>PAC0000258</PackingSlipId>
        <DeliveryDate>2020-02-20</DeliveryDate>
        <DeliveredQuantity>300.00</DeliveredQuantity>
      </ItemDeliveryInformation>
    </Item>
  </LineInformation>  
</SALESINVOICE>

XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" standalone="yes" indent="yes"/>
  <xsl:strip-space elements="*" />

<xsl:template match="ItemDeliveryInformation[InvoiceNumber != HeaderInformation/InvoiceNumber]"/>
  
 <!-- Identity-Template für die nicht explizit benannten Elemente -->
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>  

 <xsl:template match="*[not(@*|*|comment()|processing-instruction()) and normalize-space()='']"/>

</xsl:stylesheet>
  1. Hallo Julian,

    würde gerne den gesamten Knoten "ItemDeliveryInformation" löschen, wenn die ItemDeliveryInformation/InvoiceNumber ungleich der HeaderInformation/InvoiceNumber ist.

    Was mache ich hier falsch?

    Richtigen Bezug zu HeaderInformation herstellen:

    <xsl:template match="ItemDeliveryInformation[InvoiceNumber
      != //HeaderInformation/InvoiceNumber]"/>
    

    ODER

    <xsl:template match="ItemDeliveryInformation[InvoiceNumber
      != /SALESINVOICE/HeaderInformation/InvoiceNumber]"/>
    
    

    Grüße,
    Thomas

    1. vielen vielen Dank!!

      LG Julian