xslt - count xml files

Hi
I need to generate XML content that is based on the number of specific XML files (identified by namespace) that exists.
How can one retrieve the count of xml files in a specific location using xpath/xslt ??
thanks in advance!
[255 byte] By [eils] at [2007-11-18 20:31:16]
# 1 Re: xslt - count xml files
The only way to access external xml files from xsl is by using the xpath function 'document(file)'. But to use this function you have to know the names of the files to be counted.
If you have some way of getting the file names of the files you wish to count you could write something like this<xsl:value-of select="count(document(expression selecting the files to be counted)/namespace:*)"/>
If you have no way of getting the names of the files to be counted, then it can't be done.

In Cocoon, which is the environment I usally use, I have a directory reader, that I can use turn a dirrectory listing into an xml document, which I can then use to get the files in a particular directory. So I might write something like

<xsl:value-of select="count(document(document('/directory/path')/dir:directory/dir:file[contains(@name,'.xml']/@name))/namespace:*)"/>
Provided that cocoon has been setup to return a directory listing for/directory/path and allows access to the xml files. How to do this in other environments I do not know. But obviously xsl was never intended to be used for counting xml files.
khp at 2007-11-10 3:28:14 >