<project name="XOM documentation" default="all" basedir=".">
  <description>
    Run stylesheets across DocBook source code
  </description>
    
  <!-- set global properties for this build -->
  <property name="build.dir"  value="./build"/>
  <property name="website.dir" value="${build.dir}/website"/>
  <property name="parentdist.dir"   value="../dist/website"/>

  <!-- The JDK's XSLT engine cannot handle the DocBook XSLT stylesheets
    so we use Saxon 6.5.3 loaded via Ivy from Maven Central. --> 
  <path id="saxon.classpath">
    <pathelement path="../ivy/saxon-6.5.3.jar"/>
  </path>

  <path id="xerces.class.path">
     <pathelement path="../lib/xercesImpl-2.12.2.jar"/> 
     <pathelement path="../lib/xml-apis-1.4.01.jar"/> 
  </path>
  
  <target name="init">
    <!-- Create the time stamp -->
    <tstamp/>

    <mkdir dir="${website.dir}"/>
    <mkdir dir="${parentdist.dir}"/>
    <copy todir="${website.dir}">
      <fileset dir="dtd"/>
    </copy>
    <copy todir="${build.dir}/dtd">
      <fileset dir="dtd"/>
    </copy>
  </target>

  <target name="finished_tutorial.xml" depends="init"
          description="Merge original chapters and examples into a single file">
    <java classname="nu.xom.samples.XIncludeDriver" output="${build.dir}/finished_tutorial.xml" fork="yes" failonerror="true">
        <arg line="tutorial.xml"/>
        <classpath refid="xerces.class.path"/>
        <classpath location="../build/classes"/>
        <classpath location="../build/jaxen-classes"/>
     </java>
  </target>

  
  <target name="valid" 
          description="Check validity of input documents and output"
          depends="tutorial">
    <java classname="nu.xom.samples.Validator" fork="yes" failonerror="true">
     <arg value="--strict"/>
     <arg value="index.html"/>
     <arg value="history.html"/>
     <arg value="faq.xml"/>
     <arg value="${build.dir}/finished_tutorial.xml"/>
     <arg value="${website.dir}/tutorial.xhtml"/>
     <arg value="infoset.xml"/>
     <arg value="xpath.xml"/>
     <arg value="license.xml"/>
     <arg value="openquestions.xml"/>
     <arg value="futuredirections.xml"/>
     <arg value="testsuite.xml"/>
     <arg value="faq.xml"/>
     <arg value="designprinciples.xml"/>
	
     <classpath refid="xerces.class.path"/>
     <classpath location="../build/classes"/>
     <classpath location="../build/jaxen-classes"/>
    </java>
  </target>


  <target name="tutorial" description="Generate a single XHTML document" depends="finished_tutorial.xml">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/tutorial.xhtml"  fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="${build.dir}/finished_tutorial.xml"/>
        <arg line="tutorial.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 

  <target name="design" depends="init" description="Design principles">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/designprinciples.xhtml" fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="designprinciples.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 

  <target name="license" depends="init" description="License for XOM">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/license.xhtml" fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="license.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 

 <target name="infoset" depends="init" description="Infoset Mapping">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/infoset.xhtml" fork="yes"  error="${build.dir}/error.txt" failonerror="true">
        <arg line="infoset.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 

 <target name="xpath" depends="init" description="XPath Mapping">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/xpath.xhtml"  fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="xpath.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 

  <target name="faq" depends="init" description="FAQ list for XOM">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/faq.xhtml"  fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="faq.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 

  <target name="open" depends="init" description="Open Questions list for XOM">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/openquestions.xhtml" fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="openquestions.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 

  <target name="future" depends="init" description="Future Directions for XOM">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/futuredirections.xhtml" fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="futuredirections.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 


  <target name="building" depends="init" description="How to build XOM">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/building.xhtml"  fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="building.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 


  <target name="install" depends="init" description="How to install XOM">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/install.xhtml" fork="yes"  error="${build.dir}/error.txt" failonerror="true">
        <arg line="install.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 


  <target name="testsuite" depends="init" description="How to test XOM">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/testsuite.xhtml"  fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="testsuite.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>	 


  <target name="samples" depends="init" description="Example code">
    <java classname="com.icl.saxon.StyleSheet" output="${website.dir}/samples.xhtml"  fork="yes" error="${build.dir}/error.txt" failonerror="true">
        <arg line="samples.xml"/>
        <arg line="../ivy/docbook/xhtml/docbook.xsl"/>
        <classpath refid="xerces.class.path"/>
        <classpath refid="saxon.classpath"/>
     </java>
  </target>


  <target name="html" depends="init" description="Raw HTML files that don't need to be transformed">
    <loadfile property="sidebar.content" srcFile="sidebar.html"/>
    <copy todir="${website.dir}" filtering="true">
      <fileset dir=".">
        <include name="index.html"/>
        <include name="history.html"/>
      </fileset>
      <filterset>
        <filter token="SIDEBAR" value="${sidebar.content}"/>
      </filterset>
    </copy>
    <copy todir="${website.dir}">
      <fileset dir=".">
        <include name="*.html"/>
        <include name="*.txt"/>
        <include name="favicon.ico"/>
        <exclude name="index.html"/>
        <exclude name="history.html"/>
      </fileset>
    </copy>
  </target>	


  <target name="dist" depends="html, tutorial, faq, infoset, xpath, design, future, open, license, testsuite, samples, install, building, valid">
    <copy todir="${parentdist.dir}" >  
      <fileset dir="${website.dir}" includes="**"/>  
    </copy> 
    <copy todir="${parentdist.dir}/whatswrong" >  
      <fileset dir="whatswrong" includes="**"/>  
    </copy>
  </target>

  <target name="clean" description="Remove build files">
    <delete dir="${build.dir}"/>
    <delete dir="${parentdist.dir}"/>
  </target>
</project>

