<?xml version="1.0" encoding="UTF-8"?>
<!-- Apache Ant script to build spec.
     Philippe Le Hegaret, W3C -->
      
<project name="SOAP-JMS" default="main" basedir=".">
    <path id="saxon8.classpath">
        <pathelement location="saxon8/saxon8.jar"/>
    </path>
    <property name="htmlOutputDir" value="./"/>
    <property name="stylesheet" value="xmlspec-soapjms.xsl"/>
    <property name="glossary" value="extract-glist.xsl"/>
	<property name="generateBPlist" value="generateBPlist.xsl"/>
    <property name="diffformat" value="diffspec.xsl"/>
    <property name="last-public-draft" value="20070706"/>

    <macrodef name="m.gen.html">
        <attribute name="target" description="target HTML file" />
        <attribute name="source" description="source file" />
        <sequential>
            <echo>Generating @{target}</echo>
            <java fork="true" classname="net.sf.saxon.Transform">
                <classpath refid="saxon8.classpath"/>
                <arg value="-o"/>
                <arg value="${htmlOutputDir}@{target}"/>
                <arg value="@{source}"/>
                <arg value="${stylesheet}"/>
                <arg value="showAssertions=true"/>
            </java>
          <echo>@{target} is ready for CVS commit</echo>
        </sequential>        
    </macrodef>
    
    <target name="clean">
        <delete quiet="true" file="soapjms.html"/>
        <delete quiet="true" file="document-assertion-table.xml"/>
    </target>

    <target name="validate-xsl" description="Validates all XML files.">
        <xmlvalidate lenient="true">
            <fileset dir="." includes="*.xsl"/>
        </xmlvalidate>
    </target>

    <target name="validate-svg" description="Validates all SVG files.">
        <xmlvalidate lenient="false" warn="yes">
            <fileset dir="." includes="*.svg"/>
        </xmlvalidate>
    </target>

    <target name="validate-soapjms-specs" description="Validates all SOAP JMS spec files.">
        <xmlvalidate lenient="true" warn="yes" file="soapjms.xml"/>
        <xmlvalidate lenient="true" warn="yes" file="soapjms-2011-PR.xml"/>
        <xmlvalidate lenient="true" warn="yes" file="soapjms-2012-REC.xml"/>
    </target>

    <target name="validate" depends="validate-xsl,validate-svg,validate-soapjms-specs"/>

    <target name="updateAcks"
        description="Update acknowledgements. Before running this, 
	update ackcurrent.xml via  and ackold.xml
	via http://www.w3.org/2000/09/dbwg/details?group=42357&amp;former=1&amp;public=1 .">
        <get src="http://www.w3.org/2000/09/dbwg/details?group=42357&amp;public=1" dest="ackcurrent.xml"/>
        <get src="http://www.w3.org/2000/09/dbwg/details?group=42357&amp;former=1&amp;public=1" dest="ackold.xml"/>
        <java fork="true" classname="net.sf.saxon.Transform">
            <classpath refid="saxon8.classpath"/>
            <arg value="-o"/>
            <arg value="acknowledgements-current.txt"/>
            <arg value="ackcurrent.xml"/>
            <arg value="generate-acknowledgements.xsl"/>
            <arg value="participating=1"/>
        </java>
        <java fork="true" classname="net.sf.saxon.Transform">
            <classpath refid="saxon8.classpath"/>
            <arg value="-o"/>
            <arg value="acknowledgements-old.txt"/>
            <arg value="ackold.xml"/>
            <arg value="generate-acknowledgements.xsl"/>
            <arg value="participating=0"/>
        </java>
    </target>

    <target name="assertionTable" description="Transforms xml into assertions.">
        <echo>Generating document-assertion-table.xml</echo>
	 <touch file="document-assertion-table.xml" />
        <java fork="true" classname="net.sf.saxon.Transform">
            <classpath refid="saxon8.classpath"/>
            <arg value="-o"/>
            <arg value="${htmlOutputDir}document-assertion-table.xml"/>
            <arg value="soapjms.xml"/>
            <arg value="assertion-table.xsl"/>
        </java>    
    </target>

    <target name="html" description="Transforms xml into html.">
        <m.gen.html target="soapjms.html" source="soapjms.xml" />
    </target>
	
    <target name="html-2010-10-CR" description="Transforms CR xml into html.">
        <m.gen.html target="soapjms-2010-10-CR.html" source="soapjms-2010-10-CR.xml" />
    </target>

    <target name="html-2011-PR" description="Transforms PR xml into html.">
        <m.gen.html target="soapjms-2011-PR.html" source="soapjms-2011-PR.xml" />
    </target>

    <target name="html-2012-REC" description="Transforms PR xml into html.">
        <m.gen.html target="soapjms-2012-REC.html" source="soapjms-2012-REC.xml" />
    </target>

    <path id="diffmk.classpath">
        <pathelement location="${basedir}/diffmk.jar"/>
        <pathelement location="${basedir}/DiffMk.properties"/>
    </path>
    <target name="generateXMLdiff">
  <java classname="com.sun.xtc.diffmk.DiffMk" fork="true">
            <arg value="-doctype"/>
            <arg value="xmlspec"/>
            <arg value="-diff"/>
            <arg value="both"/>
            <arg value="-words"/>
            <arg value="soapjms-tr${last-public-draft}.xml"/>
            <arg value="soapjms.xml"/>
            <arg value="soapjms-diff${last-public-draft}.xml"/>
            <classpath path="diffmk.jar:DiffMk.properties"> </classpath>
        </java>
    </target>
    <target name="generateHTMLdiff">
        <java fork="true" classname="net.sf.saxon.Transform">
            <classpath refid="saxon8.classpath"/>
            <arg value="-o"/>
            <arg value="${htmlOutputDir}soapjms-diff${last-public-draft}.html"/>
            <arg value="soapjms-diff${last-public-draft}.xml"/>
            <arg value="diffspec.xsl"/>
        </java>
    </target>

    <target name="postprocess-diff">
      <java fork="true" classname="net.sf.saxon.Transform">
            <classpath refid="saxon8.classpath"/>
            <arg value="-o"/>
            <arg value="temp-soapjms-diff${last-public-draft}.xml"/>
            <arg value="soapjms-diff${last-public-draft}.xml"/>
            <arg value="diff-postprocess.xsl"/>
        </java>
        <copy tofile="soapjms-diff${last-public-draft}.xml"
            file="temp-soapjms-diff${last-public-draft}.xml" overwrite="true"/>
        <delete file="temp-soapjms-diff${last-public-draft}.xml"/>
    </target>

    <target name="diff" depends="generateXMLdiff, postprocess-diff, generateHTMLdiff"/>

    <target name="changelog" depends="getChangeLog, buildChangeLog"/>

    <target name="getChangeLog" description="Retrieve the CVS change log to be added into the specification">
        <echo>Retrieving changelog.xhtml</echo>
      <get src="http://services.w3.org/tidy/tidy?docAddr=http%3A%2F%2Fdev.w3.org%2Fcvsweb%2F2008%2Fws%2Fsoapjms%2Fsoapjms.xml&amp;forceXML=on" dest="changelog.xhtml"/>         
    </target>
    
    <target name="buildChangeLog" description="Transform the CVS change log to be added into the specification">
        <sequential>
            <echo>Generating changelog.xml</echo>
            <java fork="true" classname="net.sf.saxon.Transform">
                <classpath refid="saxon8.classpath"/>
                <arg value="-o"/>
                <arg value="${htmlOutputDir}changelog.xml"/>
                <arg value="changelog.xhtml"/>
                <arg value="cvswebrss.xsl"/>
                <arg value="showAssertions=true"/>
            </java>
        </sequential>        
    </target>
    
    <target name="generate" description="Generate the specification without updating changelog and acknowledgments sections"
	    depends="validate-soapjms-specs,html">
      <echo>WARNING: changelog.xml and acknowledgments.xml MAY be out of date. Use "main" target if necessary.</echo>
    </target>
    
    <target name="main" description="Generate the specification for a CVS commit"
	    depends="updateAcks,changelog,assertionTable,validate-soapjms-specs,html,html-2010-10-CR,html-2011-PR,html-2012-REC">
      <echo>Use target "generate" to avoid regenerating changelog.xml and acknowledgments.xml</echo>
    </target>

</project>

