title: select every following segment until next sibling occurs and group them under target structure
body: <p>I have input structure like below: 
  After Item we have delivery_Info segment it can one per item or multiple for item, And the again Item followed by Delivery_Info. So we have group first item with following Delivery_Info and then next Item with their following Delivery_Info. Input and output structure is provided for more understanding.</p>
  
  <p><code>DataSet</code> cardinality is 1..n <br>
  <code>EDI_Header</code> cardinality is 1..n <br>
  <code>Item</code> cardinality is 1..n <br>
  <code>Deliveryinfoset</code> cardinality 1..1 <br>
  <code>Delivery_info</code> cardinality 0..n <br> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ns:MM_FlatFile_CBOX_ORDRSP_Out xmlns:ns="urn:test:corp:pi:a:ecc:cbox:ordrsp:100"&gt;
          &lt;DataSet&gt;
              &lt;EDI_Header&gt;
                  &lt;LineIdent&gt;SIM&lt;/LineIdent&gt;
                  &lt;EDIPartnerNo&gt;047866091&lt;/EDIPartnerNo&gt;
                  &lt;MessageType&gt;ORDRSP01&lt;/MessageType&gt;
                  &lt;VersionNo&gt;3A7V0&lt;/VersionNo&gt;
                  &lt;Mode&gt;102&lt;/Mode&gt;
              &lt;/EDI_Header&gt;
              &lt;Header&gt;
                  &lt;LineIdent&gt;HO01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;CustomerOrderNo&gt;0038283143&lt;/CustomerOrderNo&gt;
                  &lt;MessageFunction/&gt;
                  &lt;Reference1&gt;6174625&lt;/Reference1&gt;
                  &lt;Reference2/&gt;
                  &lt;Reference3/&gt;
                  &lt;SoldToID&gt;126919&lt;/SoldToID&gt;
                  &lt;Partner2&gt;126919&lt;/Partner2&gt;
                  &lt;Partner3/&gt;
                  &lt;ShipToID&gt;126919&lt;/ShipToID&gt;
                  &lt;ShipToName&gt;XXXXX&lt;/ShipToName&gt;
                  &lt;ShipToAddress/&gt;
                  &lt;ShipToAddress2&gt;XXXXX&lt;/ShipToAddress2&gt;
                  &lt;ShipToCity&gt;XXXXX&lt;/ShipToCity&gt;
                  &lt;ShipToZIP&gt;XXXXX&lt;/ShipToZIP&gt;
                  &lt;ShipToCountry&gt;FI&lt;/ShipToCountry&gt;
                  &lt;CustContact&gt;XXXXX&lt;/CustContact&gt;
                  &lt;CustContactTelNo&gt;XXXXX&lt;/CustContactTelNo&gt;
                  &lt;TransportType&gt;EUR&lt;/TransportType&gt;
              &lt;/Header&gt;
              &lt;Item&gt;
                  &lt;LineIdent&gt;PO01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1&lt;/LineItemNo&gt;
                  &lt;ActionCode&gt;6&lt;/ActionCode&gt;
                  &lt;ItemNoCust&gt;P380200&lt;/ItemNoCust&gt;
                  &lt;ItemNoSup&gt;B39172B5364U410W 3&lt;/ItemNoSup&gt;
                  &lt;Quantity&gt;D1L1&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;Price&gt;0.4000&lt;/Price&gt;
                  &lt;PriceType/&gt;
                  &lt;QuantityPriceUnit&gt;1&lt;/QuantityPriceUnit&gt;
                  &lt;LineItemNoCust/&gt;
              &lt;/Item&gt;
              &lt;Delivery_Info&gt;
                  &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                  &lt;Quantity&gt;3000&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                  &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                  &lt;DateCode&gt;C&lt;/DateCode&gt;
                  &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                  &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                  &lt;SysVar/&gt;
              &lt;/Delivery_Info&gt;
              &lt;Item&gt;
                  &lt;LineIdent&gt;PO01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1&lt;/LineItemNo&gt;
                  &lt;ActionCode&gt;6&lt;/ActionCode&gt;
                  &lt;ItemNoCust&gt;P380200&lt;/ItemNoCust&gt;
                  &lt;ItemNoSup&gt;B39172B5364U410W 3&lt;/ItemNoSup&gt;
                  &lt;Quantity&gt;D1L1&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;Price&gt;0.4000&lt;/Price&gt;
                  &lt;PriceType/&gt;
                  &lt;QuantityPriceUnit&gt;1&lt;/QuantityPriceUnit&gt;
                  &lt;LineItemNoCust/&gt;
              &lt;/Item&gt;
              &lt;Delivery_Info&gt;
                  &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                  &lt;Quantity&gt;3000&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                  &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                  &lt;DateCode&gt;C&lt;/DateCode&gt;
                  &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                  &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                  &lt;SysVar/&gt;
              &lt;/Delivery_Info&gt;
          &lt;/DataSet&gt;
          &lt;DataSet&gt;
              &lt;EDI_Header&gt;
                  &lt;LineIdent&gt;SIM&lt;/LineIdent&gt;
                  &lt;EDIPartnerNo&gt;047866091&lt;/EDIPartnerNo&gt;
                  &lt;MessageType&gt;ORDRSP01&lt;/MessageType&gt;
                  &lt;VersionNo&gt;3A7V0&lt;/VersionNo&gt;
                  &lt;Mode&gt;102&lt;/Mode&gt;
              &lt;/EDI_Header&gt;
              &lt;Header&gt;
                  &lt;LineIdent&gt;HO01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;CustomerOrderNo&gt;0038283143&lt;/CustomerOrderNo&gt;
                  &lt;MessageFunction/&gt;
                  &lt;Reference1&gt;6174625&lt;/Reference1&gt;
                  &lt;Reference2/&gt;
                  &lt;Reference3/&gt;
                  &lt;SoldToID&gt;126919&lt;/SoldToID&gt;
                  &lt;Partner2&gt;126919&lt;/Partner2&gt;
                  &lt;Partner3/&gt;
                  &lt;ShipToID&gt;126919&lt;/ShipToID&gt;
                  &lt;ShipToName&gt;XXXXX&lt;/ShipToName&gt;
                  &lt;ShipToAddress/&gt;
                  &lt;ShipToAddress2&gt;XXXXX&lt;/ShipToAddress2&gt;
                  &lt;ShipToCity&gt;XXXXX&lt;/ShipToCity&gt;
                  &lt;ShipToZIP&gt;XXXXX&lt;/ShipToZIP&gt;
                  &lt;ShipToCountry&gt;FI&lt;/ShipToCountry&gt;
                  &lt;CustContact&gt;XXXXX&lt;/CustContact&gt;
                  &lt;CustContactTelNo&gt;XXXXX&lt;/CustContactTelNo&gt;
                  &lt;TransportType&gt;EUR&lt;/TransportType&gt;
              &lt;/Header&gt;
              &lt;Item&gt;
                  &lt;LineIdent&gt;PO01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1&lt;/LineItemNo&gt;
                  &lt;ActionCode&gt;6&lt;/ActionCode&gt;
                  &lt;ItemNoCust&gt;P380200&lt;/ItemNoCust&gt;
                  &lt;ItemNoSup&gt;B39172B5364U410W 3&lt;/ItemNoSup&gt;
                  &lt;Quantity&gt;D1L1&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;Price&gt;0.4000&lt;/Price&gt;
                  &lt;PriceType/&gt;
                  &lt;QuantityPriceUnit&gt;1&lt;/QuantityPriceUnit&gt;
                  &lt;LineItemNoCust/&gt;
              &lt;/Item&gt;
              &lt;Delivery_Info&gt;
                  &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                  &lt;Quantity&gt;3000&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                  &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                  &lt;DateCode&gt;C&lt;/DateCode&gt;
                  &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                  &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                  &lt;SysVar/&gt;
              &lt;/Delivery_Info&gt;
              &lt;Delivery_Info&gt;
                  &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                  &lt;Quantity&gt;3000&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                  &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                  &lt;DateCode&gt;C&lt;/DateCode&gt;
                  &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                  &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                  &lt;SysVar/&gt;
              &lt;/Delivery_Info&gt;
              &lt;Delivery_Info&gt;
                  &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                  &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                  &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                  &lt;Quantity&gt;3000&lt;/Quantity&gt;
                  &lt;Unit&gt;PCE&lt;/Unit&gt;
                  &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                  &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                  &lt;DateCode&gt;C&lt;/DateCode&gt;
                  &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                  &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                  &lt;SysVar/&gt;
              &lt;/Delivery_Info&gt;
          &lt;/DataSet&gt;
      &lt;/ns:MM_FlatFile_CBOX_ORDRSP_Out&gt;
  </code></pre>
  
  <p>Target Structure should be--></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ns:MM_FlatFile_CBOX_ORDRSP_Out 
  
  xmlns:ns="urn:test:corp:pi:a:ecc:cbox:ordrsp:100"&gt;
      &lt;DataSet&gt;
          &lt;EDI_Header&gt;
              &lt;LineIdent&gt;SIM&lt;/LineIdent&gt;
              &lt;EDIPartnerNo&gt;047866091&lt;/EDIPartnerNo&gt;
              &lt;MessageType&gt;ORDRSP01&lt;/MessageType&gt;
              &lt;VersionNo&gt;3A7V0&lt;/VersionNo&gt;
              &lt;Mode&gt;102&lt;/Mode&gt;
          &lt;/EDI_Header&gt;
          &lt;Header&gt;
              &lt;LineIdent&gt;HO01&lt;/LineIdent&gt;
              &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
              &lt;CustomerOrderNo&gt;0038283143&lt;/CustomerOrderNo&gt;
              &lt;MessageFunction/&gt;
              &lt;Reference1&gt;6174625&lt;/Reference1&gt;
              &lt;Reference2/&gt;
              &lt;Reference3/&gt;
              &lt;SoldToID&gt;126919&lt;/SoldToID&gt;
              &lt;Partner2&gt;126919&lt;/Partner2&gt;
              &lt;Partner3/&gt;
              &lt;ShipToID&gt;126919&lt;/ShipToID&gt;
              &lt;ShipToName&gt;XXXXX&lt;/ShipToName&gt;
              &lt;ShipToAddress/&gt;
              &lt;ShipToAddress2&gt;XXXXX&lt;/ShipToAddress2&gt;
              &lt;ShipToCity&gt;XXXXX&lt;/ShipToCity&gt;
              &lt;ShipToZIP&gt;XXXXX&lt;/ShipToZIP&gt;
              &lt;ShipToCountry&gt;FI&lt;/ShipToCountry&gt;
              &lt;CustContact&gt;XXXXX&lt;/CustContact&gt;
              &lt;CustContactTelNo&gt;XXXXX&lt;/CustContactTelNo&gt;
              &lt;TransportType&gt;EUR&lt;/TransportType&gt;
          &lt;/Header&gt;
          &lt;Item&gt;
              &lt;LineIdent&gt;PO01&lt;/LineIdent&gt;
              &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
              &lt;LineItemNo&gt;D1L1&lt;/LineItemNo&gt;
              &lt;ActionCode&gt;6&lt;/ActionCode&gt;
              &lt;ItemNoCust&gt;P380200&lt;/ItemNoCust&gt;
              &lt;ItemNoSup&gt;B39172B5364U410W 3&lt;/ItemNoSup&gt;
              &lt;Quantity&gt;D1L1&lt;/Quantity&gt;
              &lt;Unit&gt;PCE&lt;/Unit&gt;
              &lt;Price&gt;0.4000&lt;/Price&gt;
              &lt;PriceType/&gt;
              &lt;QuantityPriceUnit&gt;1&lt;/QuantityPriceUnit&gt;
              &lt;LineItemNoCust/&gt;
              &lt;Deliveryinfoset&gt;
                  &lt;Delivery_Info&gt;
                      &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                      &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                      &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                      &lt;Quantity&gt;3000&lt;/Quantity&gt;
                      &lt;Unit&gt;PCE&lt;/Unit&gt;
                      &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                      &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                      &lt;DateCode&gt;C&lt;/DateCode&gt;
                      &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                      &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                      &lt;SysVar/&gt;
                  &lt;/Delivery_Info&gt;
              &lt;/Deliveryinfoset&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;LineIdent&gt;PO01&lt;/LineIdent&gt;
              &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
              &lt;LineItemNo&gt;D1L1&lt;/LineItemNo&gt;
              &lt;ActionCode&gt;6&lt;/ActionCode&gt;
              &lt;ItemNoCust&gt;P380200&lt;/ItemNoCust&gt;
              &lt;ItemNoSup&gt;B39172B5364U410W 3&lt;/ItemNoSup&gt;
              &lt;Quantity&gt;D1L1&lt;/Quantity&gt;
              &lt;Unit&gt;PCE&lt;/Unit&gt;
              &lt;Price&gt;0.4000&lt;/Price&gt;
              &lt;PriceType/&gt;
              &lt;QuantityPriceUnit&gt;1&lt;/QuantityPriceUnit&gt;
              &lt;LineItemNoCust/&gt;
              &lt;Deliveryinfoset&gt;
                  &lt;Delivery_Info&gt;
                      &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                      &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                      &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                      &lt;Quantity&gt;3000&lt;/Quantity&gt;
                      &lt;Unit&gt;PCE&lt;/Unit&gt;
                      &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                      &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                      &lt;DateCode&gt;C&lt;/DateCode&gt;
                      &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                      &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                      &lt;SysVar/&gt;
                  &lt;/Delivery_Info&gt;
              &lt;/Deliveryinfoset&gt;
          &lt;/Item&gt;
      &lt;/DataSet&gt;
      &lt;DataSet&gt;
          &lt;EDI_Header&gt;
              &lt;LineIdent&gt;SIM&lt;/LineIdent&gt;
              &lt;EDIPartnerNo&gt;047866091&lt;/EDIPartnerNo&gt;
              &lt;MessageType&gt;ORDRSP01&lt;/MessageType&gt;
              &lt;VersionNo&gt;3A7V0&lt;/VersionNo&gt;
              &lt;Mode&gt;102&lt;/Mode&gt;
          &lt;/EDI_Header&gt;
          &lt;Header&gt;
              &lt;LineIdent&gt;HO01&lt;/LineIdent&gt;
              &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
              &lt;CustomerOrderNo&gt;0038283143&lt;/CustomerOrderNo&gt;
              &lt;MessageFunction/&gt;
              &lt;Reference1&gt;6174625&lt;/Reference1&gt;
              &lt;Reference2/&gt;
              &lt;Reference3/&gt;
              &lt;SoldToID&gt;126919&lt;/SoldToID&gt;
              &lt;Partner2&gt;126919&lt;/Partner2&gt;
              &lt;Partner3/&gt;
              &lt;ShipToID&gt;126919&lt;/ShipToID&gt;
              &lt;ShipToName&gt;XXXXX&lt;/ShipToName&gt;
              &lt;ShipToAddress/&gt;
              &lt;ShipToAddress2&gt;XXXXX&lt;/ShipToAddress2&gt;
              &lt;ShipToCity&gt;XXXXX&lt;/ShipToCity&gt;
              &lt;ShipToZIP&gt;XXXXX&lt;/ShipToZIP&gt;
              &lt;ShipToCountry&gt;FI&lt;/ShipToCountry&gt;
              &lt;CustContact&gt;XXXXX&lt;/CustContact&gt;
              &lt;CustContactTelNo&gt;XXXXX&lt;/CustContactTelNo&gt;
              &lt;TransportType&gt;EUR&lt;/TransportType&gt;
          &lt;/Header&gt;
          &lt;Item&gt;
              &lt;LineIdent&gt;PO01&lt;/LineIdent&gt;
              &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
              &lt;LineItemNo&gt;D1L1&lt;/LineItemNo&gt;
              &lt;ActionCode&gt;6&lt;/ActionCode&gt;
              &lt;ItemNoCust&gt;P380200&lt;/ItemNoCust&gt;
              &lt;ItemNoSup&gt;B39172B5364U410W 3&lt;/ItemNoSup&gt;
              &lt;Quantity&gt;D1L1&lt;/Quantity&gt;
              &lt;Unit&gt;PCE&lt;/Unit&gt;
              &lt;Price&gt;0.4000&lt;/Price&gt;
              &lt;PriceType/&gt;
              &lt;QuantityPriceUnit&gt;1&lt;/QuantityPriceUnit&gt;
              &lt;LineItemNoCust/&gt;
              &lt;Deliveryinfoset&gt;
                  &lt;Delivery_Info&gt;
                      &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                      &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                      &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                      &lt;Quantity&gt;3000&lt;/Quantity&gt;
                      &lt;Unit&gt;PCE&lt;/Unit&gt;
                      &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                      &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                      &lt;DateCode&gt;C&lt;/DateCode&gt;
                      &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                      &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                      &lt;SysVar/&gt;
                  &lt;/Delivery_Info&gt;
                  &lt;Delivery_Info&gt;
                      &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                      &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                      &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                      &lt;Quantity&gt;3000&lt;/Quantity&gt;
                      &lt;Unit&gt;PCE&lt;/Unit&gt;
                      &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                      &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                      &lt;DateCode&gt;C&lt;/DateCode&gt;
                      &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                      &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                      &lt;SysVar/&gt;
                  &lt;/Delivery_Info&gt;
                  &lt;Delivery_Info&gt;
                      &lt;LineIdent&gt;TE01&lt;/LineIdent&gt;
                      &lt;SupplierOrderNo&gt;6174625&lt;/SupplierOrderNo&gt;
                      &lt;LineItemNo&gt;D1L1DI1&lt;/LineItemNo&gt;
                      &lt;Quantity&gt;3000&lt;/Quantity&gt;
                      &lt;Unit&gt;PCE&lt;/Unit&gt;
                      &lt;DelDateReq&gt;20181130&lt;/DelDateReq&gt;
                      &lt;DelDate&gt;20181212&lt;/DelDate&gt;
                      &lt;DateCode&gt;C&lt;/DateCode&gt;
                      &lt;QuantityOrdered&gt;3000&lt;/QuantityOrdered&gt;
                      &lt;DateCurrent&gt;20181121&lt;/DateCurrent&gt;
                      &lt;SysVar/&gt;
                  &lt;/Delivery_Info&gt;
              &lt;/Deliveryinfoset&gt;
          &lt;/Item&gt;
      &lt;/DataSet&gt;
  &lt;/ns:MM_FlatFile_CBOX_ORDRSP_Out&gt;
  </code></pre>
  
  <p>My XSLT Code which is not working if we have more than one item with their delivery info</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ns="urn:test:corp:pi:a:ecc:cbox:ordrsp:100" exclude-result-prefixes="ns"&gt;
  &lt;xsl:output method="xml" indent="yes"/&gt;
  &lt;xsl:template match="/"&gt;
  &lt;MM_FlatFile_CBOX_ORDRSP_Out&gt;
      &lt;xsl:for-each select="/ns:MM_FlatFile_CBOX_ORDRSP_Out/DataSet"&gt;
  
      &lt;DataSet&gt;
          &lt;EDI_Header&gt;
  
              &lt;LineIdent&gt;
                  &lt;xsl:value-of select="./EDI_Header/LineIdent"/&gt;
              &lt;/LineIdent&gt;
  
              &lt;EDIPartnerNo&gt;
                  &lt;xsl:value-of select="./EDI_Header/EDIPartnerNo"/&gt;
              &lt;/EDIPartnerNo&gt;
  
              &lt;MessageType&gt;
                  &lt;xsl:value-of select="'ORDRSP01'"/&gt;
              &lt;/MessageType&gt;
  
              &lt;VersionNo&gt;
                  &lt;xsl:value-of select="'3A7V0'"/&gt;
              &lt;/VersionNo&gt;
  
              &lt;Mode&gt;
                  &lt;xsl:value-of select="'102'"/&gt;
              &lt;/Mode&gt;
          &lt;/EDI_Header&gt;
  
          &lt;Header&gt;
              &lt;LineIdent&gt;
                  &lt;xsl:value-of select="./Header/LineIdent"/&gt;
              &lt;/LineIdent&gt;
  
              &lt;SupplierOrderNo&gt;
                  &lt;xsl:value-of select="./Header/SupplierOrderNo"/&gt;
              &lt;/SupplierOrderNo&gt;
  
              &lt;CustomerOrderNo&gt;
                  &lt;xsl:value-of select="./Header/CustomerOrderNo"/&gt;
              &lt;/CustomerOrderNo&gt;
  
              &lt;MessageFunction&gt;
                  &lt;xsl:value-of select="./Header/MessageFunction"/&gt;
              &lt;/MessageFunction&gt;
  
              &lt;Reference1&gt;
                  &lt;xsl:value-of select="./Header/Reference1"/&gt;
              &lt;/Reference1&gt;
  
              &lt;Reference2&gt;
                  &lt;xsl:value-of select="./Header/Reference2"/&gt;
              &lt;/Reference2&gt;
  
              &lt;Reference3&gt;
                  &lt;xsl:value-of select="./Header/Reference3"/&gt;
              &lt;/Reference3&gt;
  
              &lt;SoldToID&gt;
                  &lt;xsl:value-of select="./Header/SoldToID"/&gt;
              &lt;/SoldToID&gt;
              &lt;Partner2&gt;
                  &lt;xsl:value-of select="./Header/Partner2"/&gt;
              &lt;/Partner2&gt;
  
              &lt;Partner3&gt;
                  &lt;xsl:value-of select="./Header/Partner3"/&gt;
              &lt;/Partner3&gt;
  
              &lt;ShipToID&gt;
                  &lt;xsl:value-of select="./Header/ShipToID"/&gt;
              &lt;/ShipToID&gt;
  
              &lt;ShipToName&gt;
                  &lt;xsl:value-of select="./Header/ShipToName"/&gt;
              &lt;/ShipToName&gt;
  
              &lt;ShipToAddress&gt;
                  &lt;xsl:value-of select="./Header/ShipToAddress"/&gt;
              &lt;/ShipToAddress&gt;
  
              &lt;ShipToAddress2&gt;
                  &lt;xsl:value-of select="./Header/ShipToAddress2"/&gt;
              &lt;/ShipToAddress2&gt;
  
              &lt;ShipToCity&gt;
                  &lt;xsl:value-of select="./Header/ShipToCity"/&gt;
              &lt;/ShipToCity&gt;
  
              &lt;ShipToZIP&gt;
                  &lt;xsl:value-of select="./Header/ShipToZIP"/&gt;
              &lt;/ShipToZIP&gt;
  
              &lt;ShipToCountry&gt;
                  &lt;xsl:value-of select="./Header/ShipToCountry"/&gt;
              &lt;/ShipToCountry&gt;
  
              &lt;CustContact&gt;
                  &lt;xsl:value-of select="./Header/CustContact"/&gt;
              &lt;/CustContact&gt;
  
              &lt;CustContactTelNo&gt;
                  &lt;xsl:value-of select="./Header/CustContactTelNo"/&gt;
              &lt;/CustContactTelNo&gt;
  
              &lt;TransportType&gt;
                  &lt;xsl:value-of select="./Header/TransportType"/&gt;
              &lt;/TransportType&gt;
  
          &lt;/Header&gt;
          &lt;xsl:for-each select="./Item"&gt;
          &lt;Item&gt;
  
  
              &lt;LineIdent&gt;
                  &lt;xsl:value-of select="./LineIdent"/&gt;
              &lt;/LineIdent&gt;
  
              &lt;SupplierOrderNo&gt;
                  &lt;xsl:value-of select="./SupplierOrderNo"/&gt;
              &lt;/SupplierOrderNo&gt;
  
              &lt;LineItemNo&gt;
                  &lt;xsl:value-of select="./LineItemNo"/&gt;
              &lt;/LineItemNo&gt;
  
              &lt;ActionCode&gt;
                  &lt;xsl:value-of select="./ActionCode"/&gt;
              &lt;/ActionCode&gt;
  
              &lt;ItemNoCust&gt;
                  &lt;xsl:value-of select="./ItemNoCust"/&gt;
              &lt;/ItemNoCust&gt;
  
              &lt;ItemNoSup&gt;
                  &lt;xsl:value-of select="./ItemNoSup"/&gt;
              &lt;/ItemNoSup&gt;
  
              &lt;Quantity&gt;
                  &lt;xsl:value-of select="./Quantity"/&gt;
              &lt;/Quantity&gt;
  
              &lt;Unit&gt;
                  &lt;xsl:value-of select="./Unit"/&gt;
              &lt;/Unit&gt;
  
              &lt;Price&gt;
                  &lt;xsl:value-of select="./Price"/&gt;
              &lt;/Price&gt;
  
              &lt;PriceType&gt;
                  &lt;xsl:value-of select="./PriceType"/&gt;
              &lt;/PriceType&gt;
  
              &lt;QuantityPriceUnit&gt;
                  &lt;xsl:value-of select="./QuantityPriceUnit"/&gt;
              &lt;/QuantityPriceUnit&gt;
  
              &lt;LineItemNoCust&gt;
                  &lt;xsl:value-of select="./LineItemNoCust"/&gt;
              &lt;/LineItemNoCust&gt;
  
              &lt;xsl:for-each select="../Delivery_Info"&gt;
  
              &lt;DeliveryInfoSet&gt;
                  &lt;Delivery_Info&gt;
                      &lt;LineIdent&gt;
                          &lt;xsl:value-of select="./LineIdent"/&gt;
                      &lt;/LineIdent&gt;
  
                      &lt;SupplierOrderNo&gt;
                          &lt;xsl:value-of select="./SupplierOrderNo"/&gt;
                      &lt;/SupplierOrderNo&gt;
  
                      &lt;LineItemNo&gt;
                          &lt;xsl:value-of select="./LineItemNo"/&gt;
                      &lt;/LineItemNo&gt;
  
                      &lt;Quantity&gt;
                          &lt;xsl:value-of select="./Quantity"/&gt;
                      &lt;/Quantity&gt;
  
                      &lt;Unit&gt;
                          &lt;xsl:value-of select="./Unit"/&gt;
                      &lt;/Unit&gt;
                      &lt;DelDateReq&gt;
                          &lt;xsl:value-of select="./DelDateReq"/&gt;
                      &lt;/DelDateReq&gt;
  
                      &lt;DelDate&gt;
                          &lt;xsl:value-of select="./DelDate"/&gt;
                      &lt;/DelDate&gt;
  
                      &lt;DateCode&gt;
                          &lt;xsl:value-of select="./DateCode"/&gt;
                      &lt;/DateCode&gt;
  
                      &lt;QuantityOrdered&gt;
                          &lt;xsl:value-of select="./QuantityOrdered"/&gt;
                      &lt;/QuantityOrdered&gt;
  
                      &lt;DateCurrent&gt;
                          &lt;xsl:value-of select="./DateCurrent"/&gt;
                      &lt;/DateCurrent&gt;
  
                      &lt;SysVar&gt;
                          &lt;xsl:value-of select="./SysVar"/&gt;
                      &lt;/SysVar&gt;
  
                  &lt;/Delivery_Info&gt;
              &lt;/DeliveryInfoSet&gt;
  
              &lt;/xsl:for-each&gt;
  
          &lt;/Item&gt;
          &lt;/xsl:for-each&gt;
      &lt;/DataSet&gt;
      &lt;/xsl:for-each&gt;
  &lt;/MM_FlatFile_CBOX_ORDRSP_Out&gt;
  
  
  
  
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Thanks</p>
  
  <p>May I request you people to help me in this requirement</p>