У меня есть исходный XML-файл, который мне нужно распаковать в более структурированный XML, чтобы впоследствии я мог обработать его как набор данных.
Я пробовал многочисленные методы с помощью apply-templates и for-eachкоманды, но всегда, кажется, не хватает.
Мне нужно уточнить связь между элементами.Начиная с самого глубокого элемента, элемента BookingDetail, он должен быть дочерним по отношению к элементу BookingHeader, только если его элемент равен элементу BookingHeader.Затем, поднимаясь по цепочке, элемент BookingHeader будет отображаться как дочерний элемент ManifestBooking только в том случае, если их два равны.И, наконец, элемент ManifestBooking должен отображаться как дочерний элемент Manifest, только если их два равны.
Любая помощь будет высоко ценится.
Исходный файл:
<?xml version="1.0" encoding="UTF-8"?>
<ShipmentInformation xmlns="http://www.tranxml.org/TranXML/Version4.0" Transaction="Actual">
<GeneralShipmentInformation>
<TransactionSetPurposeCode>00</TransactionSetPurposeCode>
<TransportationMethodTypeCode>L</TransportationMethodTypeCode>
<ShipmentMethodOfPayment>DE</ShipmentMethodOfPayment>
<ShipmentIdentificationNumber>918072</ShipmentIdentificationNumber>
<StandardCarrierAlphaCode>NUNCRR</StandardCarrierAlphaCode>
</GeneralShipmentInformation>
<Priority>0</Priority>
<DateTimeReference SegmentId="StartTime">
<Date>2010-11-05</Date>
<Time>00:00:00</Time>
</DateTimeReference>
<Origin>
<GeographicLocation>
<LocationIdentifier>NUN</LocationIdentifier>
</GeographicLocation>
</Origin>
<Destination>
<GeographicLocation>
<LocationIdentifier>SSS BARGAIN BUILDERS SUPP P/L</LocationIdentifier>
</GeographicLocation>
</Destination>
<EquipmentDetailsLoop>
<EquipmentDetails>
<EquipmentStructure>
<Initial/>
<EquipmentNumber>Z48GW</EquipmentNumber>
<DescriptionCode>TV</DescriptionCode>
</EquipmentStructure>
</EquipmentDetails>
</EquipmentDetailsLoop>
<EquipmentDetailsLoop>
<EquipmentDetails>
<EquipmentStructure>
<Initial/>
<EquipmentNumber>B50KX</EquipmentNumber>
<DescriptionCode>TL</DescriptionCode>
</EquipmentStructure>
</EquipmentDetails>
</EquipmentDetailsLoop>
<EquipmentDetailsLoop>
<EquipmentDetails>
<EquipmentStructure>
<Initial/>
<EquipmentNumber>B60KX</EquipmentNumber>
<DescriptionCode>TL</DescriptionCode>
</EquipmentStructure>
</EquipmentDetails>
</EquipmentDetailsLoop>
<EquipmentDetailsLoop>
<EquipmentDetails>
<EquipmentStructure>
<Initial/>
<EquipmentNumber>B70KX</EquipmentNumber>
<DescriptionCode>TL</DescriptionCode>
</EquipmentStructure>
</EquipmentDetails>
</EquipmentDetailsLoop>
<EquipmentDetailsLoop>
<EquipmentDetails>
<EquipmentStructure>
<Initial/>
<EquipmentNumber>B80KX</EquipmentNumber>
<DescriptionCode>TL</DescriptionCode>
</EquipmentStructure>
</EquipmentDetails>
</EquipmentDetailsLoop>
<ManifestSourceBD xmlns:version4="http://www.tranxml.org/TranXML/Version4.0">
<DSBookingDetail>
<SeqNo>1</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/040</OrderNo>
<SSCC>193168810020083905</SSCC>
<Description>RIDGE CAP ROLL TOP.42 X 390MM DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>25</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>2</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/040</OrderNo>
<SSCC>193168810020083912</SSCC>
<Description>RIDGE CAP ROLL TOP.42 X 390MM DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>25</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>3</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/040</OrderNo>
<SSCC>193168810020083929</SSCC>
<Description>RIDGE CAP ROLL TOP.42 X 390MM DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>17</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>4</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/010</OrderNo>
<SSCC>193168810020115484</SSCC>
<Description>CUSTOM ORB.42 DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>484</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>5</SeqNo>
<LineType>Product</LineType>
<BookingNo>3</BookingNo>
<OrderNo>CAM/074082/010</OrderNo>
<SSCC>193168810020115491</SSCC>
<Description>CUSTOM ORB.42 DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>487</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>6</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/010</OrderNo>
<SSCC>193168810020115507</SSCC>
<Description>CUSTOM ORB.42 DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>274</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>7</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/010</OrderNo>
<SSCC>193168810380969598</SSCC>
<Description>CUSTOM ORB.42 DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>149</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>8</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/020</OrderNo>
<SSCC>193168810380969604</SSCC>
<Description>CUSTOM ORB.42 SANDBANK</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>312</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>9</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/030</OrderNo>
<SSCC>193168810380969611</SSCC>
<Description>VALLEY GUTTER.42 390MM DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>11</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>10</SeqNo>
<LineType>Product</LineType>
<BookingNo>1</BookingNo>
<OrderNo>CAM/074082/040</OrderNo>
<SSCC>193168810380969628</SSCC>
<Description>RIDGE CAP ROLL TOP.42 X 390MM DEEP OCEAN</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>17</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>11</SeqNo>
<LineType>Product</LineType>
<BookingNo>2</BookingNo>
<OrderNo>NUN/017553/010</OrderNo>
<SSCC>193168810020081963</SSCC>
<Description>CUSTOM ORB.42 PAPERBARK</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>279</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>12</SeqNo>
<LineType>Product</LineType>
<BookingNo>2</BookingNo>
<OrderNo>NUN/017553/020</OrderNo>
<SSCC>193168810020081970</SSCC>
<Description>QUAD GUTTER HI 115 PAPERBARK (PLAIN)</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>6</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>13</SeqNo>
<LineType>Product</LineType>
<BookingNo>2</BookingNo>
<OrderNo>NUN/017553/070</OrderNo>
<SSCC>193168810020082021</SSCC>
<Description>UC UNIVERSAL CAP PAPERBARK</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>13</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>14</SeqNo>
<LineType>Product</LineType>
<BookingNo>2</BookingNo>
<OrderNo>CAM/074112/010</OrderNo>
<SSCC>193168810380973892</SSCC>
<Description>QUAD GUTTER HI 115 CLASSIC CREAM (PLAIN)</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>6</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>15</SeqNo>
<LineType>Product</LineType>
<BookingNo>3</BookingNo>
<OrderNo>CAM/074112/050</OrderNo>
<SSCC>193168810380973939</SSCC>
<Description>CUSTOM ORB.42 WOODLAND GREY</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>149</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>16</SeqNo>
<LineType>Product</LineType>
<BookingNo>2</BookingNo>
<OrderNo>CAM/074112/040</OrderNo>
<SSCC>193168810020118645</SSCC>
<Description>QUAD GUTTER HI 115 EXTERNAL BRACKET CLASSIC CREAM</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>1</Quantity1>
</DSBookingDetail>
<DSBookingDetail>
<SeqNo>17</SeqNo>
<LineType>Product</LineType>
<BookingNo>2</BookingNo>
<OrderNo>NUN/017553/060</OrderNo>
<SSCC>193168810020118669</SSCC>
<Description>POP ROUND 90MM ZINCALUME NOZZLE/DROP</Description>
<UnitCode1>KG</UnitCode1>
<Quantity1>1</Quantity1>
</DSBookingDetail>
</ManifestSourceBD>
<ManifestSourceBH xmlns:version4="http://www.tranxml.org/TranXML/Version4.0">
<DSBookingHeader/>
<DSBookingHeader>
<BookingNo>2</BookingNo>
<SenderName>BlueScope Lysaght</SenderName>
<ReceiverName>REECE PTY LTD - CAMPBELLFIELD</ReceiverName>
<ReceiverAddress1>35 STATION AV vicroads 639 S6</ReceiverAddress1>
<ReceiverAddress3>HEATHCOTE JUNCTION</ReceiverAddress3>
<ReceiverPostCode>3758</ReceiverPostCode>
<DespatchDate>2010-11-05</DespatchDate>
<DeliveryDate>2010-11-05</DeliveryDate>
<SenderReference>918072</SenderReference>
<DeliveryStartTime>00:00:00</DeliveryStartTime>
</DSBookingHeader>
<DSBookingHeader>
<BookingNo>1</BookingNo>
<SenderName>BlueScope Lysaght</SenderName>
<ReceiverName>SSS BARGAIN BUILDERS SUPP P/L</ReceiverName>
<ReceiverAddress1>83 HIGH ST TO 85</ReceiverAddress1>
<ReceiverAddress3>BROADFORD</ReceiverAddress3>
<ReceiverPostCode>3658</ReceiverPostCode>
<DespatchDate>2010-11-05</DespatchDate>
<DeliveryDate>2010-11-05</DeliveryDate>
<SenderReference>918072</SenderReference>
<DeliveryStartTime>00:00:00</DeliveryStartTime>
</DSBookingHeader>
<DSBookingHeader>
<BookingNo>3</BookingNo>
<SenderName>BlueScope Lysaght</SenderName>
<ReceiverName>SSS BARGAIN BUILDERS SUPP P/L</ReceiverName>
<ReceiverAddress1>83 HIGH ST TO 85</ReceiverAddress1>
<ReceiverAddress3>BROADFORD</ReceiverAddress3>
<ReceiverPostCode>3658</ReceiverPostCode>
<DespatchDate>2010-11-05</DespatchDate>
<DeliveryDate>2010-11-05</DeliveryDate>
<SenderReference>918072</SenderReference>
<DeliveryStartTime>00:00:00</DeliveryStartTime>
</DSBookingHeader>
</ManifestSourceBH>
<ManifestSourceM xmlns:version4="http://www.tranxml.org/TranXML/Version4.0">
<DSManifest>
<ManifestNo>918072</ManifestNo>
<ManifestDate>2010-11-05</ManifestDate>
<PrimeMover>Z48GW</PrimeMover>
<Fleet1>B50KX</Fleet1>
<Fleet2>B60KX</Fleet2>
<Fleet3>B70KX</Fleet3>
<Fleet4>B80KX</Fleet4>
<Fleet5>B90KX</Fleet5>
<Description>""</Description>
<Description2>""</Description2>
</DSManifest>
</ManifestSourceM>
<ManifestSourceMB xmlns:version4="http://www.tranxml.org/TranXML/Version4.0">
<DSManifestBooking/>
<DSManifestBooking>
<ManifestNo>918072</ManifestNo>
<BookingNo>3</BookingNo>
<SeqNo>1</SeqNo>
<SubBookingNo>1</SubBookingNo>
<Confirmed>"No"</Confirmed>
<Charge>"No"</Charge>
<SentToEDI>"No"</SentToEDI>
</DSManifestBooking>
<DSManifestBooking>
<ManifestNo>918072</ManifestNo>
<BookingNo>2</BookingNo>
<SeqNo>2</SeqNo>
<SubBookingNo>1</SubBookingNo>
<Confirmed>"No"</Confirmed>
<Charge>"No"</Charge>
<SentToEDI>"No"</SentToEDI>
</DSManifestBooking>
<DSManifestBooking>
<ManifestNo>918072</ManifestNo>
<BookingNo>1</BookingNo>
<SeqNo>1</SeqNo>
<SubBookingNo>1</SubBookingNo>
<Confirmed>"No"</Confirmed>
<Charge>"No"</Charge>
<SentToEDI>"No"</SentToEDI>
</DSManifestBooking>
</ManifestSourceMB>
</ShipmentInformation>
В это:
<?xml version="1.0" encoding="UTF-8"?>
<ManifestSource xmlns:version4="http://www.tranxml.org/TranXML/Version4.0">
<DSManifest>
<ManifestNo>918072</ManifestNo>
<ManifestDate>2010-11-05</ManifestDate>
<PrimeMover>Z48GW</PrimeMover>
<Description>""</Description>
<Description2>""</Description2>
<Fleet1>B50KX</Fleet1>
<Fleet2>B60KX</Fleet2>
<Fleet3>B70KX</Fleet3>
<Fleet4>B80KX</Fleet4>
<Fleet5>B90KX</Fleet5>
<DSManifestBooking>
<ManifestNo>918072</ManifestNo>
<BookingNo>1</BookingNo>
<SeqNo>1</SeqNo>
<Confirmed>"No"</Confirmed>
<Charge>"No"</Charge>
<SentToEDI>"No"</SentToEDI>
<DSBookingHeader>
<BookingNo>1</BookingNo>
<SenderName>BlueScope Lysaght</SenderName>
<ReceiverName>REECE PTY LTD - CAMPBELLFIELD</ReceiverName>
<ReceiverAddress1>35 STATION AV vicroads 639 S6</ReceiverAddress1>
<ReceiverAddress3>HEATHCOTE JUNCTION</ReceiverAddress3>
<ReceiverPostCode>3758</ReceiverPostCode>
<DespatchDate>2010-11-05</DespatchDate>
<DeliveryDate>2010-11-05</DeliveryDate>
<SenderReference>918072</SenderReference>
<DeliveryStartTime>00:00:00</DeliveryStartTime>
<DSBookingDetail>
<BookingNo>1</BookingNo>
<SeqNo>1</SeqNo>
<Description>RIDGE CAP ROLL TOP.42 X 390MM DEEP OCEAN</Description>
<Quantity1>25</Quantity1>
</DSBookingDetail>
</DSBookingHeader>
</DSManifestBooking>
<DSManifestBooking>
<ManifestNo>918072</ManifestNo>
<BookingNo>2</BookingNo>
<SeqNo>2</SeqNo>
<Confirmed>"No"</Confirmed>
<Charge>"No"</Charge>
<SentToEDI>"No"</SentToEDI>
<DSBookingHeader>
<BookingNo>2</BookingNo>
<SenderName>BlueScope Lysaght</SenderName>
<ReceiverName>SSS BARGAIN BUILDERS SUPP P/L</ReceiverName>
<ReceiverAddress1>83 HIGH ST TO 85</ReceiverAddress1>
<ReceiverAddress3>BROADFORD</ReceiverAddress3>
<ReceiverPostCode>3658</ReceiverPostCode>
<DespatchDate>2010-11-05</DespatchDate>
<DeliveryDate>2010-11-05</DeliveryDate>
<SenderReference>918072</SenderReference>
<DeliveryStartTime>00:00:00</DeliveryStartTime>
<DSBookingDetail>
<BookingNo>2</BookingNo>
<SeqNo>11</SeqNo>
<Description>CUSTOM ORB.42 PAPERBARK</Description>
<Quantity1>279</Quantity1>
</DSBookingDetail>
</DSBookingHeader>
</DSManifestBooking>
</DSManifest>
</ManifestSource>