'Group by value in child note xslt 2

Is there someone to help me resolve this : I have this xml


    <?xml version="1.0" encoding="utf-8"?>
    <OrderInformation>
     <Order>
      <Products>
       <Product>
        <IdData>
         <DSF>
             <Id>366613</Id>
             <IdTypeName>OrderLineItem2</IdTypeName>
             <Description>RV2-1010</Description>
         </DSF>
        </IdData>           
        <ProductData>
         <Shipments>
          <Shipment>
            <ShippingDetailID>553359</ShippingDetailID>
            <adresse>3 Rue de Paris</adresse>
          </Shipment>
          <Shipment>
            <ShippingDetailID>553360</ShippingDetailID>
            <adresse>67 Main street</adresse>
          </Shipment>
         </Shipments>
        </ProductData>
       </Product>
       <Product>
        <IdData>
         <DSF>
            <Id>366613</Id>
            <IdTypeName>OrderLineItem2</IdTypeName>
            <Description>RV1-0903403</Description>
         </DSF>
        </IdData>
        <ProductData>
         <Shipments>
          <Shipment>
            <ShippingDetailID>553360</ShippingDetailID>
            <adresse>67 Main street</adresse>
          </Shipment>
         </Shipments>
        </ProductData>
       </Product>
      </Products>
     </Order>
    </OrderInformation>

and i want this :


    <?xml version="1.0" encoding="UTF-8"?>
    <OrderInformation>
        <Ship553359>
            <ShippingDetailID>553359</ShippingDetailID>
            <adresse>3 Rue de Paris</adresse>
            <Description>RV2-1010</Description>
        </Ship553359>
        <Ship553360>
            <ShippingDetailID>553360</ShippingDetailID>
            <adresse>67 Main street</adresse>
            <Description>RV2-1010 \n RV1-0903403</Description>
        </Ship553360>
    </OrderInformation>

There's 2 "product" and each has Shipment, 2 for the first product and one for the second. The xml i wish should have 2 shipment, one with the 2 product (with a break line in description) and the other with only one. I've just started by a group-by ShippingDetailID but to no avail, i don't know how to copy the node i want inside. Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source