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

Re: Merging multiple xmls into a single xml

Subject: Re: Merging multiple xmls into a single xml
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Fri, 15 Jul 2005 13:38:40 +0200
merge xmls using xsl
Hi,

Tempore 09:05:14, die 07/15/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Neelam Joshi <mneelam@xxxxxxxxx>:

The number of input xmls is not fixed, it may vary. So is it possible
to accept more than one input file to an xsl script?

yes, take a look at this stylesheet:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>


<xsl:param name="sources">file1.xml|e:/temp/file2.xml|xml3</xsl:param>

<xsl:template match="/">
	<modulenames>
		<xsl:call-template name="loaddocuments"/>
	</modulenames>
</xsl:template>

<xsl:template name="loaddocuments">
<xsl:param name="string" select="concat($sources,'|')"/>
<xsl:if test="substring-before($string,'|') != ''">
<xsl:apply-templates select="document(substring-before($string,'|'))" mode="merge"/>
</xsl:if>
<xsl:if test="contains($string,'|')">
<xsl:call-template name="loaddocuments">
<xsl:with-param name="string" select="substring-after($string,'|')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>


<xsl:template match="/" mode="merge">
	<xsl:copy-of select="//module"/>
</xsl:template>

</xsl:stylesheet>

This will load all files specified in the 'sources' parameter and copy their 'module' nodes.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Spread the wiki (http://www.wikipedia.org)

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.