title: Grouping the Child with no common key values using XSLT
body: <p>Below is my input XML. Here I have two different <strong>SHOWSHIPMENT</strong> files and I want to merge them to one using the data of the first occurrence of <strong>SHOWSHIPMENT</strong> for all the fields and grouping the second <strong>RL_DEATILS</strong> into the first <strong>SHOWSHIPMENT</strong></p>
  
  <p>INPUT:</p>
  
  <pre><code> &lt;SHOW&gt;
      &lt;SHOWSHIPMENT&gt;
          &lt;APPLICATIONAREA&gt;
              &lt;SENDER&gt;
                  &lt;LOGICALID&gt;ABC&lt;/LOGICALID&gt;
              &lt;/SENDER&gt;
              &lt;RECEIVERID&gt;220911&lt;/RECEIVERID&gt;
          &lt;/APPLICATIONAREA&gt;
          &lt;DATAAREA&gt;
              &lt;SHIPMENT&gt;
                  &lt;X_DLV_TAB_ITEM&gt;
                      &lt;TYPE&gt;A&lt;/TYPE&gt;
                      &lt;TRANSACTION_CODE&gt;RC&lt;/TRANSACTION_CODE&gt;
                  &lt;/X_DLV_TAB_ITEM&gt;
                  &lt;X_DLV_TAB&gt;
                      &lt;X_DLV_TAB_ITEM&gt;
                          &lt;TYPE&gt;A&lt;/TYPE&gt;
                          &lt;TRANSACTION_CODE&gt;RC&lt;/TRANSACTION_CODE&gt;
                          &lt;DELIVERY_ID&gt;46689764&lt;/DELIVERY_ID&gt;
                          &lt;NAME&gt;46689764&lt;/NAME&gt;
                      &lt;/X_DLV_TAB_ITEM&gt;   
                      &lt;RL_DETAILS&gt;
                          &lt;ITEM&gt;ONE&lt;/ITEM&gt;
                          &lt;RL_DETAILS_ITEM&gt;
                              &lt;DELIVERY_DETAIL_ID&gt;14460996&lt;/DELIVERY_DETAIL_ID&gt;
                              &lt;GROSS_WEIGHT&gt;11&lt;/GROSS_WEIGHT&gt;
                              &lt;WEIGHT_UOM_CODE&gt;LB&lt;/WEIGHT_UOM_CODE&gt;
                              &lt;VOLUME&gt;0.2&lt;/VOLUME&gt;
                              &lt;VOLUME_UOM_CODE&gt;CF&lt;/VOLUME_UOM_CODE&gt;
                              &lt;REQUESTED_QUANTITY&gt;5&lt;/REQUESTED_QUANTITY&gt;
                          &lt;/RL_DETAILS_ITEM&gt;
                      &lt;/RL_DETAILS&gt;
                  &lt;/X_DLV_TAB&gt;
              &lt;/SHIPMENT&gt;
          &lt;/DATAAREA&gt;
      &lt;/SHOWSHIPMENT&gt;
      &lt;SHOWSHIPMENT&gt;
          &lt;APPLICATIONAREA&gt;
              &lt;SENDER&gt;
                  &lt;LOGICALID&gt;XYZ&lt;/LOGICALID&gt;
              &lt;/SENDER&gt;
              &lt;RECEIVERID&gt;220911&lt;/RECEIVERID&gt;
          &lt;/APPLICATIONAREA&gt;
          &lt;DATAAREA&gt;
              &lt;SHIPMENT&gt;
                  &lt;X_DLV_TAB_ITEM&gt;
                      &lt;TYPE&gt;B&lt;/TYPE&gt;
                      &lt;TRANSACTION_CODE&gt;AB&lt;/TRANSACTION_CODE&gt;
                  &lt;/X_DLV_TAB_ITEM&gt;
                  &lt;X_DLV_TAB&gt;
                      &lt;X_DLV_TAB_ITEM&gt;
                          &lt;TYPE&gt;B&lt;/TYPE&gt;
                          &lt;TRANSACTION_CODE&gt;AB&lt;/TRANSACTION_CODE&gt;
                          &lt;DELIVERY_ID&gt;466897665&lt;/DELIVERY_ID&gt;
                          &lt;NAME&gt;46689765&lt;/NAME&gt;
                      &lt;/X_DLV_TAB_ITEM&gt;
                      &lt;RL_DETAILS&gt;
                          &lt;ITEM&gt;TWO&lt;/ITEM&gt;
                          &lt;RL_DETAILS_ITEM&gt;
                              &lt;DELIVERY_DETAIL_ID&gt;14460997&lt;/DELIVERY_DETAIL_ID&gt;
                              &lt;GROSS_WEIGHT&gt;5.28333&lt;/GROSS_WEIGHT&gt;
                              &lt;WEIGHT_UOM_CODE&gt;LB&lt;/WEIGHT_UOM_CODE&gt;
                              &lt;VOLUME&gt;0.12&lt;/VOLUME&gt;
                              &lt;VOLUME_UOM_CODE&gt;CF&lt;/VOLUME_UOM_CODE&gt;
                              &lt;REQUESTED_QUANTITY&gt;3&lt;/REQUESTED_QUANTITY&gt;
                          &lt;/RL_DETAILS_ITEM&gt;
                      &lt;/RL_DETAILS&gt;
                  &lt;/X_DLV_TAB&gt;
              &lt;/SHIPMENT&gt;
          &lt;/DATAAREA&gt;
      &lt;/SHOWSHIPMENT&gt;
   &lt;/SHOW&gt;
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code> &lt;SHOW&gt;
      &lt;SHOWSHIPMENT&gt;
          &lt;APPLICATIONAREA&gt;
              &lt;SENDER&gt;
                  &lt;LOGICALID&gt;ABC&lt;/LOGICALID&gt;
              &lt;/SENDER&gt;
              &lt;RECEIVERID&gt;220911&lt;/RECEIVERID&gt;
          &lt;/APPLICATIONAREA&gt;
          &lt;DATAAREA&gt;
              &lt;SHIPMENT&gt;
                  &lt;X_DLV_TAB_ITEM&gt;
                      &lt;TYPE&gt;A&lt;/TYPE&gt;
                      &lt;TRANSACTION_CODE&gt;RC&lt;/TRANSACTION_CODE&gt;
                  &lt;/X_DLV_TAB_ITEM&gt;
                  &lt;X_DLV_TAB&gt;
                      &lt;X_DLV_TAB_ITEM&gt;
                          &lt;TYPE&gt;A&lt;/TYPE&gt;
                          &lt;TRANSACTION_CODE&gt;RC&lt;/TRANSACTION_CODE&gt;
                          &lt;DELIVERY_ID&gt;46689764&lt;/DELIVERY_ID&gt;
                          &lt;NAME&gt;46689764&lt;/NAME&gt;
                      &lt;/X_DLV_TAB_ITEM&gt;   
                      &lt;RL_DETAILS&gt;
                          &lt;ITEM&gt;ONE&lt;/ITEM&gt;
                          &lt;RL_DETAILS_ITEM&gt;
                              &lt;DELIVERY_DETAIL_ID&gt;14460996&lt;/DELIVERY_DETAIL_ID&gt;
                              &lt;GROSS_WEIGHT&gt;11&lt;/GROSS_WEIGHT&gt;
                              &lt;WEIGHT_UOM_CODE&gt;LB&lt;/WEIGHT_UOM_CODE&gt;
                              &lt;VOLUME&gt;0.2&lt;/VOLUME&gt;
                              &lt;VOLUME_UOM_CODE&gt;CF&lt;/VOLUME_UOM_CODE&gt;
                              &lt;REQUESTED_QUANTITY&gt;5&lt;/REQUESTED_QUANTITY&gt;
                          &lt;/RL_DETAILS_ITEM&gt;
                      &lt;/RL_DETAILS&gt;
                      &lt;RL_DETAILS&gt;
                          &lt;ITEM&gt;TWO&lt;/ITEM&gt;
                          &lt;RL_DETAILS_ITEM&gt;
                              &lt;DELIVERY_DETAIL_ID&gt;14460997&lt;/DELIVERY_DETAIL_ID&gt;
                              &lt;GROSS_WEIGHT&gt;5.28333&lt;/GROSS_WEIGHT&gt;
                              &lt;WEIGHT_UOM_CODE&gt;LB&lt;/WEIGHT_UOM_CODE&gt;
                              &lt;VOLUME&gt;0.12&lt;/VOLUME&gt;
                              &lt;VOLUME_UOM_CODE&gt;CF&lt;/VOLUME_UOM_CODE&gt;
                              &lt;REQUESTED_QUANTITY&gt;3&lt;/REQUESTED_QUANTITY&gt;
                          &lt;/RL_DETAILS_ITEM&gt;
                      &lt;/RL_DETAILS&gt;
                  &lt;/X_DLV_TAB&gt;
              &lt;/SHIPMENT&gt;
          &lt;/DATAAREA&gt;
      &lt;/SHOWSHIPMENT&gt;
   &lt;/SHOW&gt;
  </code></pre>
  
  <p>In the <strong>SHOWSHIPMENT</strong> I have <strong>X_DLV_TAB_ITEM</strong> repeated twice at two different levels <strong>SHIPMENT/X_DLV_TAB_ITEM</strong> and <strong>SHIPMENT/X_DLV_TAB/X_DLV_TAB_ITEM</strong>.</p>
  
  <p>Thanks Maryann. </p>