xsl-list
[Top] [All Lists]

[xsl] Split one line to multiple lines

2014-10-10 23:20:20
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.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>