Re: [xsl] collecting a fileset with XSLT 2.0

Subject: Re: [xsl] collecting a fileset with XSLT 2.0
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 06 Feb 2012 12:17:15 -0500
Hi Mark,

In addition to what Ken says, two other things:

Some processors, Saxon included, will accept a list of documents for the collection() function from a file. So you only have to contrive a way of getting the files you are interested in listed in the syntax it expects.


Plus, there's also a (rather crude) escape hatch. In addition to whatever is supported by the local implementation of collection(), keep in mind that you can get any document's URI using the document-uri() function, and it's a string, so you can use it to filter documents.

So something like


Obviously this is likely to quite expensive since every document (or every XML document) is subject to being retrieved before the ones you don't want are discarded. But by the same token it is very flexible.


On 2/5/2012 4:25 PM, Mark Giffin wrote:
Thanks Ken! This does help, I'll check it out. That info is not in
Michael Kay's XSLT 2.0 book. I'll blame him. Just kiddin.


On 2/5/2012 12:56 PM, G. Ken Holman wrote:
At 2012-02-05 12:51 -0800, Mark Giffin wrote:
Is there a way to collect a set of files off the file system in XSLT
2.0, in the same way that Ant lets you define a set of files with
<fileset> like this:

<fileset dir="${src.dir}" id="">
<include name="**/*.xml"/>
<exclude name="**/gui/*.*"/>
<exclude name="tools/**/*.*"/>
<exclude name="content/extra/**/*.*"/>

Maybe an extension function or something? I've been using a
manually-maintained list of files like this, but it's a a pain:

<root href="../../../doc_source/system100.xml" />
<root href="../../../doc_source/content/access/accesscore.xml" />
<root href="../../../doc_source/content/access/accesstest.xml" />
href="../../../doc_source/content/access/accesstest_commands.xml" />

The concept in XSLT2 is the function collection(uri) which returns a set of root nodes of all the XML files addressed by the URI.

There is no standard for the URI string, so you have to read your
vendor's documentation regarding how to compose the URI for what you
want. For example, for Saxon, you would address all the XML files in
the current and descendent subdirectories with something along the
lines of:


I hope this helps.

. . . . . . . . . . . Ken

-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread