Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] xslt2: Retrieving a directory's non-XML file names

From: Yves Forkl <Y.Forkl@------>
To:
Date: 10/1/2008 10:08:00 AM
Hi,



from a directory whose path is stored in $myDir I would like to retrieve 
the names of all files with extension ".txt". Of course that could be 
done easily using shell mecanisms, but I want to do this using XSLT 2 
(with Saxon) only.



That appears to be somewhat difficult, at least I couldn't find the 
solution anywhere. Knowing that collection() allows to access all of the 
XML documents in a given directory, I tried this:



    <xsl:variable name="txt_files" as="xs:string*">
      <xsl:for-each
        select="collection(concat($myDir,
          '?select=*.txt;on-error=warn'))/saxon:discard-document(.)">
        <xsl:value-of select="unparsed-entity-uri(.)"/>
      </xsl:for-each>
    </xsl:variable>

This gives me



"Error SXXP0003: Error reported by XML parser: Premature end of file.
Transformation failed: Run-time errors were reported"

I guess the reason is that collection() is unable to return the document 
node for any of these text files.



So how to obtain the list of .txt files from my directory in XSLT 2?



  Yves


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent