xsl-list
[Top] [All Lists]

XSLT to conver flat XML to Heirarchy XML

2005-04-26 19:54:29

Hi ,
 I have an XML which is flat,

<?xml version="1.0" encoding="utf-8" ?>

<ns:MT_Test xmlns:ns="<http://centrica/Test>http://Centrica/Test";>
 <RECSETNAME xmlns:ns="<http://centrica/Test>http://Centrica/Test";>
   <Record>
       <keyfieldValue>"HEADR"</keyfieldValue>
       <fieldValue>"CDJOB"</fieldValue>
       <fieldValue>"TRA"</fieldValue>
   </Record>

   <Record>
       <keyfieldValue>"TRANS"</keyfieldValue>
       <fieldValue>"DATA"</fieldValue>
       <fieldValue>"EXCHG"</fieldValue>
       <fieldValue>"EXCH"</fieldValue>
   </Record>

   <Record>
       <keyfieldValue>"MTPNT"</keyfieldValue>
       <fieldValue>74842606</fieldValue>
   </Record>

   <Record>
       <keyfieldValue>"ADDRS"</keyfieldValue>
       <fieldValue>"MTRPT"</fieldValue>
       <fieldValue>"BRITISH TELECOM"</fieldValue>
   </Record>

   <Record>
       <keyfieldValue>"ASSET"</keyfieldValue>
       <fieldValue>"INSTL"</fieldValue>
       <fieldValue>"METER"</fieldValue>
   </Record>

   <Record>
       <keyfieldValue>"METER"</keyfieldValue>
       <fieldValue>"T"</fieldValue>
   </Record>

 </RECSETNAME>
</<ns:MT_Test>

All the data is store under the record structure, based on the
keyFieldValue i have to generate the target node.

my Target XML should look like:

<HEADR>
  <fieldValue>"CDJOB"</fieldValue>
  <fieldValue>"TRA"</fieldValue>
  <TRANS>
    <fieldValue>"DATA"</fieldValue>
    <fieldValue>"EXCHG"</fieldValue>
    <fieldValue>"EXCH"</fieldValue>

    <MTPNT>
      <fieldValue>74842606</fieldValue>

      <ADDRS>
         <fieldValue>"MTRPT"</fieldValue>
         <fieldValue>"BRITISH TELECOM"</fieldValue>
      </ADDRS>

      <ASSET>
         <fieldValue>"INSTL"</fieldValue>
         <fieldValue>"568"</fieldValue>

         <METER>
            <fieldValue>"T"</fieldValue>
         </METER>
      </ASSET>
    <MTPNT>
  </TRANS>
</HEADR>



The logic for generating:

  loop through the records in sorce xml,

   Base on the key value generate the note in the tareget XML, The
problem here is i am not sure how to insert the nodes as a children in
the targt.



Could anyone please help.



Regards

Sreekanth



Confidentiality Notice

The information contained in this electronic message and any attachments to 
this message are intended
for the exclusive use of the addressee(s) and may contain confidential or 
privileged information. If
you are not the intended recipient, please notify the sender at Wipro or 
Mailadmin(_at_)wipro(_dot_)com immediately
and destroy all copies of this message and any attachments.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>