File Module

From EXPath Community Group
Jump to: navigation, search

Examples

file:list

The function file:list() returns a sequence of strings. Consider the following stylesheet:

 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns:file="http://expath.org/ns/file"
                 exclude-result-prefixes="#all"
                 version="2.0">
 
    <xsl:output indent="yes"/>
 
    <xsl:template match="/" name="main">
       <file-list>
          <xsl:for-each select="file:list('/')">
             <file>
                <xsl:value-of select="."/>
             </file>
          </xsl:for-each>
       </file-list>
    </xsl:template>
 
 </xsl:stylesheet>

This has been tested with Saxon:

 $ xrepo create test-repo
 $ xrepo --repo test-repo install http://cxan.org/file/expath/file-saxon/expath-file-saxon-0.5.0.xar
 $ saxon --repo test-repo -xsl:file-example.xsl -it:main
 <file-list>
    <file>bin/</file>
    ...
    <file>usr/</file>
    <file>var/</file>
 </file-list>