Hallo,
hätte mit folg. Part versucht die Duplikate unter "ItemDeliveryInformation" zu entfernen.
<xsl:key name="packing_slip" match="ItemDeliveryInformation" use="concat(LineNumDeliveryNote, '|', PackingSlipId, '|', DeliveryDate, '|', DeliveredQuantity, '|', RecId_InventTrans)"/>
<xsl:template match="ItemDeliveryInformation[generate-id() != generate-id(key('packing_slip', concat(LineNumDeliveryNote, '|', PackingSlipId, '|', DeliveryDate, '|', DeliveredQuantity, '|', RecId_InventTrans))[1])]" />
Jedoch muss ich weiters, das daraus entstandene Ergebnis zusammenzählen.
Dies wurde wie folgt gelöst:
<xsl:key name="group" match="ItemDeliveryInformation" use="concat(LineNumDeliveryNote, PackingSlipId, DeliveryDate)"/>
<xsl:template match="ItemDeliveryInformation">
<xsl:for-each select="current()[generate-id() = generate-id(key('group', concat(LineNumDeliveryNote, PackingSlipId, DeliveryDate))[1])]">
<ItemDeliveryInformation>
<xsl:copy-of select="LineNumDeliveryNote"/>
<xsl:copy-of select="PackingSlipId"/>
<xsl:copy-of select="DeliveryDate"/>
<DeliveredQuantity>
<xsl:value-of select="format-number(sum(key('group', concat(LineNumDeliveryNote, PackingSlipId, DeliveryDate))/DeliveredQuantity), '#.00')"/>
</DeliveredQuantity>
</ItemDeliveryInformation>
</xsl:for-each>
</xsl:template>
XML:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SALESINVOICE>
<Interchange>
<Interchange_Control_Number>5637372751</Interchange_Control_Number>
</Interchange>
<HeaderInformation>
<OrigInvoiceNumber>1</OrigInvoiceNumber>
</HeaderInformation>
<LineInformation>
<Item>
<LineNum>10</LineNum>
<GTIN>1234</GTIN>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378733</RecId_InventTrans>
<ShipFromAddressInformation />
</ItemDeliveryInformation>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378716</RecId_InventTrans>
</ItemDeliveryInformation>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378733</RecId_InventTrans>
</ItemDeliveryInformation>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378716</RecId_InventTrans>
</ItemDeliveryInformation>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378733</RecId_InventTrans>
</ItemDeliveryInformation>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378716</RecId_InventTrans>
</ItemDeliveryInformation>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378733</RecId_InventTrans>
</ItemDeliveryInformation>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>18.00</DeliveredQuantity>
<RecId_InventTrans>5644378716</RecId_InventTrans>
</ItemDeliveryInformation>
</Item>
</LineInformation>
</SALESINVOICE>
XSLT:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:strip-space elements="*" />
<xsl:key name="packing_slip" match="ItemDeliveryInformation" use="concat(LineNumDeliveryNote, '|', PackingSlipId, '|', DeliveryDate, '|', DeliveredQuantity, '|', RecId_InventTrans)"/>
<xsl:key name="group" match="ItemDeliveryInformation" use="concat(LineNumDeliveryNote, PackingSlipId, DeliveryDate)"/>
<!-- 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="ItemDeliveryInformation[generate-id() != generate-id(key('packing_slip', concat(LineNumDeliveryNote, '|', PackingSlipId, '|', DeliveryDate, '|', DeliveredQuantity, '|', RecId_InventTrans))[1])]" />
<xsl:template match="ItemDeliveryInformation">
<xsl:for-each select="current()[generate-id() = generate-id(key('group', concat(LineNumDeliveryNote, PackingSlipId, DeliveryDate))[1])]">
<ItemDeliveryInformation>
<xsl:copy-of select="LineNumDeliveryNote"/>
<xsl:copy-of select="PackingSlipId"/>
<xsl:copy-of select="DeliveryDate"/>
<DeliveredQuantity>
<xsl:value-of select="format-number(sum(key('group', concat(LineNumDeliveryNote, PackingSlipId, DeliveryDate))/DeliveredQuantity), '#.00')"/>
</DeliveredQuantity>
</ItemDeliveryInformation>
</xsl:for-each>
</xsl:template>
<!-- delete empty nodes -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="ItemDeliveryInformation/RecId_InventTrans"/>
<xsl:template match="*[not(@*|*|comment()|processing-instruction()) and normalize-space()='']"/>
</xsl:stylesheet>
Ergebnis sollte sein: -> DeliveredQuantity mit Menge 36
<?xml version="1.0" encoding="UTF-8"?>
<SALESINVOICE>
<Interchange>
<Interchange_Control_Number>5637372751</Interchange_Control_Number>
</Interchange>
<HeaderInformation>
<OrigInvoiceNumber>1</OrigInvoiceNumber>
</HeaderInformation>
<LineInformation>
<Item>
<LineNum>10</LineNum>
<GTIN>1234</GTIN>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>36.00</DeliveredQuantity>
</ItemDeliveryInformation>
</Item>
</LineInformation>
</SALESINVOICE>
Derzeit jedoch: -> Falsche Menge DeliveredQuantity 144
<?xml version="1.0" encoding="UTF-8"?>
<SALESINVOICE>
<Interchange>
<Interchange_Control_Number>5637372751</Interchange_Control_Number>
</Interchange>
<HeaderInformation>
<OrigInvoiceNumber>1</OrigInvoiceNumber>
</HeaderInformation>
<LineInformation>
<Item>
<LineNum>10</LineNum>
<GTIN>1234</GTIN>
<ItemDeliveryInformation>
<LineNumDeliveryNote>10</LineNumDeliveryNote>
<PackingSlipId>LS-0000224</PackingSlipId>
<DeliveryDate>2021-02-01</DeliveryDate>
<DeliveredQuantity>144.00</DeliveredQuantity>
</ItemDeliveryInformation>
</Item>
</LineInformation>
</SALESINVOICE>
Danke & LG Julian