I have to pick value from one loop and use it as key to sum the quantity. At the end we should add the totals of each loop.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.051/Fulfill.dtd">
<cXML payloadID="16314uu19eii6-765h52u1pp0.162.97.178" timestamp="2021-10-06T02:54:24-07:00" version="1.2.051" xml:lang="en-PL">
<Request deploymentMode="test">
<ShipNoticeRequest>
<ShipNoticePortion>
<OrderReference orderDate="2021-10-05T05:00:00-07:00" orderID="4500005482a">
<DocumentReference payloadID="4pr7uurwyjjjoyyj59iikk5j869900u61"></DocumentReference>
</OrderReference>
<ShipNoticeItem shipNoticeLineNumber="1" lineNumber="10" quantity="60">
<ItemID>
<SupplierPartID></SupplierPartID>
<BuyerPartID>MJBR003</BuyerPartID>
</ItemID>
<ShipNoticeItemDetail>
<UnitPrice>
<Money currency="USD">0.1</Money>
</UnitPrice>
<Description xml:lang="en-US">Sugar White 2lb</Description>
<UnitOfMeasure>EA</UnitOfMeasure>
</ShipNoticeItemDetail>
<UnitOfMeasure>EA</UnitOfMeasure>
<Packaging>
<PackagingCode xml:lang="en-US">SPACINGCARTON</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="10000.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Spacing Carton</Description>
<PackagingLevelCode>auxiliary</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>SPACINGCARTON</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCodeReference>60003629</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="3.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">2</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">1</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US"></PackagingCode>
<Dimension type="grossWeight" quantity="40.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="40.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Test Pallet 001</Description>
<PackagingLevelCode>1</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBPALLET001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003629</ShippingContainerSerialCode>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="3.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">1</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId"></Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">SPACINGCARTON</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1000.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Spacing Carton</Description>
<PackagingLevelCode>auxiliary</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>SPACINGCARTON</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCodeReference>60003630</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="1.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">4</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">3</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003630</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003629</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">3</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">1</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">SPACINGCARTON</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1000.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Spacing Carton</Description>
<PackagingLevelCode>auxiliary</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>SPACINGCARTON</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCodeReference>60003631</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="1.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">6</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">5</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003631</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003629</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">5</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">1</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">SPACINGCARTON</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1000.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Spacing Carton</Description>
<PackagingLevelCode>auxiliary</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>SPACINGCARTON</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCodeReference>60003632</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="1.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">8</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">7</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003632</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003629</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">7</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">1</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
</ShipNoticeItem>
<ShipNoticeItem shipNoticeLineNumber="2" lineNumber="20" quantity="120">
<ItemID>
<SupplierPartID></SupplierPartID>
<BuyerPartID>MJBR003</BuyerPartID>
</ItemID>
<ShipNoticeItemDetail>
<UnitPrice>
<Money currency="USD">0.1</Money>
</UnitPrice>
<Description xml:lang="en-US">Sugar White 2lb</Description>
<UnitOfMeasure>EA</UnitOfMeasure>
</ShipNoticeItemDetail>
<UnitOfMeasure>EA</UnitOfMeasure>
<Packaging>
<PackagingCode xml:lang="en-US">SPACINGCARTON</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="10000.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Spacing Carton</Description>
<PackagingLevelCode>auxiliary</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>SPACINGCARTON</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCodeReference>60003633</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="6.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">10</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">9</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US"></PackagingCode>
<Dimension type="grossWeight" quantity="40.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="40.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Test Pallet 001</Description>
<PackagingLevelCode>1</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBPALLET001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003633</ShippingContainerSerialCode>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="5.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">9</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId"></Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003634</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003633</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">11</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">9</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003635</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003633</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">12</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">9</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003636</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003633</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">13</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">9</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003637</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003633</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">14</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">9</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003638</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003633</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">15</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">9</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">SPACINGCARTON</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1000.0">
<UnitOfMeasure>LB</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">Spacing Carton</Description>
<PackagingLevelCode>auxiliary</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>SPACINGCARTON</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCodeReference>60003640</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="2.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">18</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">17</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US">MJBR003</PackagingCode>
<Dimension type="grossWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="1.0">
<UnitOfMeasure>LBR</UnitOfMeasure>
</Dimension>
<Description type="Material" xml:lang="en-US">Test Carton 001</Description>
<PackagingLevelCode>2</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>MBCARTON001</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003640</ShippingContainerSerialCode>
<ShippingContainerSerialCodeReference>60003639</ShippingContainerSerialCodeReference>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="20.0">
<UnitOfMeasure>EA</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">17</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId">16</Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex">1.0</Extrinsic>
</Packaging>
<Packaging>
<PackagingCode xml:lang="en-US"></PackagingCode>
<Dimension type="grossWeight" quantity="15.0">
<UnitOfMeasure>KGM</UnitOfMeasure>
</Dimension>
<Dimension type="unitNetWeight" quantity="15.0">
<UnitOfMeasure>KGM</UnitOfMeasure>
</Dimension>
<Description type="Package" xml:lang="en-US">SCC HU Demo Pallet</Description>
<PackagingLevelCode>1</PackagingLevelCode>
<PackageTypeCodeIdentifierCode>SCC_HU_PALLET</PackageTypeCodeIdentifierCode>
<ShippingContainerSerialCode>60003639</ShippingContainerSerialCode>
<PackageID></PackageID>
<OrderedQuantity quantity="60.0">
<UnitOfMeasure>PCE</UnitOfMeasure>
</OrderedQuantity>
<DispatchQuantity quantity="1.0">
<UnitOfMeasure>PCE</UnitOfMeasure>
</DispatchQuantity>
<Extrinsic name="AribaNetwork.packId">16</Extrinsic>
<Extrinsic name="AribaNetwork.parentPackId"></Extrinsic>
<Extrinsic name="AribaNetwork.mixedInstruction">false</Extrinsic>
<Extrinsic name="AribaNetwork.shipNoticeLineIndex"></Extrinsic>
</Packaging>
</ShipNoticeItem>
</ShipNoticePortion>
</ShipNoticeRequest>
</Request>
</cXML>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:dew="com.ariba.microservices.anuiextensions.service.data.ANDataCxmlExtension"
xmlns:dew1="com.ariba.microservices.scm.micro.serivce.data.ANDataCxmlExtension"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:barcode="http://barcode4j.krysalis.org/ns"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
>
<xsl:output method="xml" indent="yes" />
<xsl:decimal-format name="generalFormat" grouping-separator="," decimal-separator="." />
<xsl:template match="/" name="Barcode">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="ManufacturLabelSize-first" page-height="297mm" page-width="210mm" margin-top="25.4mm" margin-right="25.4mm" margin-left="25.4mm" margin-bottom="25.4mm">
<fo:region-body margin-top="15mm" />
<fo:region-before />
<fo:region-after />
</fo:simple-page-master>
<fo:simple-page-master master-name="ManufacturLabelSize-rest" page-height="297mm" page-width="210mm" margin-top="25.4mm" margin-right="25.4mm" margin-left="25.4mm" margin-bottom="25.4mm">
<fo:region-body margin-top="15mm"/>
<fo:region-before />
<fo:region-after />
</fo:simple-page-master>
<fo:page-sequence-master master-name="ManufacturLabelSize-portrait">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="ManufacturLabelSize-first"
page-position="first"/>
<fo:conditional-page-master-reference master-reference="ManufacturLabelSize-rest"
page-position="rest"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="ManufacturLabelSize-portrait" id="pSeqID">
<fo:flow flow-name="xsl-region-body">
<fo:table>
<fo:table-body border="solid" border-width="0.5pt">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:call-template name="ShippinglineNew"></xsl:call-template>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template name="ShippinglineNew" >
<fo:table border-style="solid" border-width="1pt" >
<fo:table-body >
<xsl:apply-templates
select="cXML/Request/ShipNoticeRequest/ShipNoticePortion/ShipNoticeItem"/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template match="ShipNoticeItem" name="PalletNew8">
<xsl:for-each select="Packaging[PackagingLevelCode='1']">
<fo:table-row>
<fo:table-cell start-indent="0.02in" >
<xsl:variable name="packId">
<xsl:value-of select="Extrinsic[@name="AribaNetwork.packId"]"/>
</xsl:variable>
<xsl:variable name="pack2key">
<xsl:for-each select="ancestor::ShipNoticeItem/Packaging[PackagingLevelCode='2'][Extrinsic[@name="AribaNetwork.parentPackId"]=$packId]">
<xsl:variable name="One">
<xsl:value-of select="Extrinsic[@name="AribaNetwork.packId"]"/>
</xsl:variable>
<xsl:call-template name="TotalAmtAuxiliaryPack2">
<xsl:with-param name="nodes" select="ancestor::ShipNoticeItem/Packaging[PackagingLevelCode='auxiliary'][Extrinsic[@name="AribaNetwork.parentPackId"]=$One]"/>
</xsl:call-template>
</xsl:for-each>
</xsl:variable>
<fo:block>
Auxiliary Gross weight: <xsl:value-of select="$pack2key"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:template>
<xsl:template name="TotalAmtAuxiliary">
<xsl:param name="nodes"/>
<xsl:param name="sum" select="0" />
<xsl:variable name="current" select="$nodes[1]" />
<xsl:if test="$current">
<xsl:call-template name="TotalAmtAuxiliary">
<xsl:with-param name="nodes" select="$nodes[position() > 1]" />
<xsl:with-param name="sum" select="$sum $current/DispatchQuantity/@quantity " />
</xsl:call-template>
</xsl:if>
<xsl:if test="not($current)">
<xsl:value-of select="$sum" />
</xsl:if>
</xsl:template>
<xsl:template name="TotalAmtAuxiliaryPack2">
<xsl:param name="nodes"/>
<xsl:param name="sum" select="0" />
<xsl:variable name="current" select="$nodes[1]" />
<xsl:if test="$current">
<xsl:call-template name="TotalAmtAuxiliaryPack2">
<xsl:with-param name="nodes" select="$nodes[position() > 1]" />
<xsl:with-param name="sum" select="$sum $current/DispatchQuantity/@quantity * $current/Dimension[@type='unitNetWeight']/@quantity" />
</xsl:call-template>
</xsl:if>
<xsl:if test="not($current)">
<xsl:value-of select="$sum" />
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Current output:
Auxiliary Gross weight:100010001000
Auxiliary Gross weight:00000
Auxiliary Gross weight:2000
Expected output:
Auxiliary Gross weight:3000
Auxiliary Gross weight:00000
Auxiliary Gross weight:2000
Please help to solve!
CodePudding user response:
In XSLT 2 or 3 (as supported through Saxon 9 or 10 or Saxon-JS 2) you could use
<xsl:key name="ref-2-by-ariba" match="ShipNoticeItem/Packaging[PackagingLevelCode='2']" use="Extrinsic[@name = 'AribaNetwork.parentPackId']"/>
<xsl:key name="auxilia-by-ariba" match="ShipNoticeItem/Packaging[PackagingLevelCode='auxiliary']" use="Extrinsic[@name = 'AribaNetwork.parentPackId']"/>
<xsl:template match="ShipNoticeItem" name="PalletNew8">
<xsl:for-each select="Packaging[PackagingLevelCode='1']">
<fo:table-row>
<fo:table-cell start-indent="0.02in" >
<xsl:variable name="packId" select="Extrinsic[@name = 'AribaNetwork.packId']"/>
<fo:block>
Auxiliary Gross weight: <xsl:value-of select="sum(key('auxilia-by-ariba', key('ref-2-by-ariba', $packId)/Extrinsic[@name = 'AribaNetwork.packId'])/(DispatchQuantity/@quantity * Dimension[@type = 'unitNetWeight']/@quantity))"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:template>
In XSLT 1 you could use the same two keys but then call your template
<xsl:template match="ShipNoticeItem" name="PalletNew8">
<xsl:for-each select="Packaging[PackagingLevelCode='1']">
<fo:table-row>
<fo:table-cell start-indent="0.02in" >
<xsl:variable name="packId" select="Extrinsic[@name = 'AribaNetwork.packId']"/>
<fo:block>
Auxiliary Gross weight: <xsl:call-template name="TotalAmtAuxiliaryPack2">
<xsl:with-param name="nodes" select="key('auxilia-by-ariba', key('ref-2-by-ariba', $packId)/Extrinsic[@name = 'AribaNetwork.packId'])"/>
</xsl:call-template>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:template>