[xsl] Using Saxon 8.5 and collection() to process a directory of XML fi les

Subject: [xsl] Using Saxon 8.5 and collection() to process a directory of XML fi les
From: "Welch Andrew (ELS)" <A.Welch@xxxxxxxxxxxx>
Date: Thu, 4 Aug 2005 13:08:25 +0100
I've just had a requirement to process a directory of XML files, generating
10 output files per source XML file and placing them in a folder named the
same as the input file.  Mike mentioned in his annoucement email for Saxon
8.5 something along these lines, so I want to try and achieve it all in a
single stylesheet, rather then needing the host language.

So, given a folder of source XML files:


The result of tranform should be a folder per XML file, named the same as
the XML file, with the 10 ouput files within it:

[001] <- folder


I believe it's possible now to use the collection() function to get a
sequence of the input XML files.  Is it possible to get the filenames so
that I can create the corresponding output folder?

This is the code I think I need once I have the collection bit sorted (which
will wrap this code):

<xsl:for-each select="for $i in $outputFileNames return $i">
    <xsl:result-document href="{$dir}/{$folderName}/{.}.html">

$outputFileNames is the sequence of the 10 filenames eg 'first', 'second'
and so on.  $dir is the output folder.  $folderName needs to come from the
filename of the input XML - not sure if this is possible yet.

Once this is ready, I think the end user should be able to run this
stylesheet (with the correct path parameters but without any input XML) to
generate all of the necessary files.  It would be great to do all this in
the stylesheet, rather than requiring the host language to perform each
transform separately.

My question is - is this possible?


Current Thread