[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Merging 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>
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>
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|