[xsl] Merging an dynamic set of XML files into 1 with ANT / XSLT ?

Subject: [xsl] Merging an dynamic set of XML files into 1 with ANT / XSLT ?
From: Jérôme Haguet <j.haguet@xxxxxxxxxx>
Date: Tue, 11 Dec 2007 16:29:26 +0100

I have to extract XML elements from a set of XML files, and to gather these
elements into one XML file.
(Let's imagine each XML file is a chapter, and I want to extract Title element
to build the Table Of Contents)
I have to do this using an ANT target.

My main problem is that is must be DYNAMIC : I have to scan the contents of a
folder, sort files alphabetically, and build the TOC according to that.

I already wrote something STATIC (list of file hardcoded in the ANT file) :
I have one XSLT task which add a new chapter title to the TOC, passing the XML
file as an XSLT parameter.

<xsl:stylesheet version="1.0"

  <xsl:output method="xml"  encoding="utf-8" indent="yes"/>

  <xsl:param name="P_moduleFile"/>

  <xsl:variable name="modDoc"   select="document($P_moduleFile)"/>

  <!-- identity template -->
  <xsl:template match="@* | node()">
    <xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy>

  <xsl:template match="/*">
      <xsl:apply-templates select="@* | node()"/>
        <xsl:attribute name="name"><xsl:value-of
        <xsl:apply-templates select="$modDoc/STR-module/text"/>
        <xsl:apply-templates select="$modDoc/STR-module/description"/>


Any idea how to make a DYNAMIC version of this ?


Current Thread