[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Merging two XML documents

Subject: Re: Merging two XML documents
From: cutlass <cutlass@xxxxxxxxxxx>
Date: Fri, 09 Mar 2001 13:37:16 +0000
xsl merge two xml documents
Simon Reed wrote:

Being relatively new to xml I have come across a problem, which is as
follows:
What is the best method to merge and/or update 2 XML's with the same
structure. The merging/updating XML will only contain a section of a larger
XML it is to be merged into but the structure will be identical from the
root node. Examples are shown below:
XML to merge
<page>
	<type>
		<address>
			<addressline1>34 th Street</addressline1>
			<addressline2>USA</addressline2>
		</address>
	</type>


faq on using document() function http://www.dpawson.co.uk/xsl/N2602.html#N18697


faq on merging http://www.dpawson.co.uk/xsl/merge.html

depending on what u mean by 'merge', this can be done using one xml file as your list of files to process ( note-with sablot xsl parser u must use file://// for filepaths), then having the xsl recurse through this list, loading test1, test2, and so on...... and doing a xsl:copy.

what i could not get from your email was if u wanted to merge records from different documents, might be able to help more if u give an ex of required output.

test.xsl( as adopted from Steve Tinney from XSLT FAQ )
-----------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="file">
<xsl:variable name="pathname" select="."/>
<xsl:variable name="contents" select="document($pathname)"/>
<xsl:copy-of select="$contents"/>
</xsl:template>
</xsl:stylesheet>



test.xml ( as adopted from Steve Tinney from XSLT FAQ ) ----------------------------------- <?xml version="1.0" encoding="utf-8"?> <mother> <file>test1.xml</file> <file>test2.xml</file> </mother>

test1.xml
-------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<page>
<order>
<item cost="100">CD-ROM</item>
</order>
<type>
<name>abc</name>
<name>jkl</name>
<name>mno</name>
<name>pqr</name>
<address>
<addressline1>43 sdfsdf</addressline1>
</address>
<address>
<addressline1>64 The Road</addressline1>
<addressline2>Big City</addressline2>
<addressline3>UK</addressline3>
</address>
</type>
</page>

test2.xml
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<page>
<type>
<address>
<addressline1>34 th Street</addressline1>
<addressline2>USA</addressline2>
</address>
</type>
</page>


cheers, jim fuller



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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.