Subject: Re: [xsl] How to merge multiple XML files From: "Alexander Johannesen" <alexander.johannesen@xxxxxxxxx> Date: Mon, 7 May 2007 15:40:39 +1000 |
Would anybody let me know that how to merge multiple xml files within a directory into a single XML file. I have no idea about it.
a) Scripting language : create array of input files, read them in, locate all the <record> elements (and content), and dump them all out in a file containing the surrounding <records> element.
<xsl:template match="/"> <xsl:variable name="a" select="document('a.xml')/records" /> <xsl:variable name="b" select="document('b.xml')/records" /> <xsl:variable name="c" select="document('c.xml')/records" /> <records> <xsl:copy-of select="$a/text()|$a/*" /> <xsl:copy-of select="$b/text()|$b/*" /> <xsl:copy-of select="$c/text()|$c/*" /> </records> </xsl:template>
or a more dyunamic version with an XML input, or XSLT 2.0 with embedded XML. If you need some special sort-order you need to tweakit a bit.
Alex -- --------------------------------------------------------------------------- Project Wrangler, SOA, Information Alchymist, UX, RESTafarian, Topic Maps ------------------------------------------ http://shelter.nu/blog/ --------
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to merge multiple XML fil, J. S. Rawat | Thread | Re: [xsl] How to merge multiple XML, J. S. Rawat |
[xsl] How to merge multiple XML fil, J. S. Rawat | Date | Re: [xsl] How to merge multiple XML, J. S. Rawat |
Month |