<?xml version="1.0"?>
<project name='XSD2HRC Module' default="all" basedir=".">

  <property file='build.properties'/>

  <property name='hrc-path' value='../../hrc'/>
  <property name='hrc-path-auto' value='${hrc-path}/auto/gen'/>

  <property name='custom' value='schemas-custom'/>

  <property name='core-schemas' value='../../doc/2003'/>


  <xmlcatalog id="DTDs">
    <dtd publicid="-//OASIS//DTD DocBook XML V4.1.2//EN"
         location="docbook/docbookx.dtd"/>
    <dtd publicid="-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
         location="web-app_2_2.dtd"/>

    <dtd publicid="-//Cail Lomecb//DTD Colorer HRC take5//EN"
         location="../../doc/2003/hrc.dtd"/>
    <dtd publicid="-//Cail Lomecb//DTD Colorer HRD take5//EN"
         location="../../doc/2003/hrd.dtd"/>
    <dtd publicid="-//Cail Lomecb//DTD Colorer CATALOG take5//EN"
         location="../../doc/2003/catalog.dtd"/>
  </xmlcatalog>


  
  <target name="all" description='Stub target'>
    <echo>Choose a required build target</echo>
  </target>

  <target name='distr' description='All distribution targets'
          depends='checkpaths,
                   xmlschema,xml,ant,mathml,xhtml,xslfo,xslt,
                   relaxng,web-app,wsc,wsf,
                   hrc,hrd,colorer5catalog,calcset,esc,xsd2hrc.custom,
                   docbook'>
  </target>



  <target name='checkpaths.mathml' unless='mathml-xsd-exists'>
<echo>
* ************ WARNING !! ************
* Can't find MathML external XML Schema files.
* If you don't have it, you can't build HRC scheme:
*     MathML :  ${mathml-xsd}
* If you have these files, please fix 'build.properties'
* file in colorer root directory and restart building.
* You can ignore this build error, removing 'fail-on-badpaths'
* property from the 'build.properties' file.
</echo>
<fail if='fail-on-badpaths'>
******** Build stopped because of bad XSD paths.
</fail>
  </target>

  <target name='checkpaths.docbook' unless='docbook-xsd-exists'>
<echo>
* ************ WARNING !! ************
* Can't find DocBook external XML Schema files.
* If you don't have it, you can't build HRC scheme:
*     DocBook:  ${docbook-xsd}
* If you have these files, please fix 'build.properties'
* file in colorer root directory and restart building.
* You can ignore this build error, removing 'fail-on-badpaths'
* property from the 'build.properties' file.
</echo>
<fail if='fail-on-badpaths'>
******** Build stopped because of bad XSD paths.
</fail>
  </target>

  <target name='checkpaths.xhtml' unless='xhtml-xsd-exists'>
<echo>
* ************ WARNING !! ************
* Can't find XHTML external XML Schema files.
* If you don't have it, you can't build HRC scheme:
*     XHTML  :  ${xhtml-xsd-dir}/xhtml1-*.xsd
* If you have these files, please fix 'build.properties'
* file in colorer root directory and restart building.
* You can ignore this build error, removing 'fail-on-badpaths'
* property from the 'build.properties' file.
</echo>
<fail if='fail-on-badpaths'>
******** Build stopped because of bad XSD paths.
</fail>
  </target>

  <target name='checkpaths'>
    <echo>Checking paths to the external XSD resources</echo>
    <available file='${mathml-xsd}' property='mathml-xsd-exists'/>
    <available file='${docbook-xsd}' property='docbook-xsd-exists'/>
    <condition property='xhtml-xsd-exists'>
      <and>
       <available file='${xhtml-xsd-dir}/xhtml1-strict.xsd'/>
       <available file='${xhtml-xsd-dir}/xhtml1-transitional.xsd'/>
       <available file='${xhtml-xsd-dir}/xhtml1-frameset.xsd'/>
      </and>
    </condition>
    <antcall target='checkpaths.docbook'/>
    <antcall target='checkpaths.xhtml'/>
    <antcall target='checkpaths.mathml'/>
  </target>



  <target name="xmlschema">
    <xslt in='schemas/XMLSchema.xsd' out='${hrc-path}/xml/xmlschema.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xmlschema'/>
      <param name='custom-defines' expression='${custom}/custom.xsd.xml'/>
    </xslt>
  </target>

  <target name="xml">
    <xslt in='schemas/xml.xsd' out='${hrc-path}/xml/xml.internal.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xml'/>
    </xslt>
  </target>

 
  <target name="docbook" if='docbook-xsd-exists'>
    <xslt in='${docbook-xsd}' out='${hrc-path-auto}/docbook.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='docbook'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.docbook.xml'/>
    </xslt>
  </target>

  <target name="ant">
    <xslt in='schemas/ant.auto.xsd' out='${hrc-path-auto}/ant.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='ant'/>
      <param name='allow-any-attr' expression='yes'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.ant.xml'/>
    </xslt>
  </target>

  <target name="mathml" if='mathml-xsd-exists'>
    <xslt in='${mathml-xsd}' out='${hrc-path-auto}/mathml.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='mathml'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='allow-any-attr' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.mathml.xml'/>
    </xslt>
  </target>


  <target name="xhtml" if='xhtml-xsd-exists'>
    <xslt in='${xhtml-xsd-dir}/xhtml1-strict.xsd' out='${hrc-path}/inet/xhtml-strict.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xhtml-strict'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.xhtml.xml'/>
    </xslt>
    <xslt in='${xhtml-xsd-dir}/xhtml1-transitional.xsd' out='${hrc-path}/inet/xhtml-trans.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xhtml-trans'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.xhtml.xml'/>
    </xslt>
    <xslt in='${xhtml-xsd-dir}/xhtml1-frameset.xsd' out='${hrc-path}/inet/xhtml-frameset.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xhtml-frameset'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.xhtml.xml'/>
    </xslt>
  </target>


  <target name="xslfo">
    <xslt in='schemas/xslfo.xsd' out='${hrc-path-auto}/xslfo.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xslfo'/>
      <param name='allow-any-attr' expression='yes'/>
    </xslt>
  </target>
  <target name="xslt">
    <xslt in='schemas/xslt.xsd' out='${hrc-path}/xml/xslt.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xslt'/>
      <param name='allow-unknown-root-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.xslt.xml'/>
    </xslt>
  </target>
  <target name="xslt2">
    <echo>Not yet completed!!!</echo>
    <xslt in='schemas/xslt2.xsd' out='${hrc-path}/xml/xslt2.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xslt2'/>
      <param name='allow-unknown-root-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.xslt2.xml'/>
    </xslt>
  </target>


  
  <target name="relaxng">
    <xslt in='schemas/relaxng.xsd' out='${hrc-path}/xml/relaxng.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='relaxng'/>
      <param name='allow-any-attr' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.relaxng.xml'/>
    </xslt>
  </target>

  <target name="web-app">
    <xslt in='schemas/web-app_2_3.xsd' out='${hrc-path-auto}/web-app.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='web-app'/>
      <param name='top-level-element' expression='web-app'/>
    </xslt>
  </target>

  <target name="taglib">
    <xslt in='schemas/web-jsptaglibrary_1_2.xsd' out='${hrc-path-auto}/taglib.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='taglib'/>
      <param name='top-level-element' expression='taglib'/>
      <param name='allow-unknown-elements' expression='yes'/>
    </xslt>
  </target>

  <target name="wsc">
    <xslt in='schemas/wsc.xsd' out='${hrc-path}/xml/wsc.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='wsc'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.wsc.xml'/>
    </xslt>
  </target>
  <target name="wsf">
    <xslt in='schemas/wsf.xsd' out='${hrc-path}/xml/wsf.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='wsf'/>
      <param name='allow-unknown-elements' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.wsf.xml'/>
    </xslt>
  </target>



  <target name="hrc">
    <xslt in='${core-schemas}/hrc.xsd' out='${hrc-path}/scripts/hrc.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='hrc'/>
      <param name='drop-annotations' expression='yes'/>
      <param name='custom-defines' expression='${custom}/custom.hrc.xml'/>
    </xslt>
  </target>
  <target name="hrd">
    <xslt in='${core-schemas}/hrd.xsd' out='${hrc-path}/scripts/hrd.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='hrd'/>
      <param name='drop-annotations' expression='yes'/>
    </xslt>
  </target>
  <target name="colorer5catalog">
    <xslt in='${core-schemas}/catalog.xsd' out='${hrc-path-auto}/colorer5catalog.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='colorer5catalog'/>
    </xslt>
  </target>

  <target name="calcset">
    <xslt in='schemas/calcset.xsd' out='${hrc-path-auto}/calcset.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='calcset'/>
      <param name='allow-any-attr' expression='yes'/>
      <param name='top-level-element' expression='calc'/>
    </xslt>
  </target>

  <target name="esc">
    <xslt in='schemas/esc.xsd' out='${hrc-path-auto}/esc.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='esc'/>
      <param name='custom-defines' expression='${custom}/custom.esc.xml'/>
    </xslt>
  </target>

  <target name="xsd2hrc.custom">
    <xslt in='schemas/xsd2hrc.custom.xsd' out='${hrc-path-auto}/xsd2hrc.custom.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xsd2hrc.custom'/>
    </xslt>
  </target>

  <target name="xmlspec">
    <echo>Not used yet</echo>
    <xslt in='schemas/xmlspec.xsd' out='${hrc-path-auto}/xmlspec.hrc' style='xsd2hrc.xsl'>
      <xmlcatalog refid="DTDs"/>
      <param name='hrctype' expression='xmlspec'/>
      <!--param name='include-prototype' expression='yes'/-->
    </xslt>
  </target>

</project>
