xsl-list
[Top] [All Lists]

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

2019-05-07 21:40:00
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-adapter.dita'
true
        
'file:/Users/danvint/pubsrc-other/formatting-sample/conaction/reuse-push-ds-config-tool.dita'
true
        
'file:/Users/danvint/pubsrc-other/formatting-sample/conaction/reuse-update-server.dita'
true
        
'file:/Users/danvint/pubsrc-other/formatting-sample/submap-ping_id_examples.ditamap'
true
        
'file:/Users/danvint/pubsrc-other/formatting-sample/concept_PDabouttheexplodedindexformat.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'
trueAAAAAUJ1ZDEAABAAAAAIAAAAEAAAAAIJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAABAAAQAHNwYmxvYgAAAPZicAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA....
lots of lines here similar to above

        
mvQrxFWXHxD6hgAEIAABCGwnAXuvGsvOvVhNBYKutU2nnqv2YZ2rz04qQ7Rm8AoBCEAAAhCAAATemQBq5p0R0gAEIAABCEAAAhA4J4C4OmfBEQQgAAEIQAACEHhnAoird0ZIAxCAAAQgAAEIQOCcAOLqnAVHEIAABCAAAQhA4J0JIK7eGSENQAACEIAABCAAgXMCiKtzFhxBAAIQgAAEIACBdyaAuHpnhDQAAQhAAAIQgAAEzgkgrs5ZcAQBCEAAAhCAAATemcD/B/Gl121mZIjuAAAAAElFTkSuQmCC
        
'file:/Users/danvint/pubsrc-other/formatting-sample/gloss_PFadminGlossary.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-notoc.ditamap'
true
        
'file:/Users/danvint/pubsrc-other/formatting-sample/glossentry-openid.dita'
truesub addTaxonomy { 
my $inname = $_[0]; 
my $tempname = $_[0] .  
".new"; 
my $taxonomy = $_[1]; 
   

open my $in,  
'<
:encoding(UTF-8)',  
$inname      
or die "Can't read old file: $inname!"; 
open my $temp, '>
:encoding(UTF-8)', $tempname or die "Can't write new file:
$tempname!"; 

while( <
$in>
 ) 
    
{ 

    
s/(<
head>
)/<
head>
n$taxonomyn/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-knownissues.ditamap'
true
        
'file:/Users/danvint/pubsrc-other/formatting-sample/concept_PAPort_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/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>