[xsl] Split one line to multiple lines

Subject: [xsl] Split one line to multiple lines
From: "sudheshna iyer sudheshnaiyer@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 11 Oct 2014 04:20:07 -0000
Hello Experts,

I have the below input. Each line has multiple ProductNumbers. I need to create one line for each ProductNumber with same values for the rest of the elements.

For eg:
         <ns1:Line>
            <ns1:LineId>22</ns1:LineId>
            <ns1:ProductNumber>prod2</ns1:ProductNumber>
            <ns1:ProductNumber>prod3</ns1:ProductNumber>
            <ns1:ProductNumber>prod4</ns1:ProductNumber>
            <ns1:ProductNumber>prod5</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>
         
Should be split to   4 lines    
         <ns1:Line>
            <ns1:LineId>22.0</ns1:LineId>
            <ns1:ProductNumber>prod2</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>
         <ns1:Line>
            <ns1:LineId>22.1</ns1:LineId>
            <ns1:ProductNumber>prod3</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>
         <ns1:Line>
            <ns1:LineId>22.2</ns1:LineId>
            <ns1:ProductNumber>prod4</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>   
         <ns1:Line>
            <ns1:LineId>22.3</ns1:LineId>
            <ns1:ProductNumber>prod5</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>  
         
===========================         
Input:
<?xml version = '1.0' encoding = 'UTF-8'?>
<ns1:QuoteInput xmlns:ns1="http://test/Quote/V1";>
   <ns1:Quote>
      <ns1:Header>
         <ns1:Base>
            <ns1:Id>96019968</ns1:Id>
            <ns1:CustomerNumber>123aaa</ns1:CustomerNumber>
         </ns1:Base>
      </ns1:Header>
      <ns1:Lines>
         <ns1:Line>
            <ns1:LineId>11</ns1:LineId>
            <ns1:ProductNumber>prod1</ns1:ProductNumber>
            <ns1:Amount>100.0</ns1:Amount>
            <ns1:Type>Upgrade</ns1:Type>
         </ns1:Line>
         <ns1:Line>
            <ns1:LineId>22</ns1:LineId>
            <ns1:ProductNumber>prod2</ns1:ProductNumber>
            <ns1:ProductNumber>prod3</ns1:ProductNumber>
            <ns1:ProductNumber>prod4</ns1:ProductNumber>
            <ns1:ProductNumber>prod5</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>
      </ns1:Lines>
   </ns1:Quote>
</ns1:QuoteInput>

Output should be:
<?xml version = '1.0' encoding = 'UTF-8'?>
<ns1:QuoteOutput xmlns:ns1="http://test/Quote/V1";>
   <ns1:Quote>
      <ns1:Header>
         <ns1:Base>
            <ns1:Id>96019968</ns1:Id>
            <ns1:CustomerNumber>123aaa</ns1:CustomerNumber>
         </ns1:Base>
      </ns1:Header>
      <ns1:Lines>
         <ns1:Line>
            <ns1:LineId>11</ns1:LineId>
            <ns1:ProductNumber>prod1</ns1:ProductNumber>
            <ns1:Amount>100.0</ns1:Amount>
            <ns1:Type>Upgrade</ns1:Type>
         </ns1:Line>
         <ns1:Line>
            <ns1:LineId>22.0</ns1:LineId>
            <ns1:ProductNumber>prod2</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>
         <ns1:Line>
            <ns1:LineId>22.1</ns1:LineId>
            <ns1:ProductNumber>prod3</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>
         <ns1:Line>
            <ns1:LineId>22.2</ns1:LineId>
            <ns1:ProductNumber>prod4</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>   
         <ns1:Line>
            <ns1:LineId>22.3</ns1:LineId>
            <ns1:ProductNumber>prod5</ns1:ProductNumber>
            <ns1:Amount>200.0</ns1:Amount>
            <ns1:Type>Sale</ns1:Type>
         </ns1:Line>  
      </ns1:Lines>
   </ns1:Quote>
</ns1:QuoteOutput>
===========================

I appreciate your help.

Current Thread