<project name="stmml" default="xsd2xsd" basedir=".">



<!-- process STMML Schema-->

<!-- parameters:

	Any of the property definitions below can be overridden at

	the command line. Common ones are:

	

//	-Dfile.root=fileroot root of the file (e.g. paper in paper.htm) def=paper

	-Dexample=exampleFoo              runs exampleFoo.xml (default=action1)

-->

<!-- example

ant stmml-->



<!-- defaults -->

 <property name="project" value="test"/>

 <property name="example" value="action1"/>



<!-- 

	files and directories:

	

	The default structure should be:



TBD

-->



<!-- ==== Be careful to preserve structure if editing ===== -->

<!-- user directories -->

 <property name="example.dir" value="${basedir}/examples"/>

 <property name="markup.dir" value="${basedir}/../markup"/>

 <property name="classes.dir" value="${markup.dir}/classes"/>

 <property name="lib.dir" value="${markup.dir}/lib"/>

 <property name="src.dir" value="${markup.dir}/src"/>

 <property name="xsl.dir" value="${basedir}/../xsl"/>



<!-- ***** EDIT THIS TO ENSURE PACKAGES ARE IN CLASSPATH *****  -->

<!-- libraries required for other functionality -->

<!-- the distrib has them in lib.dir already -->

 <property name="saxon.dir" value="${lib.dir}/saxon"/>

 <property name="fop.dir" value="${lib.dir}/fop-0.20.3"/>

 <property name="xerces.dir" value="../../../xml/xerces-2_2_0"/>



<!-- ============ DO NOT EDIT BELOW THIS LINE =============== -->



 <property name="fork" value="true"/>

 <property name="fork.javac" value="yes"/>





 <path id="common.classpath">

    <pathelement location="${classes.dir}"/>

<!--    <pathelement location="${pmrClasses.dir}"/>-->

<!--

    <pathelement location="${jumbolib.dir}/jumbo.jar"/>

    <pathelement location="${jumbolib.dir}/jumbolib.jar"/>

    <pathelement location="${jumbolib.dir}/pmrlib.jar"/>

-->

    <pathelement location="${lib.dir}/jakarta-regexp-1.2.jar"/>

<!--

    <pathelement location="${lib.dir}/wh2fo.jar"/>

-->

    <pathelement location="${saxon.dir}/saxon7.jar"/>

    <pathelement location="${xerces.dir}/xercesImpl.jar"/>

    <pathelement location="${xerces.dir}/xercesSamples.jar"/>

    <pathelement location="${xerces.dir}/xmlParserAPIs.jar"/>

    <pathelement location="${fop.dir}/build/fop.jar"/>

    <pathelement location="${fop.dir}/lib/batik.jar"/>

    <pathelement location="${fop.dir}/lib/xalan-2.0.0.jar"/>

<!--

    <pathelement location="${fop.dir}/lib/xerces-1.2.3.jar"/>

-->

    <pathelement location="${fop.dir}/lib/avalon-framework-4.0.jar"/>

    <pathelement location="${fop.dir}/lib/logkit-1.0.jar"/>

    <pathelement location="${fop.dir}/lib/jimi-1.0.jar"/>



 </path>



 <property name="classpath" refid="common.classpath"/>





 <target name="compileAll">

    <echo>${classpath}</echo>

    <copy file="${xerces.dir}/xercesImpl.jar" tofile="junk1.jar"/>

    <copy file="${xerces.dir}/xercesSamples.jar" tofile="junk2.jar"/>

    <copy file="${xerces.dir}/xmlParserAPIs.jar" tofile="junk3.jar"/>



<!--

  <echo>Compiling Java files; classpath is: ${classpath}</echo>  

  <mkdir dir="${classes.dir}"/>

  <javac srcdir="${src.dir}"

         destdir="${classes.dir}"

	 classpathref="common.classpath"

	 fork="${fork.javac}"

         debug="on"

  />

-->

 </target>



 <target name="init">

 </target>



  <target name="setup" >

<!--

    <uptodate property="${markFile.root}.wh.uptodate" targetfile="${markFile.whxml}">

      <srcfiles dir="${basedir}" includes="${markFile.htm}" />

    </uptodate>

    <uptodate property="${markFile.root}.xh.uptodate" targetfile="${markFile.orig.xhtml}">

      <srcfiles dir="${basedir}" includes="${markFile.htm}" />

    </uptodate>

-->

  </target>



<!-- ====================   CLEAN   ====================-->    



<!-- removes everything except ... -->

<!--

  <target name="tidyProject">

      <echo>${project.dir}"</echo>

    <delete>

      <fileset dir="${project.dir}">

        <exclude name="${markFile.html}"/>

        <include name="*.log"/>

        <include name="*.xml"/>

        <include name="*.xhtml"/>

      </fileset>

    </delete>

  </target>



  <target name="cleanProject">

      <echo>${project.dir}"</echo>

    <delete>

      <fileset dir="${project.dir}">

        <include name="*.log"/>

        <include name="*.svg"/>

        <include name="*.xml"/>

        <include name="*.xhtml"/>

      </fileset>

    </delete>

    <copy todir="${project.dir}" >

      <fileset dir="${project.dir}/../">

        <include name="paper_00.xhtml" />

      </fileset>

    </copy>

  </target>

-->



<!-- ====================   RUN   ====================-->    

<!-- run XML2preHTML on examples

-->

  <target name="xml2pre" depends="compileAll, setup" unless="${markFile.root}.wh.uptodate">



    <taskdef name="xml2pre"

        classname="org.xmlcml.markup.XML2preHTML">

    </taskdef>

    <echo>running xml2pre</echo>



    <xml2pre fromdir="${example.dir}" 

    	todir="${example.dir}" 

    	entityfile="${example.dir}/examples.ent" 

    	examplefile="${example.dir}/examples.xml" >

      <fileset dir="${example.dir}">

         <include name="**/*.xml"/>

         <exclude name="**/examples.xml"/>

      </fileset>

    </xml2pre>



<!-- concatenate examples into a single file -->

    <delete file="${example.dir}/concatenated.xml"/>

    <concat destfile="${example.dir}/concatenated0.xml">&lt;stmml xmlns="http://www.xml-cml.org/schema/stmml"></concat>      

    <concat destfile="${example.dir}/concatenated00.xml">&lt;/stmml></concat>

    <concat destfile="${example.dir}/concatenated.xml">

      <fileset dir="${example.dir}" includes="concatenated0.xml"/>

      <fileset dir="${example.dir}" 

         includes="*.xml" 

         excludes="all.xml,concatenated*.xml,examples.xml,personal.xml,refGroup1.xml" />

      <fileset dir="${example.dir}" includes="concatenated00.xml"/>

    </concat>



  </target>



  <target name="xsd2xsd" depends="xml2pre">

    <echo>running xsd2xsd</echo>

   <style 

        classpathref="common.classpath"

   	processor="trax"

	  in="${basedir}/stmml0.xsd"

	  out="${basedir}/stmml.xsd"

	  style="${xsl.dir}/copy.xsl">

    </style>

  </target>



  <target name="test" depends="xsd2xsd">

    <echo>testing xsd</echo>

    <echo>${classpath}</echo>

    <java 

	  fork="${fork}"

	  failonerror="true"

	  classname="dom.ASBuilder"

          classpath="${classpath}"

     >

       <arg line="-F"/>

       <arg line="-a"/>

       <arg line="${basedir}/stmml.xsd"/>

       <arg line="-i"/>

       <arg line="${example.dir}/${example}.xml"/>

    </java>



  </target>

    

<!-- ====================   Make HTML/SVG   ====================-->    

  <target name="paper" depends="">

   <style 

        classpathref="common.classpath"

   	processor="trax"

	  in="${markFile.final.xhtml}"

	  out="${markFile.final.html}"

	  style="${xsl.dir}/paper2html.xsl">

      <param name="file" expression="${file.root}"/>

    </style>

    

  </target>



<!-- ====================   Make FO/PDF   ====================-->    

  <target name="pdf" depends="paper">

    <echo>running FOP on ${markFile.final.html}</echo>

   <style 

          classpathref="common.classpath"

   	processor="trax"

	  in="${markFile.final.html}"

	  out="${markFile.fo}"

	  style="${xsl.dir}/xhtml2fo.xsl">

    </style>



    <java 

	  fork="${fork}"

	  failonerror="true"

          classname="org.apache.fop.apps.Fop"

          classpathref="common.classpath"

     >

       <arg line="${markFile.fo}"/>

       <arg line="${markFile.pdf}"/>

    </java>

  </target>



</project>









