[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Merging two xml files.


Subject: [xsl] Merging two xml files.
From: "Bhaskar Reddy" <bhaskar_reddy@xxxxxxxxxxx>
Date: Mon, 12 Jan 2004 21:59:29 +0530

Hi,
I have many sets of data in xml files. Each set has three xml files. And each set has different tree structure. So I am looking for some general solution.


I want to merge file 1 and file 2, depending on the attribute"src" from file 3( template file) of the set.

Sample files for a set are as shown below..

the "src" attribute tells from where to get the value of that element.

file 1: xml
-------------
<Data>
    <Name> Peter Radke </Name>
    <Age> 34 </Age>
    <Address>
               <Street> 34 Peter Ave </Street>
               <City> Chicago</City>
               <Country> USA </Country>
    </Address>
</Data>

file 2: xml : Has very similar structure but different values

<Data>
    <Name> Peter </Name>
    <Age> 38 </Age>
    <Address>
               <Street> 38 Bradway st</Street>
               <City> NewYork</City>
               <Country> USA </Country>
    </Address>
</Data>

file 3: xml :
<Data>
    <Name src="file1"> </Name>
    <Age src="file2"></Age>
    <Address src="file2">
    </Address>
</Data>

file 3 is a template file for merging file 1 and file 2. the src attribute in this file tells from where to get the element value from. For example the Name element value should be read from the file1 and the Age should be from the file 2. And the whole <Address> structure should be read from the file 2.

So the result should look like

Result FILE:
----------------
<Data>
    <Name> Peter Radke </Name>
    <Age> 38 </Age>
    <Address>
               <Street> 38 Bradway st</Street>
               <City> NewYork</City>
               <Country> USA </Country>
    </Address>
</Data>

_________________________________________________________________
Free drafts to 700 locations. http://server1.msn.co.in/msnleads/suvidha/dec03.asp?type=hottag Click here.



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




Current Thread
Keywords