Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 9th, 2012, 02:30 AM
Registered User
 
Join Date: Aug 2012
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Merging XML Files Using XSLT

Hi,
Can you please help with the merging of xml files using xslt.I have three xml files as input and i want a single xml file. Dummy XML files are mentioned below:

File1.xml
<tag>
<city>ABC</city>
<town>abc@example1.com</town>
</tag>

File2.xml
<tag>
<city>DEF</city>
<town>def@example2.com</town>
</tag>

File3.xml
<tag>
<city>XYZ</city>
<town>xyz@example3.com</town>
</tag>

And my desired output is:

<tag>
<city>ABC</city>
<town>abc@example1.com</town>
<city>DEF</city>
<town>def@example2.com</town>
<city>XYZ</city>
<town>xyz@example3.com</town>
</tag>

Last edited by darkknight; October 9th, 2012 at 02:37 AM..
 
Old October 9th, 2012, 05:36 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Code:
<xsl:template name="merge">
<tag>
  <xsl:for-each select="document('a.xml')|document('b.xml')|document('c.xml')">
    <xsl:copy-of select="/*/*"/>
  </xsl:for-each>
</tag>
</xsl:template>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging multiple xml files into a single xml file Pauletta XSLT 4 April 18th, 2012 10:13 AM
merging 2 xml with xslt gbordel XSLT 7 April 24th, 2008 05:27 AM
Grabbing content from 2 XML files and merging yanzickp XSLT 4 August 6th, 2007 10:07 AM
merging xml using xslt sormel XSLT 1 July 9th, 2007 06:07 PM
problem in merging of XML Files rajatake XSLT 5 April 29th, 2006 12:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.