Skip to content

Instantly share code, notes, and snippets.

@kardeiz
Created February 2, 2012 15:07
Show Gist options
  • Save kardeiz/1723883 to your computer and use it in GitHub Desktop.
Save kardeiz/1723883 to your computer and use it in GitHub Desktop.
xslt for concatenating multiple xml files
<!-- Option 1: Use an index XML file to list file names to be combined. Transform that XML file (root: files) with this XSL. -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xml>
<xsl:for-each select="files/file">
<xsl:copy-of select="document(.)/xml/*"/>
</xsl:for-each>
</xml>
</xsl:template>
</xsl:stylesheet>
<!-- Option 2: Name the files to be combined in the XSL -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xml>
<xsl:copy-of select="document('filename.xml')/xml/*"/>
<!-- Use a scripting language that can manipulate XML to append child nodes here listing all the files to be combined -->
</xml>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment