'Sum of a parent element in Subtotal section
I need to replace value '354' in the following expression with the value of the element XPPATH expression is as follows. Assuming that I am iterating through the CustomSubtotals sections.
sum(/M3OutDocument/DataArea/Document/Subdocument/Lines/Line[D6DLIX[.='354'] and D6DLIX=(following-sibling::CustomSubtotals/CustomSubtotal/VFGRB1)]/D6GRWE)
xml used is
<?xml version="1.0" encoding="UTF-8"?>
<M3OutDocument>
<Metadata>
<ZZCONO Label="Company">100</ZZCONO>
<ZZDIVI Label="User division">300</ZZDIVI>
<ZZDATE Label="Start date">2022-04-28</ZZDATE>
<ZZTIME Label="Start time">15:10:07</ZZTIME>
<ZZUSER Label="User">JLOPES</ZZUSER>
<ZZBJNO Label="Job no">886934913093804063</ZZBJNO>
<ZZPRTF Label="Printer file">DRS672PF</ZZPRTF>
<ZZFILE Label="File name">886934913093804063DRS672PF_0</ZZFILE>
<ZZSIID Label="Service ID">M3_IDM_XML</ZZSIID></Metadata>
<DataArea>
<Document>
<ZZPRTF Label="Printer file">DRS672PF</ZZPRTF>
<ZZXMLT Label="Variant">02</ZZXMLT>
<ZZXMLD Label="XML variant des">MANIFEST</ZZXMLD>
<ZZCSVN Label="Country version">AU</ZZCSVN>
<Formatting>
<M3StandardFormatVersion>1</M3StandardFormatVersion>
<ReportLayout>CUS_STD_02-01</ReportLayout>
<Structure>CUS_STD_02-01</Structure>
<PaperSize></PaperSize>
<Localization>
<DocumentDivision>300</DocumentDivision>
<CountryVersion>AU</CountryVersion>
<BaseCountry>AU</BaseCountry>
<FromToCountry>AU</FromToCountry>
<DocumentLanguage>GB</DocumentLanguage>
<Locale>en-AU</Locale>
<DateFormat>DDMMYY</DateFormat>
<DecimalFormat>.</DecimalFormat>
<ThousandSeparator>,</ThousandSeparator></Localization>
<DocumentInformation>
<DebitCreditCodeUsed>false</DebitCreditCodeUsed></DocumentInformation></Formatting>
<Header Label="Header">
<CCPHNO Label="Telephone">TEST 123</CCPHNO>
<CCCWEB Label="Company website"></CCCWEB>
<Custom>
<CCTFNO Label="Facsimile"></CCTFNO></Custom>
<Address Label="Company address" Type="Company">
<VFCUNM>Sunbeam Foods Pty Ltd</VFCUNM>
<VFADR1>1 Waltham Avenue</VFADR1>
<VFADR2></VFADR2>
<VFADR3></VFADR3>
<VFADR4>Irymple Victoria 3498</VFADR4>
<Custom>
<CCVRNO Label="A.B.N.">84004122114</CCVRNO>
<ZZ7020>Customer Service:</ZZ7020>
<ZZ7030>Phone: 1800 673 310</ZZ7030>
<ZZ7040>Fax: 1800 814 896</ZZ7040>
<ZZ7050>Pick up from:</ZZ7050></Custom></Address></Header>
<DocumentHeader Label="Document header">
<D6CONN Label="Shipment No:">1000178</D6CONN>
<VFDATE Label="Entry date">2022-04-28</VFDATE>
<D6E0B4 Label="Transp ID dep"></D6E0B4>
<D6FWNO Label="Carrier">6111</D6FWNO>
<D6TRCA Label="Transp equipmnt">NA</D6TRCA>
<IDSUNM Label="Supplier name">PICKERING TRANSPORT GROUP</IDSUNM>
<VFAGRW Label="Gross weight">4708.400</VFAGRW>
<VFAPAC Label="No. packages">6</VFAPAC>
<VFRO15 Label="Route:">SBF to CCC NDC</VFRO15>
<VFDSDT Label="Despatch Date:">2022-03-23</VFDSDT>
<VFDSHM Label="Departure time">17:00:00</VFDSHM>
<VFFRCM Label="F u/m">0.000</VFFRCM>
<Custom>
<ZZ7010>Your Reference</ZZ7010>
<ZZ7020>Total Packages</ZZ7020>
<ZZ7030>Document Print Date:</ZZ7030>
<ZZ7040>Total Loading Weight/KG:</ZZ7040>
<ZZ7050>Total Weight/KG(Incl Packaging):</ZZ7050>
<ZZ7060>Total No. of Deliveries:</ZZ7060>
<ZZ7070>TNT Pallecons:</ZZ7070>
<ZZ7080>Chep Plastic:</ZZ7080>
<ZZ7090>Plain Export:</ZZ7090>
<ZZ7100>Blue Bins:</ZZ7100>
<ZZ7110>Nil Pallets:</ZZ7110>
<ZZ7120>Pallecons:</ZZ7120>
<ZZ7130>Plain Pallets:</ZZ7130>
<ZZ7140>Loscam Pallets:</ZZ7140>
<ZZ7150>Chep Pallets:</ZZ7150>
<ZACUOR Label="Customer's ord">10007926V</ZACUOR>
<ZAYREF Label="Your ref 1">20190730-0000-</ZAYREF></Custom></DocumentHeader>
<Subdocument Label="Subdocument">
<Lines Label="Lines">
<D6DLIX Label="Corr del number"></D6DLIX>
<D6FRCM Label="F u/m"></D6FRCM>
<D6GRWE Label="Gross wt"></D6GRWE>
<D6LODO Label="Load platform"></D6LODO>
<D6PACT Label="Pckgng"></D6PACT>
<D6PANR Label="Package no"></D6PANR>
<D6VOL3 Label="Volume"></D6VOL3>
<D6CUNM Label="Name"></D6CUNM>
<D6ORNO Label="CO no"></D6ORNO>
<OACUOR Label="Customer's ord"></OACUOR>
<Line>
<D6DLIX>354</D6DLIX>
<D6FRCM>0.000</D6FRCM>
<D6GRWE>936.1</D6GRWE>
<D6LODO></D6LODO>
<D6PACT>SSCC</D6PACT>
<D6PANR>393101620064185492</D6PANR>
<D6VOL3>2.000</D6VOL3>
<D6CUNM>SUNBEAM FOODS TRUGANINA</D6CUNM>
<Custom>
<D6ORNO>1000000055</D6ORNO>
<OACUOR>10007926V</OACUOR></Custom>
<Address Label="Customer address" Type="Customer">
<VFCUNO Label="Customer"></VFCUNO>
<VFCUNM>SUNBEAM FOODS TRUGANINA</VFCUNM>
<VFADR1>154 FOUNDATION ROAD</VFADR1>
<VFADR2>TRUGANINA VIC 3029</VFADR2>
<VFADR3></VFADR3>
<VFADR4></VFADR4></Address>
<LineTable Label="Line Details" Type="Details">
<VFCS15 Label="Country"></VFCS15>
<VFED15 Label="Place"></VFED15>
<Line>
<VFCS15>Australia</VFCS15>
<VFED15>SBF Truganina</VFED15></Line></LineTable></Line>
<Line>
<D6DLIX>354</D6DLIX>
<D6FRCM>0.000</D6FRCM>
<D6GRWE>936.2</D6GRWE>
<D6LODO></D6LODO>
<D6PACT>SSCC</D6PACT>
<D6PANR>393101620064185508</D6PANR>
<D6VOL3>2.000</D6VOL3>
<D6CUNM>SUNBEAM FOODS TRUGANINA</D6CUNM>
<Custom>
<D6ORNO>1000000055</D6ORNO>
<OACUOR>10007926V</OACUOR></Custom></Line>
<Line>
<D6DLIX>366</D6DLIX>
<D6FRCM>0.000</D6FRCM>
<D6GRWE>936.3</D6GRWE>
<D6LODO></D6LODO>
<D6PACT>SSCC</D6PACT>
<D6PANR>393101620064185638</D6PANR>
<D6VOL3>2.000</D6VOL3>
<D6CUNM>SUNBEAM FOODS TRUGANINA</D6CUNM>
<Custom>
<D6ORNO>1000000057</D6ORNO>
<OACUOR>0104312434</OACUOR></Custom></Line>
<Line>
<D6DLIX>366</D6DLIX>
<D6FRCM>0.000</D6FRCM>
<D6GRWE>936.4</D6GRWE>
<D6LODO></D6LODO>
<D6PACT>SSCC</D6PACT>
<D6PANR>393101620064185645</D6PANR>
<D6VOL3>2.000</D6VOL3>
<D6CUNM>SUNBEAM FOODS TRUGANINA</D6CUNM>
<Custom>
<D6ORNO>1000000057</D6ORNO>
<OACUOR>0104312434</OACUOR></Custom></Line>
<Line>
<D6DLIX>436</D6DLIX>
<D6FRCM>0.000</D6FRCM>
<D6GRWE>480.5</D6GRWE>
<D6LODO></D6LODO>
<D6PACT>SSCC</D6PACT>
<D6PANR>393101620064186185</D6PANR>
<D6VOL3>2.000</D6VOL3>
<D6CUNM>SUNBEAM FOODS TRUGANINA</D6CUNM>
<Custom>
<D6ORNO>1000000076</D6ORNO>
<OACUOR>10007926V</OACUOR></Custom></Line>
<Line>
<D6DLIX>436</D6DLIX>
<D6FRCM>0.000</D6FRCM>
<D6GRWE>480.6</D6GRWE>
<D6LODO></D6LODO>
<D6PACT>SSCC</D6PACT>
<D6PANR>393101620064186192</D6PANR>
<D6VOL3>2.000</D6VOL3>
<D6CUNM>SUNBEAM FOODS TRUGANINA</D6CUNM>
<Custom>
<D6ORNO>1000000076</D6ORNO>
<OACUOR>10007926V</OACUOR></Custom></Line>
<CustomSubtotals>
<VFGRB1 Label="Dely no"></VFGRB1>
<VFGRB2 Label="Pckgng"></VFGRB2>
<VFGRB3 Label="Name"></VFGRB3>
<VFTOT2 Label="Volume"></VFTOT2>
<CustomSubtotal>
<VFGRB1>354</VFGRB1>
<VFGRB2>SSCC</VFGRB2>
<VFGRB3>SUNBEAM FOODS TRUGANINA</VFGRB3>
<VFTOT2>4.00</VFTOT2></CustomSubtotal>
<CustomSubtotal>
<VFGRB1>366</VFGRB1>
<VFGRB2>SSCC</VFGRB2>
<VFGRB3>SUNBEAM FOODS TRUGANINA</VFGRB3>
<VFTOT2>4.00</VFTOT2></CustomSubtotal>
<CustomSubtotal>
<VFGRB1>436</VFGRB1>
<VFGRB2>SSCC</VFGRB2>
<VFGRB3>SUNBEAM FOODS TRUGANINA</VFGRB3>
<VFTOT2>4.00</VFTOT2></CustomSubtotal></CustomSubtotals></Lines></Subdocument>
<Media>
<Mail>
<ToMail>[email protected]</ToMail>
<FromMail>[email protected]</FromMail>
<Subject>BFG TST | PO ETA:</Subject>
<Archive>false</Archive>
<ReportFileType>PDF</ReportFileType></Mail></Media></Document></DataArea></M3OutDocument>
---------
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
