<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright 1999-2007 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->

<!-- ===================================================================

   Build file for Xalan-J 2.x - for use with the Jakarta Ant java build tool
   
Setup instructions: 
   Before running an Ant build, you must
   
     - set the JAVA_HOME environment variable to the JDK root directory
     - To build 'servlet' sample: Include Servlet SDK in your classpath
     - To build docs/javadocs/xsltc: use JDK 1.2.x or higher
   
Build Instructions:   
  To build, run
    build.bat (win32) or build.sh (unix) [antoptions] [targets]
  in the directory where this file is located; you should also be 
  able to use an installation of Ant v1.4.1 or later.
   
  build -projecthelp  will show a list of supported targets.
   
  Developers: include a description="" attribute in all user-callable targets.
        
  If you build a target that depends on other targets, those other 
  targets are *usually* created in the correct order; however a 
  few of the larger targets like dist do not list all dependencies.

Other Important Notes:
- 'dist' produces a .tar file that works with GNU compatible tar 
  programs, because that's what Ant does when it finds a path that's 
  longer than 100 characters (like in our docs).  Sorry!
  
- External build maintainers: look for GUMP: comments; developers 
  please use great caution when changing these lines!

- Unusual build items: the docs and xsltc.compile targets leave 
  cruft in the source areas; various clean targets get most of this.
  
Authors:
  Shane Curcuru <shane_curcuru@lotus.com>
  Don Leslie <donald_leslie@lotus.com>

$Id: build.xml 563656 2007-08-07 21:12:16Z kcormier $
==================================================================== -->

<project name="Xalan" default="jar" basedir=".">

  <property name="name"                   value="xalan"/>
  <property name="year"                   value="2006"/>
  <property name="build.debug"            value="on"/>

  <!-- Xalan Java version information -->
  <property name="version.VERSION"        value="2"/>
  <property name="version.RELEASE"        value="7"/>
  <property name="version.DEVELOPER"      value=""/><!-- Set this to 'D' if a developer release; blank "" if maintenance release -->
  <property name="version.MINOR"          value="1"/><!-- EITHER the developer release number, or a maintenance release number -->
  <property name="version"                value="${version.VERSION}_${version.RELEASE}_${version.DEVELOPER}${version.MINOR}"/><!-- GUMP: version # of dist file -->
  <property name="impl.version"           value="${version.VERSION}.${version.RELEASE}.${version.DEVELOPER}${version.MINOR}"/><!-- Used in jar task for filtering MANIFEST.MF file -->
  
  <!-- Xerces Java version information -->
  <property name="parser.version.VERSION" value="2"/>
  <property name="parser.version.RELEASE" value="9"/>
  <property name="parser.version.MINOR"   value="0"/> 
  
  <!-- Xalan Java directories -->  
<!--  <property name="bin.dir"                value="./bin"/> -->
  <property name="build.dir"              value="./build"/> 
  <property name="lib.dir"                value="./lib"/>   
  <property name="samples.dir"            value="./samples"/>   
  <property name="src.dir"                value="./src"/>  
  <property name="tools.dir"              value="./tools"/> 
  <property name="xdocs.dir"              value="./xdocs"/>
    
  <property name="apachexml.reldir"       value="org/apache/xml"/>
  <property name="serializer.reldir"      value="org/apache/xml/serializer"/>
  <property name="xpath.reldir"           value="org/apache/xpath"/>
  <property name="xalan.reldir"           value="org/apache/xalan"/>
  <property name="domxpath.reldir"        value="org/w3c/dom/xpath"/>
  <property name="xsltc.reldir"           value="${xalan.reldir}/xsltc"/>  

  <!-- Jars needed to run Xalan Java (Interpretive, Compiled, or both) -->
  <property name="xmlapis.jar.name"       value="xml-apis.jar"/>
  <property name="xmlapis.jar"            value="${lib.dir}/${xmlapis.jar.name}"/>
  <property name="parser.jar.name"        value="xercesImpl.jar"/>
  <property name="parser.jar"             value="${lib.dir}/${parser.jar.name}"/>
  <property name="bcel.jar.name"          value="BCEL.jar"/>
  <property name="bcel.jar"               value="${lib.dir}/${bcel.jar.name}"/>
  <property name="runtime.jar.name"       value="runtime.jar"/>
  <property name="runtime.jar"            value="${lib.dir}/${runtime.jar.name}"/>
  <property name="regexp.jar.name"        value="regexp.jar"/>
  <property name="regexp.jar"             value="${lib.dir}/${regexp.jar.name}"/>
  
  <!-- Jars need to build Xalan Java (Interpretive, Compiled, or both) or build the docs -->
  <property name="java_cup.jar.name"      value="java_cup.jar"/>
  <property name="java_cup.jar"           value="${tools.dir}/${java_cup.jar.name}"/>
  <property name="jlex.jar.name"          value="JLex.jar"/>
  <property name="jlex.jar"               value="${tools.dir}/${jlex.jar.name}"/>  
  <property name="stylebook.jar.name"     value="stylebook-1.0-b3_xalan-2.jar"/>
  <property name="stylebook.jar"          value="${tools.dir}/${stylebook.jar.name}"/>
  <property name="doclet.jar.name"        value="xalan2jdoc.jar"/>
  <property name="doclet.jar"             value="${tools.dir}/${doclet.jar.name}"/>
  <property name="taglet.jar.name"        value="xalan2jtaglet.jar"/>
  <property name="taglet.jar"             value="${tools.dir}/${taglet.jar.name}"/>

 
  <!-- Relative locations of source directories -->
  <property name="manifest.mf"            value="./src/MANIFEST.MF"/>
  <property name="manifest.xsltc.mf"      value="./src/manifest.xsltc"/>
  <property name="manifest.xalan-interpretive.mf" value="./src/manifest.xalan-interpretive"/>  
  <property name="XSLTInfo.props"         value="./src/org/apache/xalan/res/XSLTInfo.properties"/>  
  <property name="generated.xpathparser"  value="${src.dir}/${xsltc.reldir}/compiler/XPathParser.java"/>
  <property name="generated.xpathlexer"   value="${src.dir}/${xsltc.reldir}/compiler/XPathLexer.java"/>
  <property name="generated.xpathsym"     value="${src.dir}/${xsltc.reldir}/compiler/sym.java"/>
  
  <!-- Build and distribution output areas -->
  <property name="build.xalan.jar"              value="${build.dir}/${name}.jar"/><!-- GUMP: actual path/name of jar target output -->
  <property name="build.xalan-unbundled.jar"    value="${build.dir}/${name}-unbundled.jar"/>
  <property name="build.xalan-interpretive.jar" value="${build.dir}/${name}.jar"/>
  <property name="build.xsltc.jar"              value="${build.dir}/xsltc.jar"/>
  <property name="build.classes"                value="${build.dir}/classes"/>
  <property name="build.docs"                   value="${build.dir}/docs"/>
  <property name="build.samples"                value="${build.dir}/samples"/>
  <property name="build.servlet"                value="${build.samples}/servlet"/>
  <property name="build.apidocs"                value="${build.docs}/apidocs"/>
  <property name="dist.pkg"                     value="${name}-j_${version}"/><!-- GUMP: actual path/name of dist target .tar.gz/.zip-->
  <property name="dist.file"                    value="${dist.pkg}"/>
  <property name="dist.dir"                     value="${build.dir}/${dist.pkg}"/>
  
  <!-- xml-commons sources (for Javadoc) -->                                                                        
  <property name="xml-commons-srcs.tar.gz"      value="${src.dir}/xml-commons-external-1.3.02-src.tar.gz"/>
  <property name="xml-commons-srcs.tar"         value="${build.dir}/xml-commons-external-1.3.02-src.tar"/>
 
  <!-- Documentation and samples information  -->
  <property name="Name-in-docs"                 value="Xalan-Java"/>
  <property name="version.file"                 value="${xalan.reldir}/processor/XSLProcessorVersion.java"/>
  
  <property name="build.samples.jar"            value="${build.dir}/xalansamples.jar"/>
  <property name="build.servlet.war"            value="${build.dir}/xalanservlet.war"/>
  <property name="build.xsltc.applet.jar"       value="${build.dir}/xsltcapplet.jar"/>
  <property name="build.xsltc.brazil.jar"       value="${build.dir}/xsltcbrazil.jar"/>
  <property name="build.xsltc.ejb.jar"          value="${build.dir}/xsltcejb.jar"/>
  <property name="build.xsltc.servlet.jar"      value="${build.dir}/xsltcservlet.jar"/>
  
  <property name="xdocs.book"                   value="${xdocs.dir}/sources/xalan-jlocal.xml"/>
  <property name="xdocs.style"                  value="${xdocs.dir}/style"/>
  <property name="xalanonly-styledocs"
            value="dtd/xsl-html40s.dtd,dtd/spec.dtd,stylesheets/patterns.xsl,stylesheets/notice.xsl,stylesheets/spec.xsl,stylesheets/done.xsl,loaderdesign.xml,stylesheets/design2project.xsl,stylesheets/designdoc2html.xsl,stylesheets/xml2fo.xsl"/>
  <property name="xalan.cmdline.class"          value="org.apache.xalan.xslt.Process"/>
  <property name="doc.generator"                value="org.apache.stylebook.StyleBook"/>
  <property name="doc.generator.styletargz"     value="${xdocs.dir}/xml-site-style.tar.gz"/>
  <property name="doc.generator.styletar"       value="${xdocs.dir}/xml-site-style.tar"/>
  
  <property name="site.root"                    value="./xml-site"/>
  <property name="site.dir"                     value="${site.root}/target/xalan-j"/>
  <property name="site.book"                    value="${xdocs.dir}/sources/xalan-jsite.xml"/>
  
  <property name="xalan.apache.org.site.root"   value="./xalan-apache-org-site"/>
  <property name="xalan.apache.org.site.dir"    value="${xalan.apache.org.site.root}/target/xalan-apache-org"/>
  <property name="xalan.apache.org.site.book"   value="${xdocs.dir}/sources/xalan-apache-org-site.xml"/>  
  
  
  <property name="xdocs.DONE.file"              value="${xdocs.dir}/sources/xalan/DONE"/>
  <property name="xdocs.XSLTCDONE.file"         value="XSLTCDONE"/>
  <property name="xdocs.XSLTCDONE.location"     value="${xdocs.dir}/sources/xalan/${xdocs.XSLTCDONE.file}"/>

      
  <!-- PROPERTIES TO COMPILE THE SERIALIZER  ======================================= -->  
  <property name="serializer.src.dir"           value="./src"/>
  <property name="serializer.build.dir"         value="./build"/> 
  <property name="serializer.build.classes"     value="${serializer.build.dir}/serializer"/> 
  
  <!-- PROPERTIES TO MAKE THE SERIALIZER JAR ======================================= -->
  <property name="serializer.manifest.basename" value="MANIFEST.SERIALIZER"/> 
  <property name="serializer.manifest"          value="${serializer.src.dir}/${serializer.manifest.basename}"/>
  <property name="serializer.impl.version"      value="${impl.version}"/>
  <property name="serializer.java.version"      value="${java.version}"/>
  <property name="serializer.java.vendor"       value="${java.vendor}"/>
  <property name="serializer.jar.name"          value="serializer.jar"/>   
  <property name="build.serializer.jar"         value="${serializer.build.dir}/${serializer.jar.name}"/> 
  <property name="lib.serializer.jar"           value="./lib/${serializer.jar.name}"/>   
 
  <!-- Class paths used in various targets -->
  <path id="docs.class.path">
    <pathelement location="${xmlapis.jar}" />
    <pathelement location="${parser.jar}" />
    <pathelement location="${bcel.jar}" />
    <pathelement location="${runtime.jar}" />
    <pathelement location="${stylebook.jar}" />
    <pathelement location="${doclet.jar}" />
    <pathelement location="${taglet.jar}" />
    <pathelement location="${build.serializer.jar}" />
    <pathelement location="${build.xalan.jar}" />
    <pathelement path="${java.class.path}" />
  </path>
  <path id="samples.class.path">
    <pathelement location="${xmlapis.jar}" />
    <pathelement location="${build.serializer.jar}" />    
    <pathelement location="${parser.jar}" />  
    <pathelement location="${build.xalan.jar}" />
    <pathelement path="${java.class.path}" />
  </path>
  <path id="compile.class.path">
    <!-- Ensure the selected parser.jar file is used to compile against -->
    <pathelement location="${build.classes}" />
    <pathelement location="${serializer.build.classes}" />    
    <pathelement location="${xmlapis.jar}" />
    <pathelement location="${build.serializer.jar}" />
    <pathelement location="${parser.jar}" />
    <pathelement path="${java.class.path}" />
  </path>
  <path id="xslt.boot.class.path">
    <!-- Put this version of xalan in front of the jdk's for JDK 1.4+ -->
    <!-- Set build.boot.class.path to a JDK 1.1.x classes.zip file to check
         compatibility with 1.1.x.  If you omit this property, compatability
         with 1.1.x will not be checked even though javac specifies a target of 1.1 -->
    <pathelement location="${build.classes}" />
    <pathelement location="${serializer.build.classes}" />
    <pathelement location="${xmlapis.jar}" />
    <pathelement location="${build.serializer.jar}" />    
    <pathelement location="${parser.jar}" />   
    <pathelement path="${build.boot.class.path}" />
    <pathelement path="${sun.boot.class.path}" />
  </path>
  <path id="compile.source.path">
    <dirset dir="${src.dir}" includes="/org/apache/**" />
  </path>

  <!-- patternsets for source and binary distribution packages -->
  <patternset id="bin-distro" >
    <include name="${dist.file}/LICENSE.txt"/>
    <include name="${dist.file}/NOTICE.txt"/>
    <include name="${dist.file}/readme.html"/>
    <include name="${dist.file}/xalan.jar"/>
    <!-- xsltc.jar will only be picked up if it has been built -->
    <include name="${dist.file}/xsltc.jar"/>     
    <include name="${dist.file}/${xmlapis.jar.name}"/>
    <include name="${dist.file}/${parser.jar.name}"/>
    <include name="${dist.file}/${serializer.jar.name}"/>
    <include name="${dist.file}/samples/"/>    
    <include name="${dist.file}/samples/xalansamples.jar"/>
    <include name="${dist.file}/samples/xalanservlet.war"/>
    <include name="${dist.file}/samples/xsltcapplet.jar"/>
    <include name="${dist.file}/samples/xsltcbrazil.jar"/>
    <include name="${dist.file}/samples/xsltcejb.jar"/>
    <include name="${dist.file}/samples/xsltcservlet.jar"/>
    <include name="${dist.file}/docs/"/>
  </patternset>
  <patternset id="bin-distro-nodocs" >
    <include name="${dist.file}/LICENSE.txt"/>
    <include name="${dist.file}/NOTICE.txt"/>
    <include name="${dist.file}/readme.html"/>
    <include name="${dist.file}/xalan.jar"/>
    <!-- xsltc.jar will only be picked up if it has been built -->
    <include name="${dist.file}/xsltc.jar"/>    
    <include name="${dist.file}/${xmlapis.jar.name}"/>
    <include name="${dist.file}/${parser.jar.name}"/>
    <include name="${dist.file}/${serializer.jar.name}"/>
    <include name="${dist.file}/samples/"/>        
    <include name="${dist.file}/samples/xalansamples.jar"/>
    <include name="${dist.file}/samples/xalanservlet.war"/>
    <include name="${dist.file}/samples/xsltcapplet.jar"/>
    <include name="${dist.file}/samples/xsltcbrazil.jar"/>
    <include name="${dist.file}/samples/xsltcejb.jar"/>
    <include name="${dist.file}/samples/xsltcservlet.jar"/>
  </patternset>
  <patternset id="src-distro" >
    <include name="${dist.file}/LICENSE.txt"/>
    <include name="${dist.file}/NOTICE.txt"/>      
    <include name="${dist.file}/build.*"/>
    <include name="${dist.file}/commits.xml"/>
    <include name="${dist.file}/KEYS"/>
    <include name="${dist.file}/readme.html"/>  
    <include name="${dist.file}/lib/"/>
    <include name="${dist.file}/tools/"/>
    <include name="${dist.file}/samples/"/>
    <exclude name="${dist.file}/samples/xalansamples.jar"/>
    <exclude name="${dist.file}/samples/xalanservlet.war"/>
    <exclude name="${dist.file}/samples/xsltcapplet.jar"/>
    <exclude name="${dist.file}/samples/xsltcbrazil.jar"/>
    <exclude name="${dist.file}/samples/xsltcejb.jar"/>
    <exclude name="${dist.file}/samples/xsltcservlet.jar"/>    
    <include name="${dist.file}/src/"/>
    <include name="${dist.file}/xdocs/"/>
  </patternset>

  <!-- XSLTC engine dependency .jar files -->    
  <patternset id="xsltc-deps-jars" >
    <include name="${dist.file}/lib/${bcel.jar.name}"/>
    <include name="${dist.file}/tools/${java_cup.jar.name}"/>
    <include name="${dist.file}/tools/${jlex.jar.name}"/>
    <include name="${dist.file}/lib/${runtime.jar.name}"/>
    <include name="${dist.file}/lib/${regexp.jar.name}"/>
  </patternset>

  <!-- =================================================================== -->
  <!-- Creates output build directories and doc prerequistes               -->
  <!-- =================================================================== -->
  <target name="prepare">
    <echo message="Project:${Name-in-docs} version:${version} build.xml $Revision$"/>
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.classes}"/>
    <!-- Note that all testing-related targets *must* depend on 
         this target, either directly or indirectly, to get 
         the tests-available property set for them.
    -->
    <available file="${test.relpath}" property="tests-available" />
    <available property="xerces.present" 
      classname="org.apache.xerces.parsers.SAXParser"/>
      
    <!-- Update version information.  This copies the Version.src
         file into Version.java, while replacing the following tokens
    -->
    <filter token="version.VERSION"          value="${version.VERSION}"/>  
    <filter token="version.RELEASE"          value="${version.RELEASE}"/>
    <filter token="version.MINOR"            value="${version.MINOR}"/>
    <filter token="version.DEVELOPER"        value="${version.DEVELOPER}"/> 
    <filter token="parser.version.VERSION"   value="${parser.version.VERSION}"/>  
    <filter token="parser.version.RELEASE"   value="${parser.version.RELEASE}"/>
    <filter token="parser.version.MINOR"     value="${parser.version.MINOR}"/>    
    <copy tofile="${src.dir}/${xalan.reldir}/Version.java" file="${src.dir}/${xalan.reldir}/Version.src" filtering="true"/>
    <copy tofile="${src.dir}/${xalan.reldir}/processor/XSLProcessorVersion.java" file="${src.dir}/${xalan.reldir}/processor/XSLProcessorVersion.src" filtering="true"/>    
    <copy tofile="${src.dir}/${serializer.reldir}/Version.java" file="${src.dir}/${serializer.reldir}/Version.src" filtering="true"/>
    <copy tofile="${xdocs.dir}/sources/entities.ent" file="${xdocs.dir}/sources/entities.src" filtering="true"/>
  </target>

  <!-- Must depend on jar since we use Xalan to process xml files -->
  <target name="prepare.docs" depends="jar,prepare.docs.nojardepends"/>
  
  <target name="prepare.docs.nojardepends">  
    <mkdir dir="${build.docs}"/> 
    <mkdir dir="${build.apidocs}"/>

    <gunzip src="${doc.generator.styletargz}"/>
    <untar src="${doc.generator.styletar}" dest="${xdocs.dir}"/>
    <delete file="${doc.generator.styletar}"/>

    <!-- We use a sed script to extract Xalan-Java 2 commits from the repository into commits.xml
         The following operation transforms commits.xml (just including source code commits) and 
         puts the result in xdocs/sources/xalan for inclusion in the readme.xml -->      
    <echo message="Transform commits.xml and put the result in ${xdocs.dir}"/>
    <java fork="yes" classname="${xalan.cmdline.class}" >
      <classpath refid="docs.class.path" />
      <arg line="-in commits.xml -xsl ${xdocs.style}/stylesheets/done.xsl -out ${xdocs.DONE.file} -param xsltcdone ${xdocs.XSLTCDONE.file}"/>
    </java>
    <echo message="Generate Xalan-J 2.x design document"/>
    <java fork="yes" classname="${doc.generator}" >
      <classpath refid="docs.class.path" />
      <arg line="loaderConfig=sbk:/style/loaderdesign.xml targetDirectory=./build/docs/design/
                 ./xdocs/sources/xalandesign.xml ./xdocs/style"/>
    </java>
  </target>

  <!-- =================================================================== -->
  <!-- Compile the DTM implementation and xml utilities                    -->
  <!-- =================================================================== -->
    <target name="xml.compile" depends="prepare,serializer.jar">
    <echo message="Compiling DTM implementation and utilities" />
    <javac srcdir="${src.dir}"
           destdir="${build.classes}"
           debug="${build.debug}" >
      <include name="${apachexml.reldir}/**/*.java" />
      <!-- exclude the serializer -->
      <exclude name="${serializer.reldir}/**/*.java" />      
      <!-- Exclude file that depends upon presence of Xerces in build path -->
      <exclude name="**/IncrementalSAXSource_Xerces.java" 
        unless="xerces.present"	 />
      <classpath refid="compile.class.path" />
      <bootclasspath refid="xslt.boot.class.path" />
    </javac>
    <!-- Copy needed properties, resource, etc. files to be put into .jar file -->
    <copy todir="${build.classes}">
      <fileset dir="${src.dir}" 
          includes="${apachexml.reldir}/**/*.properties" 
          excludes="${serializer.reldir}/**/*.properties"
      />
    </copy>  
  </target>
  
  <!-- =================================================================== -->
  <!-- Compile the Xalan interpreter source tree                           -->
  <!-- =================================================================== -->
  <target name="xalan-interpretive.compile" depends="xml.compile"
    description="Compile the Xalan interpretive classes (skips XSLTC)" >
    <echo message="Compiling Xalan interpretive classes" />
    <javac srcdir="${src.dir}" 
           destdir="${build.classes}"
           debug="${build.debug}" >
      <include name="${xpath.reldir}/**/*.java" />
      <include name="${domxpath.reldir}/**/*.java" />
      <include name="${xalan.reldir}/**/*.java" />
      <exclude name="${xsltc.reldir}/**/*.java" />
      <classpath refid="compile.class.path" />
      <bootclasspath refid="xslt.boot.class.path" />
      <sourcepath refid="compile.source.path" />
    </javac>
    <!-- Copy needed properties, resource, etc. files to be put into .jar file -->
    <copy todir="${build.classes}">
      <fileset dir="${src.dir}" includes="**/*.properties,META-INF/services/*" excludes="**/XSLTInfo.properties"/>
    </copy>  
    <filter token="impl.version" value="${impl.version}"/>
    <copy todir="${build.classes}/org/apache/xalan/res" file="${XSLTInfo.props}" filtering="true"/>
  </target>
  
  <!-- Compile all java sources (Xalan interpretive and XSLTC) -->
  <target name="compile" depends="xalan-interpretive.compile,xsltc.compile"
    description="Compile all java source files (Xalan interpretive + XSLTC)" >
  </target>

  <!-- =================================================================== -->
  <!-- Compile just the XSLTC compiler portion                             -->
  <!-- =================================================================== -->
  <path id="xsltc.class.path">
    <pathelement location="${xmlapis.jar}" />
    <pathelement location="${build.serializer.jar}" />
    <pathelement location="${bcel.jar}" />
    <pathelement location="${jlex.jar}" />
    <pathelement location="${java_cup.jar}" />
    <pathelement location="${runtime.jar}" />
    <!-- build.classes needed for 
         org.apache.xalan.xsltc.util.JavaCupRedirect -->
    <pathelement location="${build.classes}" />
    <pathelement path="${java.class.path}" />
  </path>

  <!-- Attempt to determine dependency info for generated sources -->
  <target name="xsltc.prepare" depends="prepare" >
    <!-- The first step compiles the utils directory, which includes 
         a special wrapper for the xsltc.codegen / java_cup step next. -->
    <echo message="Compiling XSLTC utilities"/>
    <javac srcdir="${src.dir}" 
           destdir="${build.classes}"
           includes="${xsltc.reldir}/util/**/*.java"
           debug="${build.debug}">
      <classpath refid="xsltc.class.path" />
      <bootclasspath refid="xslt.boot.class.path" />
    </javac>
    <!-- These tricky uptodate statements hopefully determine if we 
         actually need to generate the java_cup and jlex files 
         in the two sub-targets below
    -->
    <uptodate property="xsltc.java_cup.not_needed" targetfile="${generated.xpathparser}" >
      <srcfiles dir="${src.dir}/${xsltc.reldir}/compiler" includes="xpath.cup" />
    </uptodate>

    <uptodate property="xsltc.jlex.not_needed" targetfile="${generated.xpathlexer}" >
      <srcfiles dir="${src.dir}/${xsltc.reldir}/compiler" includes="xpath.lex" />
    </uptodate> 
    
    <!-- Determine whether the support jars are already expanded -->
    <available file="${build.classes}/org/apache/bcel"     type="dir" property="xsltc.bcel_jar.not_needed" />
    <available file="${build.classes}/JLex"                type="dir" property="xsltc.jlex_jar.not_needed" />
    <available file="${build.classes}/java_cup/Main.class" type="file" property="xsltc.java_cup_jar.not_needed" />
    <available file="${build.classes}/java_cup/runtime"    type="dir" property="xsltc.runtime_jar.not_needed" />
    <available file="${build.classes}/org/apache/regexp"   type="dir" property="xsltc.regexp_jar.not_needed" />
  </target>

  <!-- Generate the XPath parser sources for xsltc if needed -->
  <target name="xsltc.java_cup" depends="xsltc.prepare" unless="xsltc.java_cup.not_needed">
    <!-- The second step generates sym.java and XPathParser.java. -->
    <echo message="java_cup preparsing"/>
    <java fork="yes" failonerror="true" 
       classname="org.apache.xalan.xsltc.util.JavaCupRedirect" >
      <classpath refid="xsltc.class.path" />
      <!-- need to bootclasspath java_cup for JDKs that include JavaCupRedirect -->
      <jvmarg value="-Xbootclasspath/p:${java_cup.jar}${path.separator}${runtime.jar}"/>
      <!-- We're using JavaCupRedirect to call the java_cup application -->
      <arg line="-parser XPathParser -expect 0 
         -stdin ${src.dir}/${xsltc.reldir}/compiler/xpath.cup"/>
    </java>
    <echo message="java_cup move output files"/>
    <move file="XPathParser.java" tofile="${generated.xpathparser}"/>
    <move file="sym.java" tofile="${generated.xpathsym}"/>
  </target>
  
  <!-- Generate the XPath lexer sources for xsltc if needed -->
  <target name="xsltc.jlex" depends="xsltc.java_cup" unless="xsltc.jlex.not_needed">
    <!-- The third step generates XPathLexer.java. The lexiographical analyser
    has to be generated after sym.java, so order is important. -->
    <echo message="JLex preparsing"/>
    <java fork="yes" failonerror="true" classname="JLex.Main" >
      <classpath refid="xsltc.class.path" />
      <arg line="-static ${src.dir}/${xsltc.reldir}/compiler/xpath.lex"/>
    </java>
    <echo message="JLex move output file"/>
    <move file="${src.dir}/${xsltc.reldir}/compiler/xpath.lex.java" tofile="${generated.xpathlexer}"/>
  </target>

  <!-- Compile the main XSLTC classes -->
  <target name="xsltc.compile" depends="xsltc.java_cup,xsltc.jlex,xml.compile"
    description="Compile just the XSLTC classes" >
    <echo message="Compiling remaining XSLTC classes"/>
    <javac srcdir="${src.dir}" 
           destdir="${build.classes}"
           includes="${xsltc.reldir}/**/*.java"
           excludes="${serializer.reldir}/**/*.java"
           debug="${build.debug}"> 
      <classpath refid="xsltc.class.path" />
      <bootclasspath refid="xslt.boot.class.path" />
    </javac>
  </target>

  <!-- Compile just the XSLTC classes w/o JLex, JCup recompilation -->
  <target name="xsltc.fcompile" depends="xml.compile"
    description="Compile just the XSLTC classes w/o JLex, JCup recompilation" >
    <echo message="Compiling remaining XSLTC classes"/>
    <javac srcdir="${src.dir}" 
           destdir="${build.classes}"
           includes="${xsltc.reldir}/**/*.java"
           debug="${build.debug}">
      <classpath refid="xsltc.class.path" />
      <bootclasspath refid="xslt.boot.class.path" />
    </javac>
  </target>

  <!-- Jar up the XSLTC classes w/o the support jars -->
  <target name="xsltc.unbundledjar" depends="xsltc.compile"
    description="Jar just the xsltc.jar file" >
    <!-- Copy over the manifest, with filtering (for version number) -->
    <filter token="impl.version" value="${impl.version}"/>
    <filter token="java.version" value="${java.version}"/>
    <filter token="java.vendor" value="${java.vendor}"/>        
    <copy todir="${build.dir}" file="${manifest.xsltc.mf}" filtering="true"/>
    <jar jarfile="${build.xsltc.jar}" manifest="${build.dir}/manifest.xsltc" basedir="${build.classes}" >
      <patternset><!-- relative to jar/@basedir -->
        <include name="org/apache/xml/**" />
        <include name="${xsltc.reldir}/**/*" />
        <exclude name="org/apache/xalan/xsltc/util/JavaCupRedirect*" />
      </patternset>
    </jar>
  </target>

  <!-- Copy license and readme files for XSLTC support jars -->
  <target name="xsltc.copy-licenses" depends="xsltc.prepare">
  </target>

  <!-- A parametrized target which is used to copy and expand a XSLTC support jar -->
  <target name="xsltc.copy-deps-jar" unless="${param_unless}">
    <!-- copy the jar file to the build/classes directory -->
    <copy todir="${build.classes}" file="${lib.dir}/${param_jar_name}"/>
    
    <!-- unjar the jar file -->
    <unjar src="${build.classes}/${param_jar_name}" dest="${build.classes}" />
    
    <!-- remove the jar file -->
    <delete file="${build.classes}/${param_jar_name}" />
  </target>
  
  <!-- Copy and expand the XSLTC support jars if needed -->
  <target name="xsltc.copy-deps-jars" depends="xsltc.copy-licenses">
    <echo message="Copying XSLTC support jars" />
    <!-- copy the 3rd party support jar files -->
    <antcall target="xsltc.copy-deps-jar">
      <param name="param_unless" value="xsltc.bcel_jar.not_needed" />
      <param name="param_jar_name" value="${bcel.jar.name}" />
    </antcall>

<!-- We don't need to package the JLex or java_cup jars in the xalan.jar.
     These are only required for building XSLTC, not for using XSLTC.
     
    <antcall target="xsltc.copy-deps-jar">
      <param name="param_unless" value="xsltc.jlex_jar.not_needed" />
      <param name="param_jar_name" value="${jlex.jar.name}" />
    </antcall>

    <antcall target="xsltc.copy-deps-jar">
      <param name="param_unless" value="xsltc.java_cup_jar.not_needed" />
      <param name="param_jar_name" value="${java_cup.jar.name}" />
    </antcall>
-->

    <antcall target="xsltc.copy-deps-jar">
      <param name="param_unless" value="xsltc.runtime_jar.not_needed" />
      <param name="param_jar_name" value="${runtime.jar.name}" />
    </antcall>

    <antcall target="xsltc.copy-deps-jar">
      <param name="param_unless" value="xsltc.regexp_jar.not_needed" />
      <param name="param_jar_name" value="${regexp.jar.name}" />
    </antcall>
    
    <!-- remove the old META-INF/MANIFEST.MF file -->
    <delete file="${build.classes}/META-INF/MANIFEST.MF" quiet="true"/>  
  </target>

  <!-- =================================================================== -->
  <!-- Creates the xsltc jar including all support jars                    -->
  <!-- =================================================================== -->
  <target name="xsltc.jar" depends="xsltc.compile,xsltc.copy-deps-jars"
     description="Jar xsltc,xml,BCEL,JLex,java_cup,runtime and jakarta regexp">

    <!-- create new META-INF dir w/ transformer factory default -->
    <!-- GTM: comment this out so that bundled xsltc.jar does not have
         service provider default until further notice 2/20/2002
    <mkdir dir="${build.dir}/xsltctmp/META-INF"/>
    <mkdir dir="${build.dir}/xsltctmp/META-INF/services"/>
    <copy todir="${build.dir}/xsltctmp/META-INF/services"
      file="${src.dir}/${xsltc.reldir}/javax.xml.transform.TransformerFactory"
    />
    -->

    <!-- Copy over the manifest, with filtering (for version number) -->
    <filter token="impl.version" value="${impl.version}"/>
    <filter token="java.version" value="${java.version}"/>
    <filter token="java.vendor" value="${java.vendor}"/>     
    <copy todir="${build.dir}" file="${manifest.xsltc.mf}" filtering="true"/>
    
    <!-- make bundled jar named xsltc.jar -->
    <jar jarfile="${build.dir}/xsltc.jar" manifest="${build.dir}/manifest.xsltc" >
      <fileset dir="${build.classes}">
        <include name="org/apache/xalan/xsltc/**"/>
        <exclude name="org/apache/xalan/xsltc/util/JavaCupRedirect*" />
      </fileset>
      <fileset dir="${build.classes}" includes="org/apache/xml/**" 
                                      excludes="${serializer.reldir}/**" />
      <fileset dir="${build.classes}" includes="org/apache/bcel/**" />
      <fileset dir="${build.classes}" includes="JLex/**" />
      <fileset dir="${build.classes}" includes="java_cup/**" />
      <fileset dir="${build.classes}" includes="org/apache/regexp/**" />
    </jar>

  </target>
  
  <!-- =================================================================== -->
  <!-- Creates the xalan interpretive jar                                  -->
  <!-- =================================================================== -->
  <target name="xalan-interpretive.jar" depends="xalan-interpretive.compile"
    description="Jar up everything in Xalan interpretive (without XSLTC)" >
    <!-- Copy over the manifest, with filtering (for version number) -->
    <filter token="impl.version" value="${impl.version}"/>
    <filter token="java.version" value="${java.version}"/>
    <filter token="java.vendor" value="${java.vendor}"/>     
    <copy todir="${build.dir}" file="${manifest.xalan-interpretive.mf}" filtering="true"/>
    <jar jarfile="${build.xalan-interpretive.jar}" manifest="${build.dir}/manifest.xalan-interpretive" basedir="${build.classes}" >
      <patternset><!-- relative to jar/@basedir -->
        <include name="${apachexml.reldir}/**/*" />
        <include name="${xpath.reldir}/**/*" />
        <include name="${xalan.reldir}/**/*" />
        <include name="${domxpath.reldir}/**/*" />        
        <include name="META-INF/services/*" />
        <exclude name="${xsltc.reldir}/**/*" />
        <exclude name="${serializer.reldir}/**/*" />
      </patternset>
    </jar>
  </target>
  
  <!-- =================================================================== -->
  <!-- Creates the xalan unbundled jar (Xalan interpretive + XSLTC -       -->
  <!-- support jars                                                        -->
  <!-- =================================================================== -->
  <target name="unbundledjar" depends="xalan-interpretive.compile,xsltc.compile"
    description="Jar up Xalan and XSLTC, without the XSLTC dependencies" >
    <filter token="impl.version" value="${impl.version}"/>
    <filter token="java.version" value="${java.version}"/>
    <filter token="java.vendor" value="${java.vendor}"/>     
    <copy todir="${build.dir}" file="${manifest.mf}" filtering="true"/>
    <jar jarfile="${build.xalan-unbundled.jar}" manifest="${build.dir}/MANIFEST.MF" basedir="${build.classes}" >
      <patternset>
        <include name="${apachexml.reldir}/**/*" />
        <include name="${xpath.reldir}/**/*" />
        <include name="${xalan.reldir}/**/*" />
        <include name="META-INF/services/*" />
        <exclude name="${xsltc.reldir}/util/JavaCupRedirect*" />
        <exclude name="${serializer.reldir}/**/*.*" />
      </patternset>    
    </jar>
  </target>
  
  <!-- =================================================================== -->
  <!-- Creates one big xalan jar (Xalan interpretive + XSLTC + support jars) -->
  <!-- =================================================================== -->
  <target name="jar" depends="xalan-interpretive.compile,xsltc.compile,xsltc.copy-deps-jars"
    description="Jar up everything (Xalan, XSLTC and XSLTC dependencies)" >
    
    <!-- Copy over the manifest, with filtering (for version number) -->
    <filter token="impl.version" value="${impl.version}"/>
    <filter token="java.version" value="${java.version}"/>
    <filter token="java.vendor" value="${java.vendor}"/>     
    <copy todir="${build.dir}" file="${manifest.mf}" filtering="true"/>
    
    <!-- make bundled jar named xalan.jar -->
    <jar jarfile="${build.xalan.jar}" manifest="${build.dir}/MANIFEST.MF"
         basedir="${build.classes}" >
       <patternset>
         <exclude name="${xsltc.reldir}/util/JavaCupRedirect*" />
         <exclude name="${serializer.reldir}/**/*" />
       </patternset>
    </jar>  
 
  </target>
  
  <!-- =================================================================== -->
  <!-- Default all target simply Creates the xalan JAR                     -->
  <!-- =================================================================== -->
  <target name="all" depends="serializer.jar,jar"><!-- 'Standardizing build.xml files' <bloritsch@apache.org> -->
    <echo message="Redirect to jar target; please provide input on desired functionality of this target"/>
  </target>
  
  <!-- =================================================================== -->
  <!-- Compiles the samples (servlet excluded) and jars the class files    -->  
  <!-- =================================================================== -->
  <target name="samples" depends="jar,samples.nojardepends,xsltc.samples"/>

  <target name="samples.nojardepends" depends="xsltc.samples.nojardepends"
    description="Compile and jar the samples (except servlet)" >
    <property name="exclude" value="*.xml,*.xsl,*.txt,*.html,*.properties,*.out"/>
    <mkdir dir="${build.samples}"/>
    <!-- Since the samples are packageless, they must be compiled separately. -->   
    <javac srcdir="${samples.dir}/SimpleTransform" 
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/UseStylesheetPI"   
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/UseStylesheetParam" 
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/SAX2SAX"  
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/DOM2DOM"  
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/Pipe"  
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/UseXMLFilters"  
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/Trace"   
           destdir="${build.samples}"  excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/ApplyXPath"  
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>
    <javac srcdir="${samples.dir}/ApplyXPathDOM"  
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>             
    <javac srcdir="${samples.dir}/trax"  
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/extensions"  
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>           
    <javac srcdir="${samples.dir}/Validate"  
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac> 
    <javac srcdir="${samples.dir}/TransformThread"  
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>
    <javac srcdir="${samples.dir}/XPathAPI"  
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" >
      <classpath refid="samples.class.path" />
    </javac>               
    <jar jarfile="${build.samples.jar}" basedir="${build.samples}"
         includes="*.class"/>
  </target>

  <!-- =================================================================== -->
  <!-- Compiles all samples that require extra standard components in      -->
  <!-- order to compile.                                                   -->
  <!-- =================================================================== -->
  <target name="extra.std.samples"
          depends="servlet,xsltc.applet,xsltc.ejb,xsltc.servlet"/>
          
  <target name="extra.std.samples.nojardepends"
          depends="servlet.nojardepends,xsltc.applet.nojardepends,
                   xsltc.ejb.nojardepends,xsltc.servlet.nojardepends"/>

  <!-- =================================================================== -->
  <!-- Compiles all samples that require extra non-standard components in  -->
  <!-- order to compile.                                                   -->
  <!-- =================================================================== -->
  <target name="extra.nonstd.samples" depends="xsltc.brazil"/>
  
  <target name="extra.nonstd.samples.nojardepends" depends="xsltc.brazil.nojardepends"/>

  <!-- =================================================================== -->
  <!-- Compiles the sample servlet and jars the class files.               --> 
  <!-- The javax.servlet and javax.servlet.http packages                   -->
  <!-- must be on the classpath                                            -->
  <!-- =================================================================== -->
  <target name="servlet" depends="jar,servlet.nojardepends"/>

  <target name="servlet.nojardepends"
    description="Compile and jar the servlet samples in xalanservlet.war" >
     <echo message="To compile the sample servlets, javax.servlet and javax.servlet.http must be on the classpath"/>   
     <mkdir dir="${build.servlet}"/>
     <mkdir dir="${build.servlet}/WEB-INF/classes/servlet"/>
     <mkdir dir="${build.servlet}/WEB-INF/lib"/>
     <javac srcdir="${samples.dir}/servlet"
            destdir="${build.servlet}/WEB-INF/classes"
            debug="${build.debug}"
            bootclasspathref="xslt.boot.class.path" >
       <classpath refid="samples.class.path" />
     </javac>           
      <copy todir="${build.servlet}/WEB-INF/classes/servlet">
        <fileset dir="${samples.dir}/servlet" includes="media.properties"/>
      </copy>  		         
      <copy todir="${build.servlet}/WEB-INF">
        <fileset dir="${samples.dir}/servlet" includes="web.xml"/>
      </copy>
      <copy todir="${build.servlet}">
        <fileset dir="${samples.dir}/servlet" 
        		includes="birds.xml, birds.xsl, booklist1.xsl, 
        		booklist2.xsl, catalog.xml, fooparam.xml, fooparam.xsl, jspSample.jsp"/>
      </copy>
      <copy todir="${build.servlet}/WEB-INF/lib">
      	<fileset dir="${lib.dir}" includes="${parser.jar.name}, ${xmlapis.jar.name}"/>
      </copy>
      <copy file="${build.xalan.jar}" todir="${build.servlet}/WEB-INF/lib" />
    <jar jarfile="${build.servlet.war}" 
         basedir="${build.servlet}" 
         includes="**"/>
  </target>
 
  <!-- =================================================================== -->
  <!-- Compiles (does not jar) the translet samples.                       -->
  <!-- For time being, classes are generated in place.                     -->
  <!-- To run these samples, add xsltc.jar, runtime.jar, bcel.jar,         -->
  <!-- and java_cup.jar (all in the bin directory) to the classpath        --> 
  <!--                                                                     -->
  <!-- When we have straightened out classpath issues,                     -->
  <!-- add samples in CompiledApplet, CompiledBrazil, CompiledEJB and      -->
  <!-- CompiledServlet.                                                    -->
  <!-- =================================================================== -->
  <target name="xsltc.samples" depends="jar,xsltc.samples.nojardepends"/>

  <target name="xsltc.samples.nojardepends">
    <mkdir dir="${build.samples}"/>
    <javac srcdir="${samples.dir}/translets"
           classpath="${java.class.path}:${build.xalan.jar}" 
           destdir="${build.samples}" excludes="${exclude}" 
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" />
    <javac srcdir="${samples.dir}/CompiledJAXP"
           destdir="${build.samples}" excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" />
  </target>

  <!-- =================================================================== -->
  <!-- Compiles the XSLTC applet example and jars the class files.         --> 
  <!-- =================================================================== -->
  <target name="xsltc.applet" depends="jar,xsltc.applet.nojardepends"/>

  <target name="xsltc.applet.nojardepends">
    <mkdir dir="${build.samples}/CompiledApplet"/>
    <javac srcdir="${samples.dir}/CompiledApplet"
           destdir="${build.samples}/CompiledApplet" excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" />
    <jar jarfile="${build.xsltc.applet.jar}"
         basedir="${build.samples}/CompiledApplet"
         includes="*.class"/>
  </target>

  <!-- =================================================================== -->
  <!-- Compiles the XSLTC brazil example and jars the class files.         --> 
  <!-- =================================================================== -->
  <target name="xsltc.brazil" depends="jar,xsltc.brazil.nojardepends"/>

  <target name="xsltc.brazil.nojardepends">
    <mkdir dir="${build.samples}/CompiledBrazil"/>
    <javac srcdir="${samples.dir}/CompiledBrazil"
           destdir="${build.samples}/CompiledBrazil" excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" />
    <jar jarfile="${build.xsltc.brazil.jar}"
         basedir="${build.samples}/CompiledBrazil"
         includes="*.class"/>
  </target>

  <!-- =================================================================== -->
  <!-- Compiles the XSLTC EJB example and jars the class files.            --> 
  <!-- ejb.jar must be on the classpath to compile this sample.            -->
  <!-- EJB 2.0 can be found at http://java.sun.com/products/ejb/docs.html  -->
  <!-- =================================================================== -->
  <target name="xsltc.ejb" depends="jar,xsltc.ejb.nojardepends"/>

  <target name="xsltc.ejb.nojardepends">
    <mkdir dir="${build.samples}/CompiledEJB"/>
    <javac srcdir="${samples.dir}/CompiledEJB"
           destdir="${build.samples}/CompiledEJB" excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" />
    <jar jarfile="${build.xsltc.ejb.jar}"
         basedir="${build.samples}/CompiledEJB"
         includes="*.class"/>
  </target>

  <!-- =================================================================== -->
  <!-- Compiles the XSLTC servlet example and jars the class files.        --> 
  <!-- =================================================================== -->
  <target name="xsltc.servlet" depends="jar,xsltc.servlet.nojardepends" />

  <target name="xsltc.servlet.nojardepends">
    <mkdir dir="${build.samples}/CompiledServlet"/>
    <javac srcdir="${samples.dir}/CompiledServlet"
           destdir="${build.samples}/CompiledServlet" excludes="${exclude}"
           debug="${build.debug}" bootclasspathref="xslt.boot.class.path" />
    <jar jarfile="${build.xsltc.servlet.jar}"
         basedir="${build.samples}/CompiledServlet"
         includes="*.class"/>
  </target>

 
  <!-- =================================================================== -->
  <!-- Generate HTML docs                                                  -->
  <!-- =================================================================== -->
  <target name="docs" depends="jar,docs.nojardepends,xsltc.docs"/>
  
  <target name="docs.nojardepends" depends="prepare.docs.nojardepends,autodocs"  
    description="Build the documentation (overview, readme, etc.)" >
    <echo message="docs is human-usable target with dependencies"/>  
  </target>
  
  <target name="autodocs">
    <echo message="autodocs is for automated build process, without dependencies"/>   
    <java fork="yes" 
          classname="${doc.generator}" 
          classpathref="docs.class.path" >
       <arg line="targetDirectory=${build.docs} ${xdocs.book} ${xdocs.style}"/>
    </java>	 
  </target>
  
  <!-- =================================================================== -->
  <!-- Creates the API documentation                                       -->
  <!-- =================================================================== -->
  <target name="javadocs" depends="jar,javadocs.nojardepends"/>
  
  <target name="javadocs.nojardepends" depends="prepare.docs.nojardepends,autojavadocs"
    description="Build the Javadocs for Xalan 2.x and jaxp sources" >
    <echo message="javadocs is human-usable target with dependencies"/> 
    
    <!-- Expand jaxp sources (JAXP 1.1, DOM 2, and SAX 2) into source tree for 
         inclusion in the Javadoc. -->           
    <!-- Note this is into the src area.-->                                          
    <gunzip src="${xml-commons-srcs.tar.gz}" dest="${build.dir}" />                                                                         
    <untar src="${xml-commons-srcs.tar}" 
           dest="${src.dir}">
       <patternset>
         <include name="**.java"/>
       </patternset>
    </untar>
           
    <delete file="${xml-commons-srcs.tar}"/>
         
    <antcall target="autojavadocs"/>
     
    <!-- remove the jaxp sources -->
    <delete dir="${src.dir}/javax" />
    <delete dir="${src.dir}/org/w3c" />
    <delete dir="${src.dir}/org/xml" />
    <delete dir="${src.dir}/org/apache/xmlcommons" />
    <delete file="${src.dir}/manifest.commons" />
         
  </target>

  <target name="autojavadocs" 
          depends="autojavadocs-1.4-or-higher-if,autojavadocs-non1.4-or-higher-if">
    <echo message="autojavadocs is for automated build process, without dependencies"/>
  </target>

  <target name="check-using-java-1.4-or-higher">
    <condition property="using-java-1.4-or-higher">
      <not>
          <or>
            <equals arg1="${ant.java.version}" arg2="1.1"/>
            <equals arg1="${ant.java.version}" arg2="1.2"/>
            <equals arg1="${ant.java.version}" arg2="1.3"/>
          </or>
      </not>
    </condition>
  </target>

  <target name="autojavadocs-1.4-or-higher-if" if="using-java-1.4-or-higher" 
          depends="check-using-java-1.4-or-higher">
    <antcall target="autojavadocs-1.4-or-higher"/>
  </target>

  <target name="autojavadocs-non1.4-or-higher-if" unless="using-java-1.4-or-higher" 
          depends="check-using-java-1.4-or-higher">
    <antcall target="autojavadocs-non1.4-or-higher"/>
  </target>

  <target name="autojavadocs-1.4-or-higher">
    
    <!-- Ant ignores destdir arg if doclet is set, so must send to doclet in doclet subelement-->
    <javadoc
         additionalparam="-breakiterator"
         destdir="${build.apidocs}"
         public="true"
         sourcepath="${src.dir}"
         overview="${src.dir}/javadocOverview.html"
         packagenames="org.apache.*,org.xml.*,org.w3c.*,javax.xml.*"
         author="true"
         version="true"
         use="true"
         windowtitle="${Name-in-docs} ${impl.version}" 
         doctitle="${Name-in-docs} ${impl.version}"
         bottom="Copyright &#169; ${year} Apache XML Project. All Rights Reserved.">
          <classpath refid="docs.class.path" />
          <taglet name="xalan2jtaglet.XSLUsageTag" path="${taglet.jar}"/>
          <group title="Transformations API for XML (TrAX)" packages="javax.xml.transform*"/>
          <group title="Java API for XML Parsing" packages="javax.xml.parsers"/>
          <group title="Xalan Core"
                 packages="org.apache.xalan.processor:org.apache.xalan.templates:org.apache.xalan.transformer"/>
          <group title="XPath" packages="org.apache.xpath*"/>
          <group title="Document Table Model (DTM)" packages="org.apache.xml.dtm*"/>          
          <group title="Utilities" packages="org.apache.xml.utils*"/>
          <group title="Xalan Other" packages="org.apache.xalan.client:org:org.apache.xalan.extensions:org.apache.xalan.res:org.apache.xalan.stree:org.apache.xalan.trace:org.apache.xalan.xslt"/>
          <group title="Xalan Extensions" packages="org.apache.xalan.lib*"/>
          <group title="Serializers" packages="org.apache.xml.serialize*, org.apache.xalan.serialize"/>
          <group title="SAX 2" packages="org.xml.sax*"/>
          <group title="DOM 2" packages="org.w3c.dom*"/>
          <group title="XSLTC Core"
                 packages="org.apache.xalan.xsltc*"/>
    </javadoc>
  </target>

  <target name="autojavadocs-non1.4-or-higher">
      
    <!-- Ant ignores destdir arg if doclet is set, so must send to doclet in doclet subelement-->
    <javadoc
         public="true"
         sourcepath="${src.dir}"
         overview="${src.dir}/javadocOverview.html"
         packagenames="org.apache.*,org.xml.*,org.w3c.*,javax.xml.*"
         author="true"
         version="true"
         use="true"
         windowtitle="${Name-in-docs} ${impl.version}" 
         doctitle="${Name-in-docs} ${impl.version}"
         bottom="Copyright &#169; ${year} Apache XML Project. All Rights Reserved.">
          <classpath refid="docs.class.path" />
          <doclet name="xalanjdoc.Standard" path="${doclet.jar}">
            <param name="-d" value="${build.apidocs}"/>
          </doclet>
          <group title="Transformations API for XML (TrAX)" packages="javax.xml.transform*"/>
          <group title="Java API for XML Parsing" packages="javax.xml.parsers"/>
          <group title="Xalan Core"
                 packages="org.apache.xalan.processor:org.apache.xalan.templates:org.apache.xalan.transformer"/>
          <group title="XPath" packages="org.apache.xpath*"/>
          <group title="Document Table Model (DTM)" packages="org.apache.xml.dtm*"/>          
          <group title="Utilities" packages="org.apache.xml.utils*"/>
          <group title="Xalan Other" packages="org.apache.xalan.client:org:org.apache.xalan.extensions:org.apache.xalan.res:org.apache.xalan.stree:org.apache.xalan.trace:org.apache.xalan.xslt"/>
          <group title="Xalan Extensions" packages="org.apache.xalan.lib*"/>
          <group title="Serializers" packages="org.apache.xml.serialize*, org.apache.xalan.serialize"/>
          <group title="SAX 2" packages="org.xml.sax*"/>
          <group title="DOM 2" packages="org.w3c.dom*"/>
          <group title="XSLTC Core"
                 packages="org.apache.xalan.xsltc*"/>
    </javadoc>
  </target>

  <!-- =================================================================== -->
  <!-- Various targets to clean the build tree                             -->
  <!-- =================================================================== -->
  <target name="distclean" depends="clean"
    description="Clean everything, including dist/jar/docs/xsltc.*" >
    <delete dir="${dist.dir}"/>
  </target>

  <target name="clean" depends="xsltc.clean"
    description="Clean the ${build.dir} tree and doc outputs" >
    <delete dir="${build.dir}"/>
    <delete dir="${site.root}"/>
    <delete dir="${xalan.apache.org.site.root}"/>    
    <delete quiet="true">
      <fileset dir="${xdocs.style}" excludes="${xalanonly-styledocs}"/>
    </delete>
    <delete file="${xdocs.DONE.file}"/>
    <delete file="${xdocs.XSLTCDONE.location}"/>
    <delete file="${src.dir}/${xalan.reldir}/Version.java"/>
    <delete file="${src.dir}/${serializer.reldir}/Version.java"/>
    <delete file="${xdocs.dir}/sources/entities.ent"/>       
    <!-- Also delete files expanded from ${xml-commons-srcs.tar.gz}-->
    <delete dir="${src.dir}/javax" includeEmptyDirs="true" quiet="true"/>
    <delete dir="${src.dir}/org/xml" includeEmptyDirs="true" quiet="true"/>
    <delete dir="${src.dir}/org/w3c" includeEmptyDirs="true" quiet="true"/>
    <delete dir="${src.dir}/xdocs/style/graphics" includeEmptyDirs="true" quiet="true"/>
    <delete dir="${src.dir}/xdocs/style/resources" includeEmptyDirs="true" quiet="true"/>            
  </target>
 
  <target name="xsltc.clean"
    description="Clean miscellaneous generated sources from xsltc.compile" >
    <delete file="${generated.xpathparser}" />
    <delete file="${generated.xpathsym}" />
    <delete file="${generated.xpathlexer}" />
  </target>

  <!-- =================================================================== -->
  <!-- Install/Uninstall targets - not currently applicable                -->
  <!-- =================================================================== -->
  <target name="install"><!-- 'Standardizing build.xml files' <bloritsch@apache.org> -->
    <echo message="install target currently not supported in ${Name-in-docs}; try jar or dist instead"/>
  </target>
  <target name="uninstall"><!-- 'Standardizing build.xml files' <bloritsch@apache.org> -->
    <echo message="uninstall target currently not supported in ${Name-in-docs}; try distclean instead"/>
  </target>

  <!-- =================================================================== -->
  <!-- Creates a distribution that depends only on standard pieces         -->
  <!-- =================================================================== -->
  <target name="dist" depends="build.std.dist,autodist"
              description="Create a .zip/.tar.gz distribution module containing
                           all components without dependencies on non-standard
                           jars that are not part of the build system." >
    <echo message="dist is human-useable target for distribution, with only standard dependencies"/>
  </target>

  <target name="dist-nodocs" depends="build.std.dist-nodocs,autodist-nodocs"
              description="Create a .zip/.tar.gz distribution module containing
                           all components without dependencies on non-standard
                           jars that are not part of the build system." >
    <echo message="dist-nodocs is human-useable target for distribution, with only standard dependencies and no documentation "/>
  </target>

  <!-- =================================================================== -->
  <!-- Creates a complete distribution in which the xalan.jar contains     -->
  <!-- the interpretive, compiled and the common packages                  -->
  <!-- =================================================================== -->
  <target name="fulldist" depends="build.nonstd.dist,autodist"
          description="Create a .zip/.tar.gz distribution module containing
                       all components.">
    <echo message="fulldist is human-useable target for distribution, with all dependencies"/>
  </target>
  
  <target name="fulldist-nodocs" depends="build.nonstd.dist-nodocs,autodist-nodocs"
          description="Create a .zip/.tar.gz distribution module containing
                       all components.">
    <echo message="fulldist-nodocs is human-useable target for distribution, with all dependencies and no documentation"/>
  </target>  

  <!-- =================================================================== -->
  <!-- Creates a complete distribution with separate xalan.jar and         -->
  <!-- xsltc.jar.  The common packages are contained in each jar.          -->
  <!-- =================================================================== -->
  <target name="fulldist-separatejars" depends="build.nonstd-separatejars.dist,autodist"
          description="Create a .zip/.tar.gz distribution module containing
                       all components.">
    <echo message="fulldist is human-useable target for distribution, with all dependencies"/>
  </target>

  <target name="fulldist-separatejars-nodocs" depends="build.nonstd-separatejars.dist-nodocs,autodist-nodocs"
          description="Create a .zip/.tar.gz distribution module containing
                       all components.">
    <echo message="fulldist-separatejars-nodocs is human-useable target for distribution, with all dependencies and no documentation"/>
  </target>
  
  <target name="build.std.dist" depends="build.std.parts">
    <property name="has.nonstd.parts" value="false"/>
  </target>
  <target name="build.std.dist-nodocs" depends="build.std.parts-nodocs">
    <property name="has.nonstd.parts" value="false"/>
  </target>  

  <target name="build.nonstd.dist" depends="build.std.parts,build.nonstd.parts">
    <property name="has.nonstd.parts" value="true"/>
  </target>
  <target name="build.nonstd.dist-nodocs" depends="build.std.parts-nodocs,build.nonstd.parts">
    <property name="has.nonstd.parts" value="true"/>
  </target>  
  
  <target name="build.nonstd-separatejars.dist" depends="build.std-separatejars.parts,
                                                         build.nonstd-separatejars.parts">
    <property name="has.nonstd.parts" value="true"/>
  </target>
  <target name="build.nonstd-separatejars.dist-nodocs" depends="build.std-separatejars.parts-nodocs,
                                                                build.nonstd-separatejars.parts">
    <property name="has.nonstd.parts" value="true"/>
  </target>

  <target name="build.std.parts"
          depends="jar,docs,javadocs,samples,extra.std.samples,xsltc.docs"/>
          
  <target name="build.std.parts-nodocs"
          depends="jar,samples,extra.std.samples"/>          
          
  <target name="build.std-separatejars.parts"
          depends="xalan-interpretive.jar,xsltc.jar,
                   docs.nojardepends,javadocs.nojardepends,
                   samples.nojardepends,extra.std.samples.nojardepends,
                   xsltc.docs"/>
                    
  <target name="build.std-separatejars.parts-nodocs"
          depends="xalan-interpretive.jar,xsltc.jar,
                   samples.nojardepends,extra.std.samples.nojardepends"/>                            
          
  <target name="build.nonstd.parts" depends="extra.nonstd.samples"/>
  <target name="build.nonstd-separatejars.parts" depends="extra.nonstd.samples.nojardepends"/>

  <!-- =================================================================== -->
  <!-- Autodist targets.  Used by the distribution targets.                -->
  <!-- =================================================================== -->  
  <target name="autodist-mkdirs">
    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.dir}/lib"/>   
    <mkdir dir="${dist.dir}/samples"/>       
    <mkdir dir="${dist.dir}/src"/>
    <mkdir dir="${dist.dir}/tools"/>     
    <mkdir dir="${dist.dir}/xdocs"/>
  </target>

  <target name="autodist-mkdirs-docs">
    <mkdir dir="${dist.dir}/docs"/>
    <mkdir dir="${dist.dir}/docs/apidocs"/>
  </target>

  <target name="autodist-copy-files">

    <!-- Copy license files to distribution root -->
    <copy todir="${dist.dir}">
      <fileset dir=".">
        <include name="LICENSE.txt,NOTICE.txt"/>
      </fileset>
    </copy>

    <!-- Copy sources and source documentation -->
    <copy todir="${dist.dir}/src">
      <fileset dir="${src.dir}" excludes="javax/**,org/xml/**,org/w3c/**"/><!-- exclude jaxp, sax, dom -->
    </copy>
    <copy todir="${dist.dir}/xdocs">
      <fileset dir="${xdocs.dir}"/>
    </copy>

    <!-- Copy samples -->
    <copy todir="${dist.dir}/samples">
      <fileset dir="${samples.dir}"/>
    </copy>
    
    <!-- Copy tools; used for source distribution -->    
    <copy todir="${dist.dir}/tools">
      <fileset dir="${tools.dir}">
        <include name="*.*"/>
      </fileset>
    </copy>

    <!-- Copy runtime libs; used for source distribution -->    
    <copy todir="${dist.dir}/lib">
      <fileset dir="${lib.dir}">
        <include name="*.*"/>
      </fileset>
    </copy>    

    <!-- Copy built jars -->
    <copy file="${build.dir}/xalansamples.jar" todir="${dist.dir}/samples"/>
    <copy file="${build.dir}/xalanservlet.war" todir="${dist.dir}/samples"/>
    <copy file="${build.dir}/xsltcapplet.jar"  todir="${dist.dir}/samples"/>
    <copy file="${build.dir}/xsltcbrazil.jar"  todir="${dist.dir}/samples"
          failonerror="${has.nonstd.parts}"/>
    <copy file="${build.dir}/xsltcejb.jar"     todir="${dist.dir}/samples"/>
    <copy file="${build.dir}/xsltcservlet.jar" todir="${dist.dir}/samples"/>
    
    <copy file="${build.xalan.jar}" todir="${dist.dir}" />
    
    <!-- only copy the xsltc.jar file if it has been built -->
    <copy todir="${dist.dir}">
      <fileset dir="${build.dir}" includes="xsltc.jar"/>
    </copy>
    <copy file="${build.serializer.jar}" todir="${dist.dir}" />
    
    <copy file="${xmlapis.jar}" todir="${dist.dir}" />  
    <copy file="${parser.jar}" todir="${dist.dir}" />        

    <copy todir="${dist.dir}">
      <fileset dir="." includes="readme.html,KEYS,build.xml,build.sh,build.bat,commits.xml,
                                 LICENSE.txt,NOTICE.txt"/>      
    </copy>
  </target>

  <target name="autodist-copy-files-docs">
    <!-- Copy built documentation and javadoc -->
    <copy todir="${dist.dir}/docs">
      <fileset dir="${build.docs}"/>
    </copy>
  </target>

  <target name="autodist-create-bin-packages">
    <tar tarfile="${build.dir}/${dist.pkg}-bin.tar" >
      <tarfileset dir="${build.dir}">
        <patternset refid="bin-distro"/>
      </tarfileset>
    </tar>
    <gzip src="${build.dir}/${dist.pkg}-bin.tar" zipfile="${build.dir}/${dist.pkg}-bin.tar.gz"/>
    <delete file="${build.dir}/${dist.pkg}-bin.tar" />

    <zip zipfile="${build.dir}/${dist.pkg}-bin.zip" >
      <fileset dir="${build.dir}">
        <patternset refid="bin-distro"/>
      </fileset>
    </zip>
  </target>
  <target name="autodist-create-bin-packages-nodocs">
    <tar tarfile="${build.dir}/${dist.pkg}-bin-nodocs.tar" >
      <tarfileset dir="${build.dir}">
        <patternset refid="bin-distro-nodocs"/>
      </tarfileset>
    </tar>
    <gzip src="${build.dir}/${dist.pkg}-bin-nodocs.tar" zipfile="${build.dir}/${dist.pkg}-bin-nodocs.tar.gz"/>
    <delete file="${build.dir}/${dist.pkg}-bin-nodocs.tar" />

    <zip zipfile="${build.dir}/${dist.pkg}-bin-nodocs.zip" >
      <fileset dir="${build.dir}">
        <patternset refid="bin-distro-nodocs"/>
      </fileset>
    </zip>
  </target>
  <target name="autodist-create-src-packages">
    <tar tarfile="${build.dir}/${dist.pkg}-src.tar" >
      <tarfileset dir="${build.dir}">
        <patternset refid="src-distro"/>
        <patternset refid="xsltc-deps-jars"/>
      </tarfileset>
    </tar>
    <gzip src="${build.dir}/${dist.pkg}-src.tar" zipfile="${build.dir}/${dist.pkg}-src.tar.gz"/>
    <delete file="${build.dir}/${dist.pkg}-src.tar" />

    <zip zipfile="${build.dir}/${dist.pkg}-src.zip" >
      <fileset dir="${build.dir}">
        <patternset refid="src-distro"/>
        <patternset refid="xsltc-deps-jars"/>
      </fileset>
    </zip>
  </target>

  <target name="autodist">
    <echo message="autodist is for automated build processes, without dependencies"/>
    <antcall target="autodist-mkdirs"/>
    <antcall target="autodist-mkdirs-docs"/>
    <antcall target="autodist-copy-files"/>
    <antcall target="autodist-copy-files-docs"/>
    <antcall target="autodist-create-bin-packages"/>
    <antcall target="autodist-create-src-packages"/>
  </target>

  <target name="autodist-nodocs">
    <echo message="autodist-nodocs is for automated build processes, without dependencies"/>
    <antcall target="autodist-mkdirs"/>
    <antcall target="autodist-copy-files"/>
    <antcall target="autodist-create-bin-packages-nodocs"/>
    <antcall target="autodist-create-src-packages"/>
  </target>
  
  <!-- =================================================================== -->
  <!-- Creates the documentation tree for the xml.apache.org/xalan-j       -->
  <!-- website                                                             -->
  <!-- =================================================================== -->
  <target name="site" depends="prepare.docs,javadocs,xsltc.docs"
    description="Build documentation for posting to the website" >
 
    <mkdir dir="${site.dir}/apidocs"/>
    <mkdir dir="${site.dir}/design"/>
    <mkdir dir="${site.dir}/xsltc"/>    
    <java fork="yes" 
          classname="${doc.generator}" 
          classpathref="docs.class.path" >
       <arg line="targetDirectory=${site.dir} ${site.book} ${xdocs.style}"/>
    </java>

    <!-- put xalan design doc in the site design subdir -->
    <copy todir="${site.dir}/design">
      <fileset dir="${build.docs}/design"/>
    </copy>
    <!-- put xsltc design doc in the site xsltc subdir -->
    <copy todir="${site.dir}/xsltc">
      <fileset dir="${build.docs}/xsltc"/>
    </copy>  
    
    <!-- put in the javadoc -->
    <copy todir="${site.dir}/apidocs">
      <fileset dir="${build.apidocs}"/>
    </copy>      
  </target>
  
  <!-- =================================================================== -->
  <!-- Creates the documentation tree for the xalan.apache.org website     -->
  <!-- =================================================================== -->
  <target name="xalan.apache.org.site"
    description="Build documentation for posting to the website" >
 
    <mkdir dir="${xalan.apache.org.site.dir}"/>
    <java fork="yes" 
          classname="${doc.generator}" 
          classpathref="docs.class.path" >
       <arg line="targetDirectory=${xalan.apache.org.site.dir} ${xalan.apache.org.site.book} ${xdocs.style}"/>
    </java>

  </target>  
   
  <!-- =================================================================== -->
  <!-- Compiles and runs mini/smoketest from xml-xalan\test, if present    -->
  <!-- =================================================================== -->
  <property name="test.relpath" value="../test"/>

  <target name="minitest" depends="prepare,minitest-run,tests-not-available" 
    description="Run the Minitest from xml-xalan/test" >
    <!-- This target simply asks the minitest-run worker target to 
         actually have the Minitest run (by the test/build.xml file);
         we then also call the tests-not-available target in case 
         the user never checked out the tests.
    -->
  </target>
  <target name="minitest-run" if="tests-available" depends="jar" >
    <echo message=" [minitest] Calling ${test.relpath}/build.xml to run the Minitest" />
    <ant dir="${test.relpath}" antfile="build.xml" target="minitest.gump" >
    </ant>
  </target>

  <target name="smoketest" depends="prepare,smoketest-run,tests-not-available" 
    description="Run Smoketests (Minitest, conf, harness) from xml-xalan/test" >
  </target>
  <target name="smoketest-run" if="tests-available" depends="jar" >
    <echo message=" [minitest] Calling ${test.relpath}/build.xml to run the Smoketest" />
    <ant dir="${test.relpath}" antfile="build.xml" target="smoketest.dev" >
    </ant>
  </target>

  <target name="check" depends="smoketest"><!-- 'Standardizing build.xml files' <bloritsch@apache.org> -->
    <echo message="Redirect to smoketest target"/>
  </target>

  <!-- Called from various testing targets if the test dir doesn't exist. -->
  <target name="tests-not-available" unless="tests-available" >
    <echo message=" [tests] The tests do not seem to be present in ${test.relpath}" />
    <echo message=" [tests] You must have checked out from CVS to run the tests," />
    <echo message=" [tests]   it is not included in binary distributions." />
    <echo message=" [tests] See http://xml.apache.org/xalan-j/test/ for more info." />
  </target>

  <!-- =================================================================== -->
  <!-- Creates the xalan design document                                   -->
  <!-- =================================================================== -->
    <target name="xalan-j2-design">
    <java fork="yes" 
          classname="${doc.generator}" 
          classpathref="docs.class.path" >
      <arg line="loaderConfig=sbk:/style/loaderdesign.xml targetDirectory=${build.dir}/docs/design/
      ${xdocs.dir}/sources/xalandesign.xml ${xdocs.style}"/>
    </java>
  </target>
  
  <!-- =================================================================== -->
  <!-- Use FOP to create preliminary print (pdf) doc                       -->
  <!-- Note: fop.jar and xml.jar (from xml-fop) must be on classpath       -->
  <!-- This is VERY preliminary, not yet for inclusion in distribution     -->
  <!-- =================================================================== -->
  <!--Collate the xml sources into a single xml source with a litle extra structure -->
  <target name="printerdocs" depends="prepare.docs">
    <echo message="NOTICE: requires fop.jar and xml.jar on the classpath"/>
    <java fork="yes" 
          classname="${xalan.cmdline.class}"
          classpathref="docs.class.path" >
      <arg line="-xsl ${xdocs.dir}/sources/xalan-collate.xsl 
                 -out xdocs/sources/xalan/xalan-collate.xml"/>
    </java>
    
    <!-- Transform collation into Formatting Objects 
         (with a little work on links along the way) -->    
    <java fork="yes" 
          classname="${xalan.cmdline.class}"
          classpathref="docs.class.path" >
      <arg line="-in  ${xdocs.dir}/sources/xalan/xalan-collate.xml
                 -param resourceFile '../../sources/xalan/resources.xml'
                 -param project ${Name-in-docs}      
                 -xsl ${xdocs.style}/stylesheets/xml2fo.xsl 
                 -out build/docs/xalan-collate.fo"/>
    </java>
    
    <!-- Use FOP to generate a pdf file (classpath may need updating! -sc 18-Apr-01)-->
    <java fork="yes" 
          classname="org.apache.fop.apps.CommandLine"
      classpath="${java.class.path}:${build.xalan.jar}:${bin.dir}/fop.jar:${bin.dir}/w3c.jar">
      <arg line="${build.docs}/xalan-collate.fo build/docs/xalan.pdf"/>
    </java>
  </target>

 
  <!-- =================================================================== -->
  <!-- Build XSLTC design documentation. Eventually intend to incorporate -->
  <!-- XSLTC into the Xalan book.                                         -->
  <!-- =================================================================== -->


  <target name="xsltc.prepare.docs" depends="prepare.docs.nojardepends">
   <mkdir dir="${build.docs}/xsltc"/>
   <!--   
   <echo message="Transform xsltc_todo.xml and put the result in ${build.docs}/xsltc"/>
   <java fork="yes" classname="${xalan.cmdline.class}">
      <classpath refid="docs.class.path" />
      <arg line="-in xsltc_todo.xml -xsl todo.xsl -out build/docs/xsltc/todo.html"/>
   </java>  -->
  </target>  
 
 <target name="xsltc.docs" depends="xsltc.prepare.docs">
   <echo message="Build the XSLTC Architectural documentation"/>
   <java fork="yes" 
         classname="${doc.generator}" 
         classpathref="docs.class.path" >
      <arg line="targetDirectory=${build.docs}/xsltc ${xdocs.dir}/sources/xsltc.xml ${xdocs.style}"/>
    </java>	 
    <copy todir="${build.docs}/xsltc" 
	file="${xdocs.dir}/sources/xsltc/README.xslt" />
    <copy todir="${build.docs}/xsltc" 
	file="${xdocs.dir}/sources/xsltc/README.xsltc" />
 </target>
 
   <!-- pack all doc for transfer to website -->
 <target name="pack.docs">
    <!--tar tarfile="./build/xalan-j-docs.tar" basedir="./xml-site/target/xalan-j" includes="**"/>
    <gzip src="./build/xalan-j-docs.tar" zipfile="./build/xalan-j-docs.tar.gz"/-->
    <zip zipfile="./build/xalan-j-docs.zip" basedir="./xml-site/target/xalan-j" includes="**"/>
  </target>


<!-- ####################################################
     # START OF SECTION TO BUILD STAND-ALONE SERIALIZER #
     #################################################### -->

  <!-- try not to use other properties directly when building the serializer -->
  <!-- either create new values, or copy, just in case we separate into      -->
  <!-- a totally new build.xml file                                          -->
  <property name="serializer.build.debug"   value="${build.debug}"            />
 
  
  <!-- PROPERTIES TO MAKE THE SOURCE DISTRIBUTION ========================== -->
  <property name="serializer.name"          value="serializer"                />
  <property name="serializer.version"       value="${version}"                />
  <property name="serializer.dist.file"     value="${serializer.name}-j_${serializer.version}"/>
  <property name="serializer.dist.dir"      value="${serializer.build.dir}/${serializer.dist.file}"/>

  <!-- patternset for source distribution packages -->
  <patternset id="serializer-src-distro" >
    <!-- some license and legal stuff -->
    <include name="${serializer.dist.file}/LICENSE.txt"/>
    <include name="${serializer.dist.file}/NOTICE.txt"/> 
    <include name="${serializer.dist.file}/KEYS"/>  

    <!-- The build stuff that uses Ant and this file itself, build.xml
         this is getting into a strange loop but the source distribution
         needs to build, and it uses this file, build.xml to do so ... -->
    <include name="${serializer.dist.file}/build.bat"/>
    <include name="${serializer.dist.file}/build.sh"/>
    <include name="${serializer.dist.file}/build.xml"/>

    <!-- The source code that the source distribution would build -->
    <include name="${serializer.dist.file}/src/${serializer.reldir}/**/*.java" />
    <include name="${serializer.dist.file}/src/${serializer.reldir}/**/*.properties" />
    <include name="${serializer.dist.file}/src/${serializer.manifest.basename}" />

    <!-- We need Ant in order to run build.xml in the source distribution -->
    <include name="${serializer.dist.file}/tools/ant.jar"/>
    <include name="${serializer.dist.file}/tools/antRun"/>
    <include name="${serializer.dist.file}/tools/antRun.bat"/>

    <!-- The serializer needs this jar in order to build -->
    <include name="${serializer.dist.file}/xml-apis.jar"/>
    
    <!-- Ant needs an XML parser in order to read in the build.xml, so it
         can even do the build ... this is a strange loop ... -->
    <include name="${serializer.dist.file}/xercesImpl.jar"/>
  </patternset>

  <!-- patternset for  binary distribution packages ... if needed
  <patternset id="serializer-bin-distro" >
    <include name="${serializer.dist.file}/LICENSE.txt"/>
    <include name="${serializer.dist.file}/NOTICE.txt"/>
    <include name="${serializer.dist.file}/KEYS"/>
    <include name="${serializer.dist.file}/${serializer.name}.jar"/>
    <include name="${serializer.dist.file}/${xmlapis.jar.name}"/>
    <include name="${serializer.dist.file}/${parser.jar.name}"/>    
  </patternset>
  -->
  
  <!-- =================================================================== -->
  <!-- Creates the Serializer jar                                          -->
  <!-- =================================================================== -->
  <target name="serializer.jar"
    depends="serializer.prepare,serializer.compile"
    description="Build the serializer and created serializer.jar" >
    <!-- Copy over the manifest, with filtering (for version number) -->
    <filter token="impl.version" value="${serializer.impl.version}"/>
    <filter token="java.version" value="${serializer.java.version}"/>
    <filter token="java.vendor"  value="${serializer.java.vendor}"/>
    <copy todir="${serializer.build.dir}" file="${serializer.manifest}" filtering="true"/>

    <jar jarfile="${build.serializer.jar}"
      manifest="${serializer.build.dir}/${serializer.manifest.basename}"
      basedir="${serializer.build.classes}" >
      <patternset><!-- relative to jar/@basedir -->
        <include name="${serializer.reldir}/**/*" />
      </patternset>
    </jar>
  </target>

  <target name="serializer.prepare">
    <mkdir dir="${serializer.build.dir}"/>
    <mkdir dir="${serializer.build.classes}"/>
  </target>

  <target name="serializer.compile">
    <echo message="Compiling the Serializer" />
    <javac srcdir="${serializer.src.dir}"
           destdir="${serializer.build.classes}"
           debug="${serializer.build.debug}" >
      <include name="${serializer.reldir}/**/*.java" />
      <classpath refid="compile.class.path" />
      <bootclasspath refid="xslt.boot.class.path" />
    </javac>
    <!-- Copy needed properties, resource, etc. files to be put into .jar file -->
    <copy todir="${serializer.build.classes}">
      <fileset dir="${serializer.src.dir}" includes="${serializer.reldir}/**/*.properties"/>
    </copy>

  </target>


  <!-- =================================================================== -->
  <!-- Creates the API documentation                                       -->
  <!-- =================================================================== -->
  <target name="serializer.javadocs"
    description="Build the Javadocs for the Serializer" >
    <echo message="javadocs is human-usable target with dependencies"/>  
    
    <mkdir dir="${build.docs}"/> 
    <mkdir dir="${build.apidocs}"/>
    <antcall target="serializer.autojavadocs"/>
  </target>

  <target name="serializer.autojavadocs" 
          depends="serializer.autojavadocs-1.4-or-higher-if,serializer.autojavadocs-non1.4-or-higher-if">
    <echo message="serializer.autojavadocs is for automated build process, without dependencies"/>
  </target>

  <target name="serializer.autojavadocs-1.4-or-higher-if" if="using-java-1.4-or-higher" 
          depends="check-using-java-1.4-or-higher">
    <antcall target="serializer.autojavadocs-1.4-or-higher"/>
  </target>

  <target name="serializer.autojavadocs-non1.4-or-higher-if" unless="using-java-1.4-or-higher" 
          depends="check-using-java-1.4-or-higher">
    <antcall target="serializer.autojavadocs-non1.4-or-higher"/>
  </target>

  <target name="serializer.autojavadocs-1.4-or-higher">
    
    <!-- Ant ignores destdir arg if doclet is set, so must send to doclet in doclet subelement-->
    <javadoc
         additionalparam="-breakiterator"
         destdir="${build.apidocs}"
         public="true"
         sourcepath="${src.dir}"
         packagenames="org.apache.*"
         author="true"
         version="true"
         use="true"
         windowtitle="${Name-in-docs} Serializer ${impl.version}" 
         doctitle="${Name-in-docs} Serializer ${impl.version}"
         bottom="Copyright &#169; ${year} Apache XML Project. All Rights Reserved.">
          <classpath refid="docs.class.path" />
          <taglet name="xalan2jtaglet.XSLUsageTag" path="${taglet.jar}"/>
          <group title="Serializer" packages="org.apache.xml.serialize*"/>
    </javadoc>
  </target>

  <target name="serializer.autojavadocs-non1.4-or-higher">
    <!-- Ant ignores destdir arg if doclet is set, so must send to doclet in doclet subelement-->
    <javadoc
         public="true"
         sourcepath="${src.dir}"
         packagenames="org.apache.*"
         author="true"
         version="true"
         use="true"
         windowtitle="${Name-in-docs} Serializer ${impl.version}" 
         doctitle="${Name-in-docs} Serializer ${impl.version}"
         bottom="Copyright &#169; ${year} Apache XML Project. All Rights Reserved.">
          <classpath refid="docs.class.path" />
          <doclet name="xalanjdoc.Standard" path="${doclet.jar}">
            <param name="-d" value="${build.apidocs}"/>
          </doclet>
          <group title="Serializer" packages="org.apache.xml.serialize*"/>
    </javadoc>
  </target>


  <!-- =================================================================== -->
  <!-- Create the serializer source distribution                           -->
  <!-- =================================================================== -->
  <target name="serializer-dist"
          depends="serializer.jar"
          description="Build the serializer source distribution .tar and .zip">
    <antcall target="serializer-autodist-mkdirs"/>
    <antcall target="serializer-autodist-copy-files"/>
      <!-- <antcall target="serializer-autodist-create-bin-packages"/> -->
    <antcall target="serializer-autodist-create-src-packages"/>
  </target>

  <target name="serializer-autodist-mkdirs">
    <echo message="Serializer: making distribution directories" />
    <mkdir dir="${serializer.dist.dir}"/> 
    <mkdir dir="${serializer.dist.dir}/src"/>
    <mkdir dir="${serializer.dist.dir}/tools"/>      
  </target>

  <target name="serializer-autodist-copy-files">
    <!-- Copy bin directory, which includes preexisting checked-in .jar files -->
<!--    <copy todir="${serializer.dist.dir}/bin">
      <fileset dir="${serializer.bin.dir}" />
    </copy> -->

    <echo message="Serializer: copy source files to ${serializer.dist.dir}/src" />
    <echo message="            ... from ${serializer.src.dir}/${serializer.reldir}" />
    <!-- Copy sources -->
    <copy todir="${serializer.dist.dir}/src/${serializer.reldir}">
      <fileset dir="${serializer.src.dir}/${serializer.reldir}"/>
    </copy>
    <!-- Copy the manifest -->
    <copy file="${serializer.src.dir}/${serializer.manifest.basename}"
          todir="${serializer.dist.dir}/src" />

    <!-- Copy built jars -->
    <copy file="${build.serializer.jar}" todir="${serializer.dist.dir}" />
    
    <!-- Copy runtime jars -->    
    <copy file="${lib.dir}/${xmlapis.jar.name}" todir="${serializer.dist.dir}" />
    <copy file="${lib.dir}/${parser.jar.name}" todir="${serializer.dist.dir}" />

    <!-- Copy licenses -->
    <copy todir="${serializer.dist.dir}">
      <fileset dir="." 
               includes="LICENSE.txt,NOTICE.txt"/>
    </copy>

    <!-- Copy tools -->
    <copy todir="${serializer.dist.dir}/tools">
      <fileset dir="./tools" includes="ant*"/>
    </copy>    

    <copy todir="${serializer.dist.dir}">
      <fileset dir="." includes="KEYS,build.xml,build.sh,build.bat"/>
    </copy>
  </target>

  <target name="serializer-autodist-create-bin-packages">
    <tar tarfile="${serializer.build.dir}/${serializer.dist.file}-bin.tar" >
      <tarfileset dir="${serializer.build.dir}">
        <patternset refid="serializer-bin-distro"/>
      </tarfileset>
    </tar>
    <gzip src="${serializer.build.dir}/${serializer.dist.file}-bin.tar" 
      zipfile="${serializer.build.dir}/${serializer.dist.file}-bin.tar.gz"/>

    <!--  
    <delete file="${serializer.build.dir}/${serializer.dist.file}-bin.tar" />
      -->

    <zip zipfile="${serializer.build.dir}/${serializer.dist.file}-bin.zip" >
      <fileset dir="${serializer.build.dir}">
        <patternset refid="serializer-bin-distro"/>
      </fileset>
    </zip>
  </target>

  <target name="serializer-autodist-create-src-packages">
    <tar tarfile="${serializer.build.dir}/${serializer.dist.file}-src.tar" >
      <tarfileset dir="${serializer.build.dir}">
        <patternset refid="serializer-src-distro"/>
      </tarfileset>
    </tar>
    <gzip src="${serializer.build.dir}/${serializer.dist.file}-src.tar" zipfile="${serializer.build.dir}/${serializer.dist.file}-src.tar.gz"/>

    <delete file="${serializer.build.dir}/${serializer.dist.file}-src.tar" />

    <zip zipfile="${serializer.build.dir}/${serializer.dist.file}-src.zip" >
      <fileset dir="${serializer.build.dir}">
        <patternset refid="serializer-src-distro"/>
      </fileset>
    </zip>
  </target>
<!-- ##################################################
     # END OF SECTION TO BUILD STAND-ALONE SERIALIZER #
     ################################################## -->

</project>
