[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: xslt2: Retrieving a directory's non-XML file names
From: Yves Forkl <Y.Forkl@xxxxxx>
Date: Wed, 01 Oct 2008 12:07:20 +0200
 xslt2: Retrieving a directory's non-XML file names
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.