Re: [xsl] Using paramter "-s" with a diretcory = recursive for the whole dir tree?

Subject: Re: [xsl] Using paramter "-s" with a diretcory = recursive for the whole dir tree?
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 11 Aug 2009 08:40:53 +0100
2009/8/11 Ben Stover <bxstover@xxxxxxxxxxx>:
> When reading web page
>
> http://www.saxonica.com/documentation/using-xsl/commandline.html
>
> then there is said about the parameter "-s":
> "If the name identifies a directory, all the files in the directory will
> be processed individually."
>
> Does that mean all files just in this directory?
> What about files in sub-directories? Are they processed as well?
>
> If not: How can I tell Saxon to process a whole directory tree recursively?


If you want 1 output file per input file, then you could use Kernow or
the technique below.  If you want 1 output for multiple input files,
then use the collection() function in a "standalone" transform (and
then run that using Kernow :)

<xsl:template name="main">
  <xsl:for-each select="for $x in collection(concat($input-dir,
'?select=*.xml;recurse=yes')) return saxon:discard-document($x)">
    process each file

The "recurse=yes" part tells Saxon to process sub-directories too.
The "saxon:discard-document()" part is needed if you have a to process
more XML in a single transform than you can fit into memory.

I use this so often I really hope there are new features in 2.1 for
processing directories of XML.


-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

Current Thread