Re: [xsl] Running the same transformation on many input files, optimisation possible?

Subject: Re: [xsl] Running the same transformation on many input files, optimisation possible?
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 15 Dec 2019 19:31:12 -0000
On Sun, 2019-12-15 at 09:03 +0000, Trevor Nicholls
trevor@xxxxxxxxxxxxxxxxxx wrote:
> 
> cd documents
> 
> for d in `cat dlist`; do

as others have said, use collection, or unparsed-text-lines() to read
dlist;

> 
>   cd $d
> 
>   for f in `cat flist`; do
> 
>     java -jar $SAXONDIR/saxon8.jar  -o  $f.new.xml  $f.xml
> $SCRIPTDIR/transform.xsl  doc=$d  file=$f

This is super easy with fn:transform() and really fast too. In a recent
course i gave, people with laptops read an input XML file and split it
into over 9,000 HTML files with transform(), the entire process taking
roughly 6 seconds to run with Saxon for most of them, both fromthe
command-line and inside Oxygen XML Editor.

Watch that the parameters you pass with f:transformmust be QNames -use
QName('', 'doc) for example.

There's no easy way to change directory in Java, although you can do
that with a Saxon extension i think -   calling the Java method:
  System.setProperty("user.dir", "/some/directory")
might do it. The EXpath file:current-dir() function tells you where you
are.

So this approach would involve modifying the XSLT stylesheets you call
so that they take a dir parameter or use file:current-dir(). Watch that
Saxon on Windows might not include a drive letter with current-dir(),
which may or nay not matter to you.


Liam

-- 
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations:  http://www.fromoldbooks.org

Current Thread