Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Yves Forkl <Y.Forkl@------>
To:
Date: 10/1/2008 12:32:00 PM
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


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