Using only Ant and XSLT, I'd like to create an XML file that is a list of XML files in a specific directory.
Ant's concat task doesn't do the job as I end up with a list that's not XML -- ie. it doesn't have a single root element.
I have an XSLT file that I apply, using the XSLT Ant task, that uses the collection() function. This produces exactly the result I want, but it tries to do so for each file in the target directory -- I want just one list. My XSLT is operating on every file in the target directory (collection) -- how can I limit the number of tims the XSLT is applied?
Here's what I have so far:
XML files are in the target directory c:\tmp
This is the XSL file that I apply to the files in the target directory (using the Ant XSLT task);
<xsl:template match="/">
<xsl:call-template name="generatelist" />
</xsl:template>
<xsl:template name="generatelist">
<xsl:result-document href="list.xml">
<xsl:element name="list">
<xsl:element name="dir">
<xsl:for-each
select="collection('file:///C:/tmp?select=*.xml')">
<xsl:element name="file">
<xsl:attribute name="name">
<xsl:value-of select="tokenize(document-uri(.), '/')[last()]" />
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:result-document>
</xsl:template>
And this is the resulting XML list:
<list>
<dir>
<file name="filename_1.xml"/>
<file name="filename_2.xml"/>
. . .
<file name="filename_n.xml"/>
</dir>
</list>
Thanks.
Drew
Adding the Ant XSLT task that I'm using:
<xslt basedir="${staging_2}"
destdir="${staging_3}" extension=".xml" includes="**/*.xml"
style="create_list.xsl">
</xslt>
collection(iri-to-uri('./files/?select=*.xml'), but that's not it.