Subject: RE: Using Saxon 8.5 and collection() to process a directory of XML files
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 4 Aug 2005 15:23:41 +0100
|
Should be possible. You can get the URI of each individual source document
using document-uri().
Many Saxon extensions were developed because I needed them myself. This one
was created to help me organize and build a catalogue for my collection of
XSLT test data, perhaps 8000 files or so. This certainly needed to obtain
the URI/filename of each of the separate input files.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Welch Andrew (ELS) [mailto:A.Welch@xxxxxxxxxxxx]
> Sent: 04 August 2005 13:08
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Using Saxon 8.5 and collection() to process a
> directory of XML files
>
>
> 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:
>
> 001.xml
> 002.xml
> ...
> 999.xml
>
> 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
> first.html
> second.html
> ...
> [002]
> first.html
> second.html
> ....
>
> ...
> [999]
> first.html
> etc
>
> 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">
> ....
> </xsl:result-document>
> </xsl:for-each>
>
> $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?
>
> cheers
> andrew
|