<project name="copyXMLFiles" default="fileAvailable">
  <target name="copyXMLFiles" if="file.available.and.required">
    <!-- Load in the some properties -->
    <loadproperties srcFile="ant.properties"/>

    <!-- Resolve any xincludes -->
    <exec executable="xmllint">
      <arg line="--xinclude" /> 
      <arg line="${inputdir}/${item}.xml" /> 
      <arg line="-o ${src}/${item}.xml" /> 
    </exec>

    <!-- Make the output directory -->
    <mkdir dir="${outputdir}"/>

    <copy file="${src}/${item}.xml" tofile="${outputdir}/${item}.xml"/>

    <!-- Clean up-->
    <delete file="${src}/${item}.xml"/>
  </target>

  <target name="fileAvailable" description="Makes sure file is available to copy and copying is required">
    <condition property="file.available.and.required">
      <and>
        <available file="${inputdir}/${item}.xml"/>
        <or>
          <not><available file="${outputdir}/${item}.xml"/></not>
          <uptodate targetfile="${inputdir}/${item}.xml" srcfile="${outputdir}/${item}.xml"/>
        </or>
      </and>
    </condition>
    <antcall target="copyXMLFiles"/>
  </target>

</project>

