create single output files

Oxygen general issues.
stattersall
Posts: 1
Joined: Mon Nov 08, 2010 7:36 pm

create single output files

Post by stattersall »

I am new to oxygen and I have setup a custom transformation scenario to transform multiple xml files with a single xslt stylesheet. Instead of creating multiple output files following the transformation, I want to merge all transformation into a single .html output file.

Can someone advise on this please.

regards,

Steve Tattersall
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: create single output files

Post by Radu »

Hi Steve,

XSLT 2.0 has support for processing multiple XML input files and Oxygen comes bundled with the Saxon 9 Enterprise Edition XSLT processor which has full XSLT 2.0 support. The XSLT 2.0 function you can use is called collection().

So for example if your XML files have the following structure:

Code: Select all

<root>
<person>
.....
</person>
.....
<person>
.....
</person>
.....
</root>
a sample XSLT 2.0 stylesheet like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/">
<html>
<body>
<!-- Iterate all XML files in the "file:/D:/projects/eXml/samples/" directory and get all "person" elements from them -->
<xsl:variable name="allPersons" select="collection('file:/D:/projects/eXml/samples/?select=*.xml')//person"/>
<xsl:for-each select="$allPersons">
<!--Here you can match each person and output HTML from it-->
<xsl:copy-of select="."/>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
would iterate all your XML files from a certain directory and gather with an XPath all <person> elements from them.

You can apply the XSLT stylesheet on any XML file as it will only be interested in processing the files in the collection.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply