Reputation: 166
I have a directory structure like this:
-TopFolder
--ChildFolder1/file.xml
--ChildFolder2/file.xml
--ChildFolder3/file.xml
I'd like to navigate each child folder, apply my xslt stylesheet to file.xml, and output "file.html" in each folder. I've looked at collections() and some other things but I'm not quite sure which approach to take. Is this possible with XSLT 2.0?
Cheers
Upvotes: 1
Views: 1029
Reputation: 163498
Using Saxon, you can add this template rule to your stylesheet:
<xsl:template name="main">
<xsl:for-each select="collection('.?select=*.xml;recurse=yes')">
<xsl:result-document href="out/{tokenize(document-uri(.), '/')[last()]">
<xsl:apply-templates select="."/>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
and then invoke it supplying -it:main instead of a source document. Of course you may want to make adjustments to the way in which you supply the input and output directories.
Upvotes: 1