xsl-list
[Top] [All Lists]

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

2008-10-01 08:31:41
So how to obtain the list of .txt files from my directory in XSLT 2?

Andrew Welch wrote:

you could try this:

http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200607/msg00570.html

....should work fine.

Thank you both for your helpful suggestions. I especially like yours, Andrew (actually based on a suggestion from Michael back in 2006...), as it spares me from developing an extension function on its own. Using the Java IO lib, however, is fine for me, as I don't plan to move away from Saxon anytime in the near future.

With the desired filter for .txt files added, my minimally Java-based XSLT 2 solution reads:

xmlns:File="java:java.io.File"

...

<xsl:variable name="txt_files"
  select="for $filename in File:list(File:new($myDir))
            return $filename[matches(., '\.txt$')]"/>


Someone else might perhaps prefer doing the filtering in Java, too.

  Yves

--~------------------------------------------------------------------
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>