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:
http://saxonica.com/documentation/index.html#!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.

Cheers,

E.
--
Eliot Kimber
http://contrext.com


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="http://www.w3.org/1999/XSL/Transform";
        xmlns:xs="http://www.w3.org/2001/XMLSchema";
        exclude-result-prefixes="xs"
        version="2.0">

        <xsl:variable name="fileSet"
select="collection('/Users/danvint/pubsrc-other/formatting-sample?select=*.*;
recurse=yes')"/>
        <xsl:template match="/">
            <xsl:apply-templates select="$fileSet"
mode="collectionprocessing"/>

        </xsl:template>

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


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

           'file:/Users/danvint/pubsrc-other/formatting-sample/glossentry-ada
pter.dita' true
            'file:/Users/danvint/pubsrc-other/formatting-sample/conaction/reu
se-push-ds-config-tool.dita' true
            'file:/Users/danvint/pubsrc-other/formatting-sample/conaction/reu
se-update-server.dita' true
            'file:/Users/danvint/pubsrc-other/formatting-sample/submap-ping_i
d_examples.ditamap' true
            'file:/Users/danvint/pubsrc-other/formatting-sample/concept_PDabo
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

            'file:/Users/danvint/pubsrc-other/formatting-sample/concept_PAWeb
_Access_Management_Agent_Deployment.dita'
trueAAAAAUJ1ZDEAABAAAAAIAAAAEAAAAAIJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAA
AAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAQAHNwYmxvYgAAAPZicAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    .... lots of lines here similar to above
    mvQrxFWXHxD6hgAEIAABCGwnAXuvGsvOvVhNBYKutU2nnqv2YZ2rz04qQ7Rm8AoBCEAAAhCAA
ATemQBq5p0R0gAEIAABCEAAAhA4J4C4OmfBEQQgAAEIQAACEHhnAoird0ZIAxCAAAQgAAEIQOCcAO
LqnAVHEIAABCAAAQhA4J0JIK7eGSENQAACEIAABCAAgXMCiKtzFhxBAAIQgAAEIACBdyaAuHpnhDQ
AAQhAAAIQgAAEzgkgrs5ZcAQBCEAAAhCAAATemcD/B/Gl121mZIjuAAAAAElFTkSuQmCC
            'file:/Users/danvint/pubsrc-other/formatting-sample/gloss_PFadmin
Glossary.dita' true



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

            'file:/Users/danvint/pubsrc-other/formatting-sample/submap_2-noto
c.ditamap' true
            'file:/Users/danvint/pubsrc-other/formatting-sample/glossentry-op
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";	}
            'file:/Users/danvint/pubsrc-other/formatting-sample/submap-knowni
ssues.ditamap' true
            'file:/Users/danvint/pubsrc-other/formatting-sample/concept_PAPor
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
<http://www.mulberrytech.com/xsl/xsl-list>EasyUnsubscribe
<http://lists.mulberrytech.com/unsub/xsl-list/1278982>
    (by email <>)

Current Thread