xsl-list
[Top] [All Lists]

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

2007-12-11 08:30:20
Hello 

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"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 
  <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>
 
  <xsl:template match="/*">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
      <module>
        <xsl:attribute name="name"><xsl:value-of 
select="$modDoc/STR-module/@name"/></xsl:attribute>
        <xsl:apply-templates select="$modDoc/STR-module/text"/>
        <xsl:apply-templates select="$modDoc/STR-module/description"/>
      </module>
    </xsl:copy>
  </xsl:template>
 
</xsl:stylesheet>

 
Any idea how to make a DYNAMIC version of this ? 

Regards
 
 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--