Re: [xsl] Using XSLT to process a directory of mixed files

Subject: Re: [xsl] Using XSLT to process a directory of mixed files
From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 8 May 2019 02:54:15 -0000
If you use the map-producing version of the Saxon collection extension then
you'll get a map one for each file, that gives you more metadata. See the
Saxon documentation for details:!sourcedocs/collections

tl;dr: use metadata=yes to get the metadata map(s) for the selected resources.
You can use e.g. map:keys() to inspect the map entries to see what metadata
you have.


Eliot Kimber

o;?On 5/7/19, 9:39 PM, "dvint@xxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

    I'm trying to use a collection() to process all files in a directory. The
directory may have text, pddf, images files in addition to my DITA file. I've
created this little test
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="";

        <xsl:variable name="fileSet"
        <xsl:template match="/">
            <xsl:apply-templates select="$fileSet"


        <xsl:template match="/" mode="collectionprocessing">
            '<xsl:value-of select="document-uri()"/>' <xsl:value-of

    It seems to do what I expect for XML files with results like this

pter.dita' true
se-push-ds-config-tool.dita' true
se-update-server.dita' true
d_examples.ditamap' true
uttheexplodedindexformat.dita' true

    But then I have some odd things. It looks like I hit a binary file of some
sort, based upon the output, but I was just trying to get the file names in
this script

    .... lots of lines here similar to above
Glossary.dita' true

    I don't know what this chunk of content is. Then there is this odd bit

c.ditamap' true
enid.dita' truesub addTaxonomy {	my $inname = $_[0];	my $tempname = $_[0] .
".new";	my $taxonomy = $_[1];	  	open my $in,  '&lt;:encoding(UTF-8)',
$inname      or die "Can't read old file: $inname!";	open my $temp,
'&gt;:encoding(UTF-8)', $tempname or die "Can't write new file: $tempname!";
while( &lt;$in&gt; )	    {		    s/(&lt;head&gt;)/&lt;head\&gt;\n$taxonomy\n/g;
print $temp $_;	    }		 close $temp;		 close $in;		# Replace inout file with
temp, remove temp	rename "./" . $tempname, "./" . $inname or die "Can't move
file $tempname to $inname";	}
ssues.ditamap' true
t_Requirements.dita' true

    These blobs of odd stuff don't follow the pattern of '' around the file
name and the test I thought that would tell me if it was an XML file or not.
There is no true/false provided either.

    What I want to build is a list of files (shell script) that would copy
these other files to a new copy in my processed folder where I will be writing
the results of other work against the DITA files.
    XSL-List info and archive
    (by email <>)

Current Thread