I want to create transformation from multiple xml files to just one xml (Output. xml) using Saxon. The xml files will be generated by my test tools, so there is no limitation for how many xml will be available. Suppose in one folder I have several files:
Summaryfile001.xml
Summaryfile002.xml
Detailsfile001.xml
Detailsfile002.xml
SummaryandDetailsAllFiles.html
I want to get only summaryfiles. Inside the SummaryFiles001.xml :
<SummaryFile>
<testname>file001</testname>
<Error>1</Error>
<test>1</test>
<skipped>1</skipped>
<failures>0</failures>
<dateAndTime>15082015093021</dateAndtime>
</SummaryFile>
I did the transformation to one output match with Junit format report using saxon, so the template:
JUnitFormat.xslt
<xsl:output indent="yes" method="xml"/>
<xsl:param name="fileName" select="'output.xml'" />
<xsl:template match="/">
<xsl:apply-templates mode="inFile" select="collection('file:///C:/Users/Documents/Resultfiles?select=*.xml;recurse=yes')"/>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="SummaryFile">
<xsl:variable name="testName" select="//SummaryFile/testname"/>
<xsl:variable name="test" select="//SummaryFile/test"/>
<xsl:variable name="Error" select="//SummaryFile/Error"/>
<xsl:variable name="skipped" select="//SummaryFile/skipped"/>
<xsl:variable name="dateAndtime" select="//SummaryResultsFile/dateAndtime"/>
<xsl:variable name="failures" select="//SummaryFile/failures"/>
<testsuites>
<testsuite name="{$testName}"
tests="{$test}"
time="{$dateAndTime}"
failures="{$failures}"
errors="{$Error}"
skipped="{$skipped}">
</testsuite>
</testsuites>
</xsl:template>
However, when I'm trying to execute with saxon with this command:
java -jar saxon9he.jar -xslt:JUnitTemplate.xslt -s:C:/Users/Documents/Resultfiles -o:Output.xml
I couldnt do the transformation. It says transformation failed. I can do the transformation only for a single xml, but I couldn't do for multiple xml. So the idea for the xslt:
1. Look for only Summary Files
2. Get all the data from Summary file.xml
3. Create one output xml contain all summary result file in JUnit format
Anybody know how I can solve the problem?