Skip to Content
0
Former Member
Nov 23, 2011 at 02:01 PM

Mapping Requirement

17 Views

Hi All,

I am trying to achieve one XSLT mapping requirement for the below source structure.The values under "Level" and "Parent" source field dynamically determine the target structure node "SPM" and its hierachy on the target side.

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Test xmlns:ns0="http://test">
   <Header>
      <Name>xx</Name>
      <Age>12</Age>
      <Item>
         <Level>1</Level>
         <Parent>0</Parent>
         <Company>A</Company>
      </Item>
      <Item>
         <Level>2</Level>
         <Parent>1</Parent>
         <Company>B</Company>
      </Item>
      <Item>
         <Level>3</Level>
         <Parent>2</Parent>
         <Company>C</Company>
      </Item>
      <Item>
         <Level>2</Level>
         <Parent>1</Parent>
         <Company>D</Company>
      </Item>
      <Item>
         <Level>3</Level>
         <Parent>2</Parent>
         <Company>E</Company>
      </Item>
      <Item>
         <Level>3</Level>
         <Parent>2</Parent>
         <Company>F</Company>
      </Item>
   </Header>
</ns0:MT_Test>

Target:

<?xml version="1.0" encoding="UTF-8"?>
<MT_Target xmlns:ns0="http://test">
   <Records>
      <Name>xx</Name>
      <Age>12</Age>
      <SPM>
         <Level>1</Level>
         <Parent>0</Parent>
         <Company>A</Company>
              <SPM>
            <Level>2</Level>
            <Parent>1</Parent>
            <Company>B</Company>
                   <SPM>
                   <Level>3</Level>
                   <Parent>2</Parent>
                   <Company>C</Company>
                    </SPM>
             </SPM>
               <SPM>
                  <Level>2</Level>
                  <Parent>1</Parent>
                  <Company>D</Company>
                  <SPM>
                     <Level>3</Level>
                     <Parent>2</Parent>
                     <Company>E</Company>
                  </SPM>
                     <SPM>
                     <Level>3</Level>
                     <Parent>2</Parent>
                     <Company>F</Company>
                </SPM> 
         </SPM>
      </SPM>
   </Records>
</MT_Target>

Please help.

Thanks!!