Re: [xsl] Java list extension

Subject: Re: [xsl] Java list extension
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Tue, 5 Jul 2011 14:09:00 +0200
Andew,

> You can get a list of all the files in the directory and
> subdirectories by doing:

> <xsl:for-each 
select="collection('file:///path/to/dir/?select=*;recurse=yes;on-error=ignore')">
>   <xsl:value-of select="document-uri(.)"/>

how can you get the names of non-XML files?
Saxon reports errors for applying document-uri() to Non-XML files.

[stammw@br8ggx73 xslt20]$ ll
total 12
-rw-rw-r-- 1 stammw stammw 403 Jul  5 14:04 ls.xsl
-rw-rw-r-- 1 stammw stammw   5 Jul  5 14:03 some.xml
-rw-rw-r-- 1 stammw stammw   4 Jul  5 14:04 tst.txt
[stammw@br8ggx73 xslt20]$ 
[stammw@br8ggx73 xslt20]$ saxon ls.xsl some.xml 
Error on line 1 column 1 of tst.txt:
  SXXP0003: Error reported by XML parser: Content is not allowed in 
prolog.
file:/home/stammw/xslt/xslt20/ls.xsl
file:/home/stammw/xslt/xslt20/some.xml
[stammw@br8ggx73 xslt20]$ 
[stammw@br8ggx73 xslt20]$ cat ls.xsl 
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>
  <xsl:output omit-xml-declaration="yes" />
 
  <xsl:template match="/">
    <xsl:for-each 
select="collection('file:///home/stammw/xslt/xslt20/?select=*;recurse=yes;on-error=ignore')">
      <xsl:value-of select="document-uri(.)"/><xsl:text>&#10;</xsl:text>
    </xsl:for-each>
  </xsl:template>
 
</xsl:stylesheet>
[stammw@br8ggx73 xslt20]$ 


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
Fixpack team lead
WebSphere DataPower SOA Appliances
https://www.ibm.com/developerworks/mydeveloperworks/blogs/HermannSW/
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294 



From:   Andrew Welch <andrew.j.welch@xxxxxxxxx>
To:     xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Date:   07/05/2011 10:15 AM
Subject:        Re: [xsl] Java list extension



> Now I need a way to discover the contents of a directory (files and
> other directorys). So far I have:

You can get a list of all the files in the directory and
subdirectories by doing:

<xsl:for-each 
select="collection('file:///path/to/dir/?select=*;recurse=yes;on-error=ignore')">
  <xsl:value-of select="document-uri(.)"/>


-- 
Andrew Welch
http://andrewjwelch.com

Current Thread