Reputation: 1232
I have a folder with many XML files and I want a simple XSLT transformation that can merge all these files into one and put all the data under only one node named <files>...</files>
.
I don't care about the order.
P.S. I have no index file with the names of all the files. I searched "XSLT concatenate XML files" on google but the results always spoke about using the document()
function and getting the names of the files from an index file.
I would like to see the solution to this problem using the collection()
function, if possible, please.
Upvotes: 3
Views: 1354
Reputation: 167696
XSLT 2.0 processors usually allow that (pulling in files from a directory/folder) using the collection
function but the argument to that function is processor dependent. Using Saxon 9 you could use
<xsl:param name="folder-url" select="'file:///C:/dir/folder'"/>
<xsl:template name="main">
<files>
<xsl:copy-of select="collection(concat($folder-url, '?select=*.xml'))"/>
</files>
</xsl:template>
See http://www.saxonica.com/documentation/index.html#!sourcedocs/collections for details respectively check the documentation of your XSLT 2.0 processor.
Upvotes: 7