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 March 8th, 2010, 02:40 AM
Authorized User
 
Join Date: Feb 2009
Posts: 31
Thanks: 6
Thanked 1 Time in 1 Post
Send a message via MSN to anil_yadav26@hotmail.com
Default [XSLT 2.0] Merge XML

Hi,

I want to merge all the XML file of a directory into a single XML file. Could you please suggest me how to do it.

Regards,
Anil Yadav
 
Old March 8th, 2010, 03:56 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

With XSLT2.0, try the below:

Code:
<xsl:variable name="docs" select="collection('file:///xml_files_path/?select=*.xml')"/>
 
<xsl:template match="/">
<xsl:for-each select="$docs">
<xsl:copy-of select="document(document-uri(.))"/>
</xsl:for-each>
</xsl:template>
__________________
Rummy
The Following User Says Thank You to mrame For This Useful Post:
anil_yadav26@hotmail.com (March 8th, 2010)
 
Old March 8th, 2010, 02:11 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Rummy, can't your code be simplified to the following:
Code:
<xsl:variable name="docs" select="collection('file:///xml_files_path/?select=*.xml')"/>
 
<xsl:template match="/">
  <xsl:copy-of select="$docs"/>
</xsl:template>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old March 9th, 2010, 01:11 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Yes Martin, both gives the same result. Thanks
__________________
Rummy
 
Old April 1st, 2014, 12:11 PM
Authorized User
 
Join Date: Aug 2013
Posts: 30
Thanks: 9
Thanked 0 Times in 0 Posts
Default

sorry, to which file is this transformation applied to get the result merged file? thanks
 
Old April 1st, 2014, 12:25 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Whatever the principal input document is, the stylesheet makes no use of it, so it doesn't matter.

I usually use an entry point of
Code:
<xsl:template name="main"/>
in such situations for XSLT 2.0.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
pietromaria.liuzzo (April 1st, 2014)





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Merge Records using XSLT navik_pathak XSLT 10 June 22nd, 2009 06:13 PM
Merge XML file data into one XML navik_pathak XSLT 1 June 22nd, 2009 04:45 PM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 08:48 AM
XML Merge... babloo81 XML 3 November 14th, 2003 06:44 AM
Merge XML files into a xml file using xslt lxu XML 4 November 6th, 2003 06:01 PM





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