xsl-list
[Top] [All Lists]

Re: [xsl] Java list extension

2011-07-05 07:09:18
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(_dot_)j(_dot_)welch(_at_)gmail(_dot_)com>
To:     xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>