I have created a XSLT file that can transform a single XML file. However, I have several hundred directories with multiple xml files. Is there a way in XSLT to transform all these files. I am using the collection function to get a list of all files. But, not sure how to apply the transform now.
Here is my example XSLT file. Basically, I want to loop through all the xml files and apply the template table on the individual file. The output of all these transforms needs to be in one single flat text file.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foo="http://whatever">
<xsl:output method="text" encoding="ISO-8859-1"/>
<xsl:template name="process">
<xsl:variable name="files" select="collection('file:///C:/files/testResults?select=*.xml;recurse=yes')"/>
<xsl:for-each select="$files">
<xsl:if test="(not(contains(document-uri(.), 'SuiteSetUp'))) and (not(contains(document-uri(.), 'SuiteTearDown')))">
<xsl:value-of select="tokenize(document-uri(.), '/')[last()]"></xsl:value-of>
<xsl:apply-templates select="/testResults/result/tables/table[14]">
<xsl:with-param name="title" select="/testResults/rootPath"></xsl:with-param>
</xsl:apply-templates>
<xsl:apply-templates select="/testResults/result/tables/table[15]"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template match="table">
<xsl:param name="testName"></xsl:param>
<xsl:for-each select="row">
<xsl:if test="position() > 2">
<xsl:variable name="choices" select="col[2]"></xsl:variable>
<xsl:if test="contains($choices, 'fail')">
<xsl:value-of select="$testName"></xsl:value-of>
<xsl:text>|</xsl:text>
<xsl:value-of select="col[1]"></xsl:value-of>
<xsl:text>|</xsl:text>
<xsl:value-of select="foo:getCorrectChoices(col[2])"></xsl:value-of>
<xsl:text>|</xsl:text>
<xsl:value-of select="foo:getExpectedChoices(col[2])"></xsl:value-of>
<xsl:text>|</xsl:text>
<xsl:call-template name="NewLine"/>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="NewLine">
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:function name="foo:getCorrectChoices">
<xsl:param name="content"></xsl:param>
<xsl:analyze-string select="$content" regex="\[(\[.+?\])\] fail">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"></xsl:value-of>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:function>
<xsl:function name="foo:getExpectedChoices">
<xsl:param name="content"></xsl:param>
<xsl:analyze-string select="$content" regex="fail\(expected \[(\[.+?\])\]">
<xsl:matching-substring>
<xsl:value-of select="regex-group(1)"></xsl:value-of>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:function>
</xsl:stylesheet>