ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank E. Weiss" <>
Subject Re: How to implement loop constructs etc.. in ant build file?
Date Sat, 22 Sep 2001 00:50:45 GMT
> > 3. Source contents of an external .xml file into the current
> > build.xml file?
> There is no ant specific feature to include other xml files. Alternative
> features that are close are:
> * the "ant" task which invokes a target in another build file
> * the XML's "include" feature using entities

You're forgetting the best one - XSLT. For example:

<target name="cook-alpha" depends="take1/cook.xsl">
    <ant antfile="take1/build-alpha.xml"/>

What this does: The cook.xsl stylesheet outputs an 'ant' xml document. It uses
the alpha_index.xml document to get a set of files that need to be 'cooked'. The
ant xml document it puts out, build-alpha.xml, has one ant target with a set of
'get' commands for each file it found in alpha_index.xsl. That ant file is then
input to an ant subprocess. It's similar to using awk to build a shell file and
then feeding awk's output to a subshell.

Here's the cook.xsl stylesheet:

 <!-- cook an asp page into static html -->
 <!-- input document contains set of possible keys -->

 <xsl:output method="xml" indent="yes"/>

 <xsl:template match="alpha-index">
  <project name="cooker" default="build-alpha" basedir="..">
   <target name="build-alpha">
    <xsl:for-each select="alpha-key">
      <xsl:attribute name="src">
      <xsl:attribute name="dest">
       <xsl:value-of select="concat('w:/html/alpha_index.', node(), '.html')"/>


View raw message