Reputation: 453
I need to concat a number 'N' of the XML in another XML.
For example: I've this XML
<BOOKS>
<BOOK>
<TITTLE>Lord of the Rings</TITLE>
<AUTHORS>J. R. R. Tolkien</AUTHORS>
<AUTHORS>J. K. Rowling</AUTHORS>
<YEAR>2015</YEAR>
</BOOK>
<BOOK>
<TITTLE>The Hobbit: The Battle of the Five Armies</TITLE>
<AUTHORS>J. R. R. Tolkien</AUTHORS>
<YEAR>2013</YEAR>
</BOOK>
</BOOKS>
and this:
<BOOKS>
<BOOK>
<TITTLE>A Clash of Kings</TITLE>
<AUTHORS>George R. R. Martin</AUTHORS>
<AUTHORS>J. K. Rowling</AUTHORS>
<YEAR>2016</YEAR>
</BOOK>
<BOOK>
<TITTLE>The Hobbit: The Battle of the Five Armies</TITLE>
<AUTHORS>J. R. R. Tolkien</AUTHORS>
<YEAR>2013</YEAR>
</BOOK>
</BOOKS>
I need to generate a new file like this:
<BOOKS>
<BOOK>
<TITTLE>Lord of the Rings</TITLE>
<AUTHORS>J. R. R. Tolkien</AUTHORS>
<AUTHORS>J. K. Rowling</AUTHORS>
<YEAR>2015</YEAR>
</BOOK>
<BOOK>
<TITTLE>The Hobbit: The Battle of the Five Armies</TITLE>
<AUTHORS>J. R. R. Tolkien</AUTHORS>
<YEAR>2013</YEAR>
</BOOK>
<BOOK>
<TITTLE>A Clash of Kings</TITLE>
<AUTHORS>George R. R. Martin</AUTHORS>
<AUTHORS>J. K. Rowling</AUTHORS>
<YEAR>2016</YEAR>
</BOOK>
<BOOK>
<TITTLE>The Hobbit: The Battle of the Five Armies</TITLE>
<AUTHORS>J. R. R. Tolkien</AUTHORS>
<YEAR>2013</YEAR>
</BOOK>
</BOOKS>
The XMLs are in my directory: E:\books. I want to concat all files, for example: If I've two files, the script will concat them, but if I've three or more files, the script will concat also. How do I do it?
Upvotes: 0
Views: 49
Reputation: 163488
In XSLT 2.0 with Saxon it's
<xsl:template name="main">
<BOOKS>
<xsl:sequence select="collection('dir?select=*.xml')/BOOKS/BOOK"/>
</BOOKS>
</xsl:template>
Upvotes: 1