<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 1995-2010 held by the author(s).  All rights reserved.
                          
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer
      in the documentation and/or other materials provided with the
      distribution.
    * Neither the names of the Naval Postgraduate School (NPS)
      Modeling Virtual Environments and Simulation (MOVES) Institute
      (http://www.nps.edu and http://www.MovesInstitute.org)
      nor the names of its contributors may be used to endorse or
      promote products derived from this software without specific
      prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-->

<!--
    Document   : build.xml
    Created on : 25 April 2006
    Author     : Don Brutzman
    Description: Creation and customization of Ant build.xml files for each X3D examples archive using common template
    Version    : $Id: build.xml 6987 2010-03-06 20:37:14Z brutzman $
-->

<project name="X3D examples: archive top level" default="all" basedir=".">
    <description>Creation and customization of Ant build.xml files for each X3D examples archive using a common template.</description>

    <!-- private configuration properties:  server names, user names and passwords ====================== -->

    <property name="access.properties.filename"  value="/.access/access.properties"/>
    <property file="${access.properties.filename}"/>

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

    <property environment="env"/>

    <!-- note that Netbeans default path is built in and will have to be overridden by going to   -->
    <!-- Tools > Options > Miscellaneous > Ant                                                    -->
    <!-- and then pointing to C:\apache-ant-1.8.0 (or somesuch directory)                         -->

    <!-- ANT Contrib archive at http://sourceforge.net/project/showfiles.php?group_id=36177       -->
    <!-- must have ant-contrib.jar in ANT_HOME/lib (or else specify path)                         -->
    <taskdef resource="net/sf/antcontrib/antlib.xml"/>

    <property name="saxon.dir" location="C:/java/saxonb9-1-0-6j"/>
        
    <!-- Ant Subversion Task at http://sourceforge.net/projects/antsvntask                        -->
    <!-- must have antsvntask.jar in ANT_HOME/lib (or else specify path)                          -->
    <!--
    <taskdef name="subversion"
             classname="net.tralfamadore.ast.tasks.SubversionTask"
             classpath="${ANT_HOME}/antsvntask-0.1.25/antsvntask.jar"/>    -->

    <property name="xj3d.dir" value="C:/Program Files/Xj3D"/>
    
    <property name="X3dToXhtml"                   location="../../stylesheets/X3dToXhtml"/>
    <property name="X3dToVrml97"                  location="../../stylesheets/X3dToVrml97"/>
    <property name="X3dToX3dvClassicVrmlEncoding" location="../../stylesheets/X3dToX3dvClassicVrmlEncoding"/>

    <xmlcatalog id="X3dCatalog">
        <dtd    publicId="ISO//Web3D//DTD X3D 3.0//EN"                                  location="../../../../specifications/x3d-3.0.dtd"/>
        <dtd    publicId="ISO//Web3D//DTD X3D 3.1//EN"                                  location="../../../../specifications/x3d-3.1.dtd"/>
        <dtd    publicId="ISO//Web3D//DTD X3D 3.2//EN"                                  location="../../../../specifications/x3d-3.2.dtd"/>
        <dtd    publicId="http://www.web3d.org/specifications/x3d-3.0.dtd"              location="../../../../specifications/x3d-3.0.dtd"/>
        <dtd    publicId="http://www.web3d.org/specifications/x3d-3.1.dtd"              location="../../../../specifications/x3d-3.1.dtd"/>
        <dtd    publicId="http://www.web3d.org/specifications/x3d-3.2.dtd"              location="../../../../specifications/x3d-3.2.dtd"/>
        <entity publicId="http://www.web3d.org/specifications/x3d-3.0.xsd"              location="../../../../specifications/x3d-3.0.xsd"/>
        <entity publicId="http://www.web3d.org/specifications/x3d-3.1.xsd"              location="../../../../specifications/x3d-3.1.xsd"/>
        <entity publicId="http://www.web3d.org/specifications/x3d-3.2.xsd"              location="../../../../specifications/x3d-3.2.xsd"/>
        <!-- Transitional DTD, versions 3.1 and 3.1 only -->
        <dtd    publicId="file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.0.dtd" location="../../../../specifications/x3d-3.0.dtd"/>
        <dtd    publicId="file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.1.dtd" location="../../../../specifications/x3d-3.1.dtd"/>
    </xmlcatalog>

    <!-- TODO:  warning if Ant version is earlier than apache-ant-1.6.5 -->

    <!-- Ant macro definitions ===================================================================================== -->

    <!-- excerpted/adapted from "SAXON XSLT Processing with Ant" by James Fuller, http://ablog.apress.com/?p=753 -->  
    <macrodef name="Saxon9" description="Invoke XSLT transformation on passed scene using passed stylesheet">
        <attribute name="scene"/>
        <attribute name="stylesheet"/>
        <attribute name="extension"/>
        <attribute name="compiled"/>
        <sequential>
            <!-- <echo message="Saxon9 processing @{scene}.@{extension}"/> -->
            <if>
                <equals arg1="@{compiled}" arg2="true" />
                <then>
                    <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/saxon9.jar;." fork="true" failonerror="false">
                        <!--<arg value="-t"/> timing information -->
                        <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
                        <arg value="-c"/>  <!-- compiled stylesheet -->
                        <arg value="-o"/>
                        <arg value="@{scene}.@{extension}"/>
                        <arg value="@{scene}.x3d"/>
                        <arg value="@{stylesheet}"/>
                    </java>
                </then>
                <else>
                    <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/saxon9.jar;." fork="true" failonerror="false">
                        <!--<arg value="-t"/> timing information -->
                        <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
                        <arg value="-o"/>
                        <arg value="@{scene}.@{extension}"/>
                        <arg value="@{scene}.x3d"/>
                        <arg value="@{stylesheet}"/>
                    </java> 
                </else>
            </if>
        </sequential>
    </macrodef>

    <!-- target tasks ===================================================================== -->
    
    <target name="all" depends="clean.backups,compile.Stylesheets,commonSetup,convertCmlScenes,validate.all,create.buildFile.all" description="fully rebuild and zip each of the example archives" >
        <!-- output directory is relative to specified base dir -->
    <!--
        <parallel>
            <ant dir="Basic"              target="all" output="build.out.txt"/>
            <ant dir="ConformanceNist"    target="all" output="build.out.txt"/>
            <ant dir="Savage"             target="all" output="build.out.txt"/>
            <ant dir="SavageDefense"      target="all" output="build.out.txt"/>
            <ant dir="Vrml2.0Sourcebook"  target="all" output="build.out.txt"/>
            <ant dir="X3dForWebAuthors"   target="all" output="build.out.txt"/>
        </parallel>
        <antcall target="sftp.uploadExampleUpdates"/>
        
        <parallel>
        </parallel>
    -->
            <antcall target="all.web3d"/>
            <antcall target="all.savage"/>
            <ant dir="X3dForWebAuthors"  target="all" output="build.out.txt"/>
    </target>

    <target name="all.quick" depends="clean.backups,commonSetup,compile.Stylesheets,validate.all,create.buildFile.all,processScenes.all,catalog.generateHtmlPages.all,zip.all,sftp.uploadExampleUpdates" 
        description="quick update and upload, catalogs not rebuilt" >
    </target>

    <target name="all.savage" depends="compile.Stylesheets,commonSetup,create.buildFile.Savage,create.buildFile.SavageDefense" description="fully rebuild and zip each of the Savage example archives" >
        <parallel>
            <sequential>
                <ant dir="SavageDefense"      target="all" output="build.out.txt"/>
                 <!-- <antcall target="sftp.uploadExampleUpdates.SavageDefense"/> -->
            </sequential>
            <sequential>
                <ant dir="Savage"             target="all" output="build.out.txt"/>
                 <!-- <antcall target="sftp.uploadExampleUpdates.Savage"/> -->
            </sequential>
        </parallel>
    </target>

    <target name="all.web3d" depends="compile.Stylesheets,commonSetup,convertCmlScenes,create.buildFile.Basic,create.buildFile.ConformanceNist,create.buildFile.Vrml2.0Sourcebook" description="fully rebuild and zip each of the Web3D example archives" >
        <parallel>
            <ant dir="Basic"              target="all" output="build.out.txt"/> <!-- output directory is relative to specified base dir -->
            <ant dir="ConformanceNist"    target="all" output="build.out.txt"/>
            <ant dir="Vrml2.0Sourcebook"  target="all" output="build.out.txt"/>
            <ant dir="X3dForWebAuthors"   target="all" output="build.out.txt"/>
        </parallel>
        <antcall target="sftp.uploadExampleUpdates.web3d.all"/>
    </target>
    
    <target name="catalog.all" depends="" description="run catalog task for each of the example archives" >
        <ant dir="Basic"              target="catalog"/>
        <ant dir="ConformanceNist"    target="catalog"/>
        <ant dir="Vrml2.0Sourcebook"  target="catalog"/>
        <ant dir="Savage"             target="catalog"/>
        <ant dir="SavageDefense"      target="catalog"/>
        <ant dir="X3dForWebAuthors"   target="catalog"/>
    </target>
    
    <target name="catalog.generateHtmlPages.all" depends="" description="run catalog.generateHtmlPages task for each of the example archives" >
        <ant dir="Basic"              target="catalog.generateHtmlPages"/>
        <ant dir="ConformanceNist"    target="catalog.generateHtmlPages"/>
        <ant dir="Vrml2.0Sourcebook"  target="catalog.generateHtmlPages"/>
        <ant dir="Savage"             target="catalog.generateHtmlPages"/>
        <ant dir="SavageDefense"      target="catalog.generateHtmlPages"/>
        <ant dir="X3dForWebAuthors"   target="catalog.generateHtmlPages"/>
    </target>
    
    <target name="processScenes.all" depends="" description="processScenes for each of the example archives" >
        <ant dir="Basic"              target="processScenes"/>
        <ant dir="ConformanceNist"    target="processScenes"/>
        <ant dir="Vrml2.0Sourcebook"  target="processScenes"/>
        <ant dir="Savage"             target="processScenes"/>
        <ant dir="SavageDefense"      target="processScenes"/>
        <ant dir="X3dForWebAuthors"   target="processScenes"/>
    </target>

    <target name="processScenes.X3dToXhtml" depends="clean.backups" description="clean out autogenerated svg files in example archives" >
        <echo message="processScenes.X3dToXhtml in example archives"/>
        <ant dir="Basic"              target="processScenes.X3dToXhtml"/>
        <ant dir="ConformanceNist"    target="processScenes.X3dToXhtml"/>
        <ant dir="Vrml2.0Sourcebook"  target="processScenes.X3dToXhtml"/>
        <ant dir="Savage"             target="processScenes.X3dToXhtml"/>
        <ant dir="SavageDefense"      target="processScenes.X3dToXhtml"/>
        <ant dir="X3dForWebAuthors"   target="processScenes.X3dToXhtml"/>
    </target>

    <target name="processScenes.captureViewpoints" description="use Xj3D to create snapshot pictures of each viewpoint" >
        <echo message="processScenes.X3dToXhtml in example archives"/>
        <ant dir="Basic"              target="processScenes.captureViewpoints"/>
        <ant dir="ConformanceNist"    target="processScenes.captureViewpoints"/>
        <ant dir="Vrml2.0Sourcebook"  target="processScenes.captureViewpoints"/>
        <ant dir="Savage"             target="processScenes.captureViewpoints"/>
        <ant dir="SavageDefense"      target="processScenes.captureViewpoints"/>
        <ant dir="X3dForWebAuthors"   target="processScenes.captureViewpoints"/>
    </target>
    
    <target name="refresh.all" depends="" description="refresh each of the example archives" >
        <ant dir="Basic"              target="refresh"/>
        <ant dir="ConformanceNist"    target="refresh"/>
        <ant dir="Vrml2.0Sourcebook"  target="refresh"/>
        <ant dir="Savage"             target="refresh"/>
        <ant dir="SavageDefense"      target="refresh"/>
        <ant dir="X3dForWebAuthors"   target="refresh"/>
    </target>
    
    <target name="clean.all" depends="clean.backups" description="clean out cautogenerated files in example archives" >
        <echo message="clean/delete backup files in example archives"/>
        <ant dir="Basic"              target="clean.all"/>
        <ant dir="ConformanceNist"    target="clean.all"/>
        <ant dir="Vrml2.0Sourcebook"  target="clean.all"/>
        <ant dir="Savage"             target="clean.all"/>
        <ant dir="SavageDefense"      target="clean.all"/>
        <ant dir="X3dForWebAuthors"   target="clean.all"/>
    </target>
    
    <target name="clean.html" depends="clean.backups" description="clean out autogenerated html files in example archives" >
        <echo message="clean/delete autogenerated html files in example archives"/>
        <ant dir="Basic"              target="clean.html"/>
        <ant dir="ConformanceNist"    target="clean.html"/>
        <ant dir="Vrml2.0Sourcebook"  target="clean.html"/>
        <ant dir="Savage"             target="clean.html"/>
        <ant dir="SavageDefense"      target="clean.html"/>
        <ant dir="X3dForWebAuthors"   target="clean.html"/>
    </target>
    
    <target name="clean.SVG" depends="clean.backups" description="clean out autogenerated svg files in example archives" >
        <echo message="clean/delete autogenerated svg files in example archives"/>
        <ant dir="Basic"              target="clean.SVG"/>
        <ant dir="ConformanceNist"    target="clean.SVG"/>
        <ant dir="Vrml2.0Sourcebook"  target="clean.SVG"/>
        <ant dir="Savage"             target="clean.SVG"/>
        <ant dir="SavageDefense"      target="clean.SVG"/>
        <ant dir="X3dForWebAuthors"   target="clean.SVG"/>
    </target>
    
    <target name="clean.backups" depends="" description="clean out autogenerated files (only)" >
        <echo message="clean/delete backup files"/>
        <delete verbose="true">
          <fileset dir="." includes="_new_pretty_print.html"/>
            <fileset dir="." includes="_new_result.wrl"/>
            <fileset dir="." includes="_new_result.x3dv"/>
            <fileset dir="." includes="_new_result.x3db"/>
            <fileset dir="." includes="_new_resultCanonical.xml"/>
            <fileset dir="." includes="Thumb.db"/>
            <fileset dir="." includes="*.bak"/>
            <fileset dir="." includes="*.$$$$$$"/> <!--escaped .$$$ -->
            <fileset dir="." includes="**/Untitled-?.x3d"/>
        </delete>
    </target>
    
    <target name="clean.archives" depends="" description="clean out autogenerated files in example archives" >
        <echo message="clean/delete files in example _archive directories"/>
        <delete includeEmptyDirs="true" failonerror="false">
            <fileset dir="_archive/"/>
            <fileset dir="*/_archive/"/>
            <fileset dir="*/*/_archive/"/>
            <fileset dir="*/*/*/_archive/"/>
            <fileset dir="archive/"/>
            <fileset dir="*/archive/"/>
            <fileset dir="*/*/archive/"/>
            <fileset dir="*/*/*/archive/"/>
        </delete>
    </target>
    
    <target name="commonSetup" depends="compile.Stylesheets,HelloWorldCopyToArchives" description="HelloWorld and newScene preparation for examples directory" >
        <copy file="HelloWorld.x3d" todir="Basic"/>
        <ant dir="Basic" target="HelloWorld"/>
        <copy todir="." verbose="true">
            <fileset dir="Basic" includes="HelloWorld.*"/>
        </copy>
        <copy file="newScene.x3d" todir="Basic"/>
        <ant dir="Basic" target="newScene"/>
        <copy todir="." verbose="true">
            <fileset dir="Basic" includes="newScene.*"/>
        </copy>
    </target>

    <!-- TODO:  move to stylesheets/build.xml -->
    <target name="clean.Stylesheets" depends="" description="remove compiled stylesheets" >
        <echo>delete compiled *.sxx stylesheets</echo>
        <delete file="${X3dToXhtml}.sxx"/>
        <delete file="${X3dToVrml97}.sxx"/>
        <delete file="${X3dToX3dvClassicVrmlEncoding}.sxx"/>
    </target>

    <!-- TODO:  move to stylesheets/build.xml -->
    <target name="compile.Stylesheets" depends="" description="compile stylesheets using Saxon" >
        <echo>validate ${X3dToXhtml}.xslt,${X3dToVrml97}.xslt,${X3dToX3dvClassicVrmlEncoding}.xslt</echo>
        <xmlvalidate file="${X3dToVrml97}.xslt"                  failonerror="false" warn="true" lenient="yes"/>
        <xmlvalidate file="${X3dToXhtml}.xslt"                   failonerror="false" warn="true" lenient="yes"/>
        <xmlvalidate file="${X3dToX3dvClassicVrmlEncoding}.xslt" failonerror="false" warn="true" lenient="yes"/>
        <!-- http://www.saxonica.com/documentation/using-xsl/compiling.html -->
        <if>
            <outofdate>
                <sourcefiles>
                    <fileset file="${X3dToXhtml}.xslt"/>
                </sourcefiles>
                <mapper dir="." type="glob" from="*.xslt" to="*.sxx"/>
            </outofdate>
            <then>
                <echo>Compiling X3dToXhtml.xslt as X3dToXhtml.sxx ...</echo>
                <java classname="net.sf.saxon.Compile" classpath="${saxon.dir}/saxon9.jar;." fork="true">
                    <arg value="-t"/>
                    <arg value="${X3dToXhtml}.xslt"/>
                    <arg value="${X3dToXhtml}.sxx"/>
                </java>
            </then>
            <else>
                <echo message="Compiled stylesheet X3dToXhtml.sxx up to date"/>
            </else>
        </if>
        <if>
            <outofdate>
                <sourcefiles>
                    <fileset file="${X3dToVrml97}.xslt"/>
                </sourcefiles>
                <mapper dir="." type="glob" from="*.xslt" to="*.sxx"/>
            </outofdate>
            <then>
                <echo>Compiling X3dToVrml97.xslt as X3dToVrml97.sxx ...</echo>
                <java classname="net.sf.saxon.Compile" classpath="${saxon.dir}/saxon9.jar;." fork="true">
                    <arg value="-t"/>
                    <arg value="${X3dToVrml97}.xslt"/>
                    <arg value="${X3dToVrml97}.sxx"/>
                </java>
            </then>
            <else>
                <echo message="Compiled stylesheet X3dToVrml97.sxx up to date"/>
            </else>
        </if>
        <if>
            <outofdate>
                <sourcefiles>
                    <fileset file="${X3dToX3dvClassicVrmlEncoding}.xslt"/>
                </sourcefiles>
                <mapper dir="." type="glob" from="*.xslt" to="*.sxx"/>
            </outofdate>
            <then>
                <echo>Compiling X3dToX3dvClassicVrmlEncoding.xslt as X3dToX3dvClassicVrmlEncoding.sxx ...</echo>
                <java classname="net.sf.saxon.Compile" classpath="${saxon.dir}/saxon9.jar;." fork="true">
                    <arg value="-t"/>
                    <arg value="${X3dToX3dvClassicVrmlEncoding}.xslt"/>
                    <arg value="${X3dToX3dvClassicVrmlEncoding}.sxx"/>
                </java>
            </then>
            <else>
                <echo message="Compiled stylesheet X3dToX3dvClassicVrmlEncoding.sxx up to date"/>
            </else>
        </if>
    </target>
    
    <target name="create.buildFile.all" depends="create.buildFile.Basic,create.buildFile.ConformanceNist,create.buildFile.Vrml2.0Sourcebook,create.buildFile.Savage,create.buildFile.SavageDefense,create.buildFile.X3dForWebAuthors"
        description="create and customize each X3D archive build.xml" >
        <!-- all work performed by dependency targets -->
    </target>
     
    <macrodef name="create.buildFile.xml" description="Invoke XSLT transformation on passed scene using passed stylesheet">
        <attribute name="archive.name"/>
        <sequential>
            <!-- TODO:  output needs updated directory name, directory title, directoryfilters, creation timestamp -->
            <copy    file="@{archive.name}/build.xml" todir="@{archive.name}/_archive/" overwrite="true" failonerror="false"/>
            <copy  tofile="@{archive.name}/build.xml" file="buildExamplesTemplate.xml" overwrite="true"/>
            <copy  tofile="@{archive.name}/CatalogManager.properties" file="../../tools/CreateContentCatalog/CatalogManager.properties" overwrite="true"/>
            <if>
                <or>
                    <equals arg1="@{archive.name}" arg2="Basic" />
                    <equals arg1="@{archive.name}" arg2="Vrml2.0Sourcebook" />
                    <equals arg1="@{archive.name}" arg2="X3dForWebAuthors" />
                </or>
                <then>
                    <echo>Set numberOfSections="1":</echo>
                    <replace file="@{archive.name}/build.xml" token="_numberOfSections_" value="1" summary="true"/>
                    <replace file="@{archive.name}/build.xml" token="_subdir_"  value="*" summary="true"/>
                    <echo>Set X3D and XML fileset filters:</echo>
                    <replace file="@{archive.name}/build.xml" token="_x3dScenes_"   value="*/*.x3d"  summary="true"/>
                    <replace file="@{archive.name}/build.xml" token="_xmlFiles_"    value="*/*.xml"  summary="true"/>
                    <replace file="@{archive.name}/build.xml" token="_regexp2_"     value="()()()"   summary="true"/>
                </then>
                <else>
                    <!-- archive.name: ConformanceNIST, Savage, SavageDefense -->
                    <echo>Set numberOfSections="2":</echo>
                    <replace file="@{archive.name}/build.xml" token="_numberOfSections_" value="2" summary="true"/>
                    <replace file="@{archive.name}/build.xml" token="_subdir_" value="*/*" summary="true"/>
                    <echo>Set X3D and XML fileset filters:</echo>
                    <replace file="@{archive.name}/build.xml" token="_x3dScenes_"   value="*/*/*.x3d"  summary="true"/>
                    <replace file="@{archive.name}/build.xml" token="_xmlFiles_"    value="*/*/*.xml"  summary="true"/>
                    <replace file="@{archive.name}/build.xml" token="_regexp2_"     value="([^\n]*)_archiveName_[\\/]([^\n^\\]*)[\\/]([^\n^\\]*)([\\/][^\n]*)\.x3d"   summary="true"/>
                </else>
            </if>
            <echo>Set archive name to @{archive.name}:</echo>
            <replace file="@{archive.name}/build.xml" token="_archiveName_"      value="@{archive.name}" summary="true"/>
            <echo>create.buildFile.xml @{archive.name} complete</echo>
            <echo>==================================</echo>
        </sequential>
    </macrodef>
    
    <target name="validate.buildExamplesTemplate.xml" depends="" description="validate buildExamplesTemplate.xml" >
        <xmlvalidate failonerror="true" warn="true" lenient="yes">
            <fileset dir=".">
                <include name="buildExamplesTemplate.xml"/>
            </fileset>
        </xmlvalidate>
    </target>
    
    <target name="create.buildFile.Basic" depends="validate.buildExamplesTemplate.xml" description="create and customize archive build.xml for www.web3d.org/x3d/content/examples/Basic/" >
        <create.buildFile.xml archive.name="Basic"/>
    </target>
    
    <target name="create.buildFile.ConformanceNist" depends="validate.buildExamplesTemplate.xml" description="create and customize archive build.xml for www.web3d.org/x3d/content/examples/ConformanceNist/" >
        <create.buildFile.xml archive.name="ConformanceNist"/>
    </target>
    
    <target name="create.buildFile.Vrml2.0Sourcebook" depends="validate.buildExamplesTemplate.xml" description="create and customize archive build.xml for www.web3d.org/x3d/content/examples/Vrml2.0Sourcebook/" >
        <create.buildFile.xml archive.name="Vrml2.0Sourcebook"/>
    </target>
    
    <target name="create.buildFile.Savage" depends="validate.buildExamplesTemplate.xml" description="create and customize archive build.xml for www.web3d.org/x3d/content/examples/Savage/" >
        <create.buildFile.xml archive.name="Savage"/>
    </target>
    
    <target name="create.buildFile.SavageDefense" depends="validate.buildExamplesTemplate.xml" description="create and customize archive build.xml for www.web3d.org/x3d/content/examples/SavageDefense/" >
        <create.buildFile.xml archive.name="SavageDefense"/>
    </target>
    
    <target name="create.buildFile.X3dForWebAuthors" depends="validate.buildExamplesTemplate.xml" description="create and customize archive build.xml for www.web3d.org/x3d/content/examples/X3dForWebAuthors/" >
        <create.buildFile.xml archive.name="X3dForWebAuthors"/>
    </target>

    <!-- ============================================================================== -->
  
    <!-- SFTP ssh taskdef. this requires maverick-ant installed                                -->
    <!-- Maverick ssh/sftp ant task provided at http://www.sshtools.com/showMaverickAntTask.do -->
    <!-- Configuration prerequisite: move maverick.jar to local ant/lib/                       -->
    <taskdef  name="ssh" classname="com.sshtools.ant.Ssh"/>

    <!-- TODO verify maverick operation... -->
    <!-- recursing via includes="**/*.*" doesn't preserve directory structure on client side, likely due to sftp limitation  -->
    <!-- thus must use .zip, .tar.gz (.tgz) to preserve archive structure  -->

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

    <target name="sftp.askUsernamePassword.savage"
        description="If needed, ask for username, password">
        <if>
            <not>
                <and>
                    <isset property="username.savage"/>
                    <isset property="password.savage"/>
                </and>
            </not>
            <then>
                <echo  message="username.savage:, password.savage not obtained via file ${access.properties.filename}"/> 
                <input message="username.savage:"
                addproperty="username.savage" />
                <input message="password.savage:"
                addproperty="password.savage" />
                <echo  message="username.savage=${username.savage}"/>
                <echo  message="password.savage=################"/> 
                <!--<echo  message="password.savage=${password.savage}"/> debug -->
            </then>
            <else>
                <echo  message="username.savage, password.savage obtained from file ${access.properties.filename}"/> 
            </else>
        </if>
    </target>
  
    <target name="sftp.askUsernamePassword.savageDefense"
        description="If needed, ask for username, password">
        <if>
            <not>
                <and>
                    <isset property="username.savageDefense"/>
                    <isset property="password.savageDefense"/>
                </and>
            </not>
            <then>
                <echo  message="username.savageDefense:, password.savageDefense not obtained via file ${access.properties.filename}"/> 
                <input message="username.savageDefense:"
                addproperty="username.savageDefense" />
                <input message="password.savageDefense:"
                addproperty="password.savageDefense" />
                <echo  message="username.savageDefense=${username.savageDefense}"/>
                <echo  message="password.savageDefense=################"/> 
                <!--<echo  message="password.savageDefense=${password.savageDefense}"/> debug -->
            </then>
            <else>
                <echo  message="username.savageDefense, password.savageDefense obtained from file ${access.properties.filename}"/> 
            </else>
        </if>
    </target>
  
    <target name="sftp.askUsernamePassword.web3d"
        description="If needed, ask for username, password">
        <if>
            <not>
                <and>
                    <isset property="username.web3d"/>
                    <isset property="password.web3d"/>
                </and>
            </not>
            <then>
                <echo  message="username.web3d, password.web3d not obtained via file ${access.properties.filename}"/> 
                <input message="username.web3d:"
                addproperty="username.web3d" />
                <input message="password.web3d:"
                addproperty="password.web3d" />
                <echo  message="username.web3d=${username.web3d}"/>
                <echo  message="password.web3d=################"/> 
                <!--<echo  message="password.web3d=${password.web3d}"/> debug -->
            </then>
            <else>
                <echo  message="username.web3d, password.web3d obtained from file ${access.properties.filename}"/> 
            </else>
        </if>
    </target>
  
    <target name="sftp.askUsernamePassword.X3dForWebAuthors"
        description="If needed, ask for username, password">
        <if>
            <not>
                <and>
                    <isset property="username.X3dForWebAuthors"/>
                    <isset property="password.X3dForWebAuthors"/>
                </and>
            </not>
            <then>
                <echo  message="username.X3dForWebAuthors, password.X3dForWebAuthors not obtained via file ${access.properties.filename}"/> 
                <input message="username.X3dForWebAuthors:"
                   addproperty="username.X3dForWebAuthors" />
                <input message="password.X3dForWebAuthors:"
                   addproperty="password.X3dForWebAuthors" />
                <echo  message="username.X3dForWebAuthors=${username.X3dForWebAuthors}"/>
                <echo  message="password.X3dForWebAuthors=################"/> 
                <!--<echo  message="password.web3d=${password.X3dForWebAuthors}"/> debug -->
            </then>
            <else>
                <echo  message="username.X3dForWebAuthors, password.X3dForWebAuthors obtained from file ${access.properties.filename}"/> 
            </else>
        </if>
    </target>
    
    <!-- TODO:  figure out if possible to repeat upload until successful, countering loss of sftp connection failure -->

    <target name="sftp.uploadExampleUpdates" depends="sftp.uploadExampleUpdates.web3d.all,sftp.uploadExampleUpdates.Savage,sftp.uploadExampleUpdates.SavageDefense,sftp.uploadExampleUpdates.X3dForWebAuthors"
        description="sftp upload all updated X3D archive files">
        <!-- TODO:  convert other sftp.uploadExampleUpdates tasks into macros -->
    </target>

    <target name="sftp.uploadExampleUpdates.Savage" depends="sftp.uploadExampleUpdates.Savage.scenes,sftp.uploadExampleUpdates.Savage.zip"
        description="sftp upload of updated X3D archive files, including .zip">
    </target>

    <target name="sftp.uploadExampleUpdates.Savage.scenes" depends="sftp.askUsernamePassword.savage,sftp.uploadExampleUpdates.web3d.common"
        description="sftp upload of updated X3D archive files, excluding .zip">
        <echo  message="sftp upload to sftp://${sftpServer.savage}"/>
        <ssh host="${sftpServer.savage}"
            username="${username.savage}"
            password="${password.savage}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true"
                skipfailedtransfers="true"
                remotedir="${sftpDirectory.savage}">
                <fileset dir=".">
                    <include name="indexSavage.redirect.html"/>
                    <include name="help.html"/>
                    <include name="X3dResources.html"/>
                    <include name="X3dSceneAuthoringHints.html"/>
                    <include name="license.*"/>
                    <include name="images/*"/>
                    <include name="Savage/*"/>
                    <include name="Savage/**/*"/>
                    <!-- excluding these-->
                    <exclude name="X3dExamplesSavage.zip"/>
                    <exclude name="**/archive/*"/>
                    <exclude name="**/_archive/*"/>
                    <exclude name="_schematron/*"/>
                    <exclude name="**/_schematron/*"/>
                    <exclude name="**/_hide/*"/>
                    <exclude name="**/hide/*"/>
                    <exclude name="**/CVS/*"/>
                    <exclude name="**/.svn/*"/>
                    <exclude name="**/_new*.*"/>
                    <exclude name="**/*.bak"/>
                    <exclude name="**/Thumbs.db"/>
                    <exclude name="nbproject/*"/>
                    <exclude name="**/nbproject/*"/>
                    <exclude name="CVS/"/>
                    <exclude name="*/CVS/"/>
                    <exclude name=".svn/"/>
                    <exclude name="**/.svn"/>
                    <exclude name="**/*.$$$"/>
                    <exclude name="**/*.\$\$\$"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.Savage ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadSavageStudioExcerpt.zip" depends="sftp.askUsernamePassword.savage"
        description="sftp upload of updated X3D X3dExamplesSavageStudioExcerpt.zip archive">
        <echo  message="sftp upload to sftp://${sftpServer.savage}"/>
        <ssh host="${sftpServer.savage}"
            username="${username.savage}"
            password="${password.savage}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false"
                skipfailedtransfers="false"
                remotedir="${sftpDirectory.savage}">
                <fileset dir=".">
                    <include name="X3dExamplesSavageStudioExcerpt.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadSavageStudioExcerpt.zip ssh-sftp task complete"/>
    </target>

    <target name="sftp.update.common" depends="sftp.askUsernamePassword.web3d,sftp.askUsernamePassword.X3dForWebAuthors,sftp.askUsernamePassword.savage,sftp.askUsernamePassword.savageDefense"
        description="sftp upload of X3dResources.html and other common files on all online example archives">
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true" 
                skipfailedtransfers="true" 
                remotedir="${sftpDirectory.web3d}" >
                <fileset refid="web3d.common.fileset"/>
            </sftp>
        </ssh>
        <echo  message="========= web3D.org update.common complete ========="/>
        <ssh host="${sftpServer.X3dForWebAuthors}"
            username="${username.X3dForWebAuthors}"
            password="${password.X3dForWebAuthors}">
            <sftp action="put" verbose="true"
                newer="true"
                skipfailedtransfers="true"
                remotedir="${sftpDirectory.X3dForWebAuthors}" >
                <fileset refid="web3d.common.fileset"/>
            </sftp>
        </ssh>
        <echo  message="========= X3dGraphics.com update.common complete ========="/>
        <ssh host="${sftpServer.savage}"
            username="${username.savage}"
            password="${password.savage}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false"
                skipfailedtransfers="false"
                remotedir="${sftpDirectory.savage}">
                <fileset refid="web3d.common.fileset"/>
            </sftp>
        </ssh>
        <echo  message="========= Savage update.common complete ========="/>
        <ssh host="${sftpServer.savageDefense}"
            username="${username.savageDefense}"
            password="${password.savageDefense}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true"
                skipfailedtransfers="true"
                remotedir="${sftpDirectory.savageDefense}">
                <fileset refid="web3d.common.fileset"/>
            </sftp>
        </ssh>
        <echo  message="========= SavageDefense update.common complete ========="/>
    </target>

    <target name="sftp.uploadSavageAuvWorkbenchModelDistribution.zip" depends="sftp.askUsernamePassword.savage"
        description="sftp upload of updated X3D SavageAuvWorkbenchModelDistribution.zip archive">
        <echo  message="sftp upload to sftp://${sftpServer.savage}"/>
        <ssh host="${sftpServer.savage}"
            username="${username.savage}"
            password="${password.savage}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false"
                skipfailedtransfers="false"
                remotedir="${sftpDirectory.savage}">
                <fileset dir=".">
                    <include name="X3dExamplesSavageAuvWorkbenchExcerpt.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.Savage.zip ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.Savage.zip" depends="sftp.askUsernamePassword.savage"
        description="sftp upload of updated X3D Savage.zip archive">
        <echo  message="sftp upload to sftp://${sftpServer.savage}"/>
        <ssh host="${sftpServer.savage}"
            username="${username.savage}"
            password="${password.savage}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false"
                skipfailedtransfers="false"
                remotedir="${sftpDirectory.savage}">
                <fileset dir=".">
                    <include name="X3dExamplesSavage.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.Savage.zip ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.SavageDefense" depends="sftp.uploadExampleUpdates.SavageDefense.scenes,sftp.uploadExampleUpdates.SavageDefense.zip"
        description="sftp upload of updated X3D archive files, including .zip">
    </target>

    <target name="sftp.uploadExampleUpdates.SavageDefense.scenes" depends="sftp.askUsernamePassword.savageDefense,sftp.uploadExampleUpdates.web3d.common"
        description="sftp upload of updated X3D archive files, excluding .zip">
        <echo  message="sftp upload to sftp://${sftpServer.savageDefense}"/>
        <ssh host="${sftpServer.savageDefense}"
            username="${username.savageDefense}"
            password="${password.savageDefense}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true"
                skipfailedtransfers="true"
                remotedir="${sftpDirectory.savageDefense}">
                <fileset dir=".">
                    <include name="indexSavageDefense.redirect.html"/>
                    <include name="help.html"/>
                    <include name="X3dResources.html"/>
                    <include name="X3dSceneAuthoringHints.html"/>
                    <include name="license.*"/>
                    <include name="images/*"/>
                    <include name="SavageDefense/*"/>
                    <include name="SavageDefense/**/*"/>
                    <!-- excluding these-->
                    <exclude name="X3dExamplesSavageDefense.zip"/>
                    <exclude name="**/archive/*"/>
                    <exclude name="**/_archive/*"/>
                    <exclude name="_schematron/*"/>
                    <exclude name="**/_schematron/*"/>
                    <exclude name="**/_hide/*"/>
                    <exclude name="**/hide/*"/>
                    <exclude name="**/CVS/*"/>
                    <exclude name="**/.svn/*"/>
                    <exclude name="**/_new*.*"/>
                    <exclude name="**/*.bak"/>
                    <exclude name="**/Thumbs.db"/>
                    <exclude name="nbproject/*"/>
                    <exclude name="**/nbproject/*"/>
                    <exclude name="CVS/"/>
                    <exclude name="*/CVS/"/>
                    <exclude name=".svn/"/>
                    <exclude name="**/.svn"/>
                    <exclude name="**/*.$$$"/>
                    <exclude name="**/*.\$\$\$"/>
                </fileset>
            </sftp>
        </ssh>
        <!-- Exception:  Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
        <if>
            <isset property="notify.savageDefense"/>
            <then>
                <mail from="brutzman@nps.navy.mil(Don Brutzman)" tolist="notify.savageDefense" mailhost="${nps.mailhost}" password="${nps.password}"
                      subject="SavageDefense archive uploaded"
                      message="SavageDefense archive uploaded to https://${sftpServer.savageDefense}/SavageDefense"/>
            </then>
            <else>
                <echo  message="notification mail not sent, no value for property notify.savageDefense"/> 
            </else>
        </if>
        -->
        <echo  message="sftp.uploadExampleUpdates.SavageDefense ssh-sftp task complete"/>
    </target>
    
    <target name="sftp.uploadExampleUpdates.SavageDefense.zip" depends="sftp.askUsernamePassword.savageDefense"
        description="sftp upload of updated X3D SavageDefense.zip archive">
        <echo  message="sftp upload to sftp://${sftpServer.savageDefense}"/>
        <ssh host="${sftpServer.savageDefense}"
            username="${username.savageDefense}"
            password="${password.savageDefense}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false"
                skipfailedtransfers="false"
                remotedir="${sftpDirectory.savageDefense}">
                <fileset dir=".">
                    <include name="X3dExamplesSavageDefense.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.SavageDefense.zip ssh-sftp task complete"/>
    </target>
    
        <!-- Exception:  Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
        <if>
            <isset property="notify.savageDTO"/>
            <then>
                <mail from="brutzman@nps.navy.mil(Don Brutzman)" tolist="notify.savageDTO" mailhost="${nps.mailhost}" password="${nps.password}"
                      subject="SavageDTO archive uploaded"
                      message="SavageDTO archive uploaded to https://${sftpServer.savageDTO}/SavageDTO"/>
            </then>
            <else>
                <echo  message="notification mail not sent, no value for property notify.savageDTO"/> 
            </else>
        </if>
        -->

    <target name="sftp.uploadExampleUpdates.web3d.all" depends="sftp.uploadExampleUpdates.web3d.common,sftp.uploadExampleUpdates.Basic,sftp.uploadExampleUpdates.Vrml2.0Sourcebook,sftp.uploadExampleUpdates.ConformanceNist"
        description="sftp upload of updated X3D archive files">
        <echo  message="sftp.uploadExampleUpdates.web3d ssh-sftp task complete"/>
    </target>

    <fileset id="web3d.common.fileset" dir=".">
        <include name="license.*"/>
        <include name="*.html"/>
        <include name="*.txt"/>
        <include name="*.xml"/>
        <include name="Hello*"/>
        <include name="earth-topo*"/>
        <include name="newScene*"/>
        <include name="images/*"/>
        <!-- excluding these-->
        <exclude name="indexSavage.redirect.html"/>
        <exclude name="indexSavageDefense.redirect.html"/>
        <exclude name="indexX3dForWebAuthors.redirect.html"/>
        <exclude name="**/archive/*"/>
        <exclude name="**/_archive/*"/>
        <exclude name="_schematron/*"/>
        <exclude name="**/_schematron/*"/>
        <exclude name="**/_hide/*"/>
        <exclude name="**/hide/*"/>
        <exclude name="**/CVS/*"/>
        <exclude name="**/.svn/*"/>
        <exclude name="**/_new*.*"/>
        <exclude name="**/*.bak"/>
        <exclude name="**/Thumbs.db"/>
        <exclude name="nbproject/*"/>
        <exclude name="**/nbproject/*"/>
        <exclude name="CVS/"/>
        <exclude name="*/CVS/"/>
        <exclude name=".svn/"/>
        <exclude name="**/.svn/"/>
        <exclude name="**/*.$$$"/>
        <exclude name="**/*.\$\$\$"/>
    </fileset>

    <target name="sftp.uploadExampleUpdates.web3d.common" depends=""
        description="sftp upload of shared updated X3D archive files">
        <echo  message="sftp upload to sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true"
                skipfailedtransfers="true"
                remotedir="${sftpDirectory.web3d}" >
                <fileset refid="web3d.common.fileset"/>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.web3d.common ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.Basic" depends="sftp.uploadExampleUpdates.Basic.scenes,sftp.uploadExampleUpdates.Basic.zip"
        description="sftp upload of updated X3D Basic archive files, including .zip">
    </target>

    <target name="sftp.uploadExampleUpdates.Basic.scenes" depends="sftp.askUsernamePassword.web3d"
        description="sftp upload of updated X3D Basic archive files, excluding .zip">
        <echo  message="sftp upload to sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true" 
                skipfailedtransfers="true" 
                remotedir="${sftpDirectory.web3d}" >
                <fileset refid="web3d.common.fileset"/>
                <fileset dir=".">
                    <include name="Basic/*"/>
                    <include name="Basic/**/*"/>
                    <!-- excluding these-->
                    <exclude name="X3dExamplesBasic.zip"/>
                    <exclude name="indexSavage.redirect.html"/>
                    <exclude name="indexSavageDefense.redirect.html"/>
                    <exclude name="indexX3dForWebAuthors.redirect.html"/>
                    <exclude name="**/archive/*"/>
                    <exclude name="**/_archive/*"/>
                    <exclude name="_schematron/*"/>
                    <exclude name="**/_schematron/*"/>
                    <exclude name="**/_hide/*"/>
                    <exclude name="**/hide/*"/>
                    <exclude name="**/CVS/*"/>
                    <exclude name="**/.svn/*"/>
                    <exclude name="**/_new*.*"/>
                    <exclude name="**/*.bak"/>
                    <exclude name="**/Thumbs.db"/>
                    <exclude name="nbproject/*"/>
                    <exclude name="**/nbproject/*"/>
                    <exclude name="CVS/"/>
                    <exclude name="*/CVS/"/>
                    <exclude name=".svn/"/>
                    <exclude name="**/.svn/"/>
                    <exclude name="**/*.$$$"/>
                    <exclude name="**/*.\$\$\$"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.Basic ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.Basic.zip" depends="sftp.askUsernamePassword.web3d"
        description="sftp upload of updated X3D Basic archive .zip">
        <echo  message="sftp upload to sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false" 
                skipfailedtransfers="false" 
                remotedir="${sftpDirectory.web3d}" >
                <fileset dir=".">
                    <include name="X3dExamplesBasic.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.Basic.zip ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.ConformanceNist" depends="sftp.uploadExampleUpdates.ConformanceNist.scenes,sftp.uploadExampleUpdates.ConformanceNist.zip"
        description="sftp upload of updated X3D archive files, including .zip">
    </target>

    <target name="sftp.uploadExampleUpdates.ConformanceNist.scenes" depends="sftp.askUsernamePassword.web3d"
        description="sftp upload of updated X3D archive files, excluding .zip">
        <echo  message="sftp upload to sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true" 
                skipfailedtransfers="true" 
                remotedir="${sftpDirectory.web3d}" >
                <fileset refid="web3d.common.fileset"/>
                <fileset dir=".">
                    <include name="ConformanceNist/*"/>
                    <include name="ConformanceNist/**/*"/>
                    <!-- excluding these-->
                    <exclude name="X3dExamplesConformanceNist.zip"/>
                    <exclude name="indexSavage.redirect.html"/>
                    <exclude name="indexSavageDefense.redirect.html"/>
                    <exclude name="indexX3dForWebAuthors.redirect.html"/>
                    <exclude name="**/archive/*"/>
                    <exclude name="**/_archive/*"/>
                    <exclude name="_schematron/*"/>
                    <exclude name="**/_schematron/*"/>
                    <exclude name="**/_hide/*"/>
                    <exclude name="**/hide/*"/>
                    <exclude name="**/CVS/*"/>
                    <exclude name="**/.svn/*"/>
                    <exclude name="**/_new*.*"/>
                    <exclude name="**/*.bak"/>
                    <exclude name="**/Thumbs.db"/>
                    <exclude name="nbproject/"/>
                    <exclude name="**/nbproject"/>
                    <exclude name=".svn/"/>
                    <exclude name="**/.svn"/>
                    <exclude name="**/*.$$$"/>
                    <exclude name="**/*.\$\$\$"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.ConformanceNist ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.ConformanceNist.zip" depends="sftp.askUsernamePassword.web3d"
        description="sftp upload of updated X3D ConformanceNist archive .zip">
        <echo  message="sftp upload to sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false" 
                skipfailedtransfers="false" 
                remotedir="${sftpDirectory.web3d}" >
                <fileset dir=".">
                    <include name="X3dExamplesConformanceNist.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.ConformanceNist.zip ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.Vrml2.0Sourcebook" depends="sftp.uploadExampleUpdates.Vrml2.0Sourcebook.scenes,sftp.uploadExampleUpdates.Vrml2.0Sourcebook.zip"
        description="sftp upload of updated X3D archive files, including .zip">
    </target>

    <target name="sftp.uploadExampleUpdates.Vrml2.0Sourcebook.scenes" depends="sftp.askUsernamePassword.web3d"
        description="sftp upload of updated X3D archive files, excluding .zip">
        <echo  message="sftp upload to sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="true" 
                skipfailedtransfers="true" 
                remotedir="${sftpDirectory.web3d}" >
                <fileset refid="web3d.common.fileset"/>
                <fileset dir=".">
                    <include name="Vrml2.0Sourcebook/*"/>
                    <include name="Vrml2.0Sourcebook/**/*"/>
                    <!-- excluding these-->
                    <exclude name="X3dExamplesVrml2.0Sourcebook.zip"/>
                    <exclude name="indexSavage.redirect.html"/>
                    <exclude name="indexSavageDefense.redirect.html"/>
                    <exclude name="indexX3dForWebAuthors.redirect.html"/>
                    <exclude name="**/archive/*"/>
                    <exclude name="**/_archive/*"/>
                    <exclude name="_schematron/*"/>
                    <exclude name="**/_schematron/*"/>
                    <exclude name="**/_hide/*"/>
                    <exclude name="**/hide/*"/>
                    <exclude name="**/CVS/*"/>
                    <exclude name="**/.svn/*"/>
                    <exclude name="**/_new*.*"/>
                    <exclude name="**/*.bak"/>
                    <exclude name="**/Thumbs.db"/>
                    <exclude name="nbproject/"/>
                    <exclude name="**/nbproject"/>
                    <exclude name=".svn/"/>
                    <exclude name="**/.svn"/>
                    <exclude name="**/*.$$$"/>
                    <exclude name="**/*.\$\$\$"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.Vrml2.0Sourcebook ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.Vrml2.0Sourcebook.zip" depends="sftp.askUsernamePassword.web3d"
        description="sftp upload of updated X3D Vrml2.0Sourcebook archive .zip">
        <echo  message="sftp upload to sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="put" verbose="true"
                newer="false" 
                skipfailedtransfers="false" 
                remotedir="${sftpDirectory.web3d}" >
                <fileset dir=".">
                    <include name="X3dExamplesVrml2.0Sourcebook.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.Vrml2.0Sourcebook.zip ssh-sftp task complete"/>
    </target>

    <target name="sftp.uploadExampleUpdates.X3dForWebAuthors" depends="sftp.uploadExampleUpdates.X3dForWebAuthors.scenes,sftp.uploadExampleUpdates.X3dForWebAuthors.zip"
        description="sftp upload of updated X3D archive files, including .zip">
    </target>

    <target name="sftp.uploadExampleUpdates.X3dForWebAuthors.scenes" depends="sftp.askUsernamePassword.X3dForWebAuthors"
        description="sftp upload of updated X3D archive files, including .zip">
        <echo  message="sftp upload to sftp://${sftpServer.X3dForWebAuthors}"/>
        <ssh host="${sftpServer.X3dForWebAuthors}"
            username="${username.X3dForWebAuthors}"
            password="${password.X3dForWebAuthors}">
            <sftp action="put" verbose="true"
                newer="true" 
                skipfailedtransfers="true" 
                remotedir="${sftpDirectory.X3dForWebAuthors}" >
                <fileset refid="web3d.common.fileset"/>
                <fileset dir=".">
                    <!-- future book directories will immediately follow the next include entries -->
                    <include name="X3dForWebAuthors/*"/>
                    <include name="X3dForWebAuthors/**/*"/>
                    <!-- excluding these-->
                    <exclude name="X3dExamplesX3dForWebAuthors.zip"/>
                    <exclude name="indexSavage.redirect.html"/>
                    <exclude name="indexSavageDefense.redirect.html"/>
                    <exclude name="**/archive/*"/>
                    <exclude name="**/_archive/*"/>
                    <exclude name="_schematron/*"/>
                    <exclude name="**/_schematron/*"/>
                    <exclude name="**/_hide/*"/>
                    <exclude name="**/hide/*"/>
                    <exclude name="**/CVS/*"/>
                    <exclude name="**/.svn/*"/>
                    <exclude name="**/_new*.*"/>
                    <exclude name="**/*.bak"/>
                    <exclude name="**/Thumbs.db"/>
                    <exclude name="nbproject/"/>
                    <exclude name="**/nbproject"/>
                    <exclude name=".svn/"/>
                    <exclude name="**/.svn"/>
                    <exclude name="**/*.$$$"/>
                    <exclude name="**/*.\$\$\$"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.X3dForWebAuthors ssh-sftp task complete"/>
    </target>
    
    <target name="sftp.uploadExampleUpdates.X3dForWebAuthors.zip" depends="sftp.askUsernamePassword.X3dForWebAuthors"
        description="sftp upload of updated X3dForWebAuthors.zip archive">
        <echo  message="sftp upload to sftp://${sftpServer.X3dForWebAuthors}"/>
        <ssh host="${sftpServer.X3dForWebAuthors}"
            username="${username.X3dForWebAuthors}"
            password="${password.X3dForWebAuthors}">
            <!-- top level:  latest copy of archive .zip -->
            <sftp action="put" verbose="true"
                newer="false" 
                skipfailedtransfers="false" 
                remotedir="${sftpDirectory.X3dForWebAuthors}/.." >
                <fileset dir=".">
                    <include name="X3dExamplesX3dForWebAuthors.zip"/>
                </fileset>
            </sftp>
        </ssh>
        <echo  message="sftp.uploadExampleUpdates.X3dForWebAuthors.zip ssh-sftp task complete"/>
    </target>
    
    <target name="sftp.clean.all" depends="sftp.clean.X3dForWebAuthors,sftp.clean.web3d,sftp.clean.savage,sftp.clean.savageDefense"
        description="sftp clean of unwanted backup files in all X3D archives">
    </target>
    
    <fileset dir="." id="backupFiles">
    <!--<include name="**/*Canonical.x3d"/> removed this line once clean -->
        <include name="**/_new_pretty_print.html"/>
        <include name="**/_new_result.wrl"/>
        <include name="**/_new_result.x3d"/>
        <include name="**/_new_result.x3dv"/>
        <include name="**/_new_result.x3db"/>
        <include name="**/_new_resultCanonical.xml"/>
        <include name="**/Thumb.db"/>
        <include name="**/*.bak"/>
        <include name="**/hs_err_pid*.log"/>
        <include name="**/manifest.mf"/>
        <include name="**/*.$$$$$$"/> <!-- escaped .$$$ -->
        <include name="**/archive"/>
        <include name="**/_archive"/>
        <include name="**/_schematron"/>
        <include name="**/hide"/>
        <include name="**/_hide"/>
        <include name="Untitled-?.x3d"/>
        <include name="**/Untitled-?.x3d"/>
        <include name="nbproject"/>
        <include name="**/nbproject"/>
        <include name="CVS"/>
        <include name="**/CVS"/>
        <include name=".svn"/>
        <include name="**/.svn"/>
        <include name="**/*Canonical.x3d"/>
        <include name="**/*Canonical.x3db"/>
        <include name="**/*Canonical.x3dv"/>
        <include name="**/*Canonical.wrl"/>
        <include name="**/*Canonical.html"/>
    </fileset>
    
    <target name="sftp.clean.savage" depends="sftp.askUsernamePassword.savage"
        description="sftp clean of unwanted backup files in X3D archive">
        <echo  message="sftp clean of sftp://${sftpServer.savage}"/>
        <ssh host="${sftpServer.savage}"
            username="${username.savage}"
            password="${password.savage}">
            <!-- top level -->
            <sftp action="delete" verbose="true"
                remotedir="${sftpDirectory.savage}" >
                <fileset refid="backupFiles"/>
            </sftp>
        </ssh>
        <echo  message="sftp.clean.savage ssh-sftp task complete"/>
    </target>
    
    <target name="sftp.clean.savageDefense" depends="sftp.askUsernamePassword.savageDefense"
        description="sftp clean of unwanted backup files in X3D archive">
        <echo  message="sftp clean of sftp://${sftpServer.savageDefense}"/>
        <ssh host="${sftpServer.savageDefense}"
            username="${username.savageDefense}"
            password="${password.savageDefense}">
            <!-- top level -->
            <sftp action="delete" verbose="true"
                remotedir="${sftpDirectory.savageDefense}" >
                <fileset refid="backupFiles"/>
            </sftp>
        </ssh>
        <echo  message="sftp.clean.savageDefense ssh-sftp task complete"/>
    </target>
    
    <target name="sftp.clean.web3d" depends="sftp.askUsernamePassword.web3d"
        description="sftp clean of unwanted backup files in X3D archive">
        <echo  message="sftp clean of sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.web3d}"
            username="${username.web3d}"
            password="${password.web3d}">
            <!-- top level -->
            <sftp action="delete" verbose="true"
                remotedir="${sftpDirectory.web3d}" >
                <fileset refid="backupFiles"/>
            </sftp>
        </ssh>
        <echo  message="sftp.clean.web3d ssh-sftp task complete"/>
    </target>
    
    <target name="sftp.clean.X3dForWebAuthors" depends="sftp.askUsernamePassword.X3dForWebAuthors"
        description="sftp clean of unwanted backup files in X3D archive">
        <echo  message="sftp clean of sftp://${sftpServer.web3d}"/>
        <ssh host="${sftpServer.X3dForWebAuthors}"
            username="${username.X3dForWebAuthors}"
            password="${password.X3dForWebAuthors}">
            <!-- top level -->
            <sftp action="delete" verbose="true"
                remotedir="${sftpDirectory.X3dForWebAuthors}" >
                <fileset refid="backupFiles"/>
            </sftp>
        </ssh>
        <echo  message="sftp.clean.web3d ssh-sftp task complete"/>
    </target>

    <target name="hiddenArchiveDirectoryRename" depends="" description="ensure proper naming of hidden directories" >
        <move file="*/*/*/archive/*" todir="**/_archive" overwrite="true" failonerror="false" verbose="true"/>
    </target>
    
    <target name="convertCmlScenes" depends="" description="convert XML-based molecule descriptions (in Basic examplese archive) from CML to X3D" >
        <delete>
            <fileset dir="Basic/ChemistryMarkupLanguage" includes="*.x3d"/>
            <fileset dir="Basic/ChemistryMarkupLanguage" includes="*Canonical.xml"/>
        </delete>
        <xmlvalidate file="Basic/ChemistryMarkupLanguage/CmlToX3d.xslt" failonerror="true" warn="true" lenient="yes"/>
        <!-- TODO:  validation of .xml CML -->
        <xmlvalidate failonerror="false" warn="true" lenient="yes">
            <fileset dir="Basic/ChemistryMarkupLanguage">
                <include name="*.xml"/>
            </fileset>
        </xmlvalidate>
        <!-- filenames beginning with numeric characters were modified and given _ underscore prefix to permit validation of autogenerated IDs -->
        <xslt destdir="." style="Basic/ChemistryMarkupLanguage/CmlToX3d.xslt" force="true">
            <include name="Basic/ChemistryMarkupLanguage/*.xml"/>
            <mapper type="glob" from="*.xml" to="*.x3d"/>
            <xmlcatalog refid="X3dCatalog"/>
        </xslt>
        <xmlvalidate failonerror="false" warn="true" lenient="yes">
            <fileset dir="Basic/ChemistryMarkupLanguage">
                <include name="*.x3d"/>
            </fileset>
            <xmlcatalog refid="X3dCatalog"/>
        </xmlvalidate>
    </target>

    <target name="validate.all" depends="" description="XML validation checks" >
        <!-- not clear whether this uses schema or DTD.  likely DTD. -->
        <xmlvalidate failonerror="false" warn="true">
            <fileset dir=".">
                <include name="*.xml"/>
                <!-- <include name="*.xsd"/> -->
                <exclude name="build*.xml"/>
            </fileset>
        </xmlvalidate>
        <xmlvalidate file="build.xml"                 failonerror="false" warn="true" lenient="yes"/>
        <xmlvalidate file="buildExamplesTemplate.xml" failonerror="false" warn="true" lenient="yes"/>
        <ant dir="Basic"              target="validate"/>
        <ant dir="ConformanceNist"    target="validate"/>
        <ant dir="Vrml2.0Sourcebook"  target="validate"/>
        <ant dir="Savage"             target="validate"/>
        <ant dir="SavageDefense"      target="validate"/>
        <ant dir="X3dForWebAuthors"   target="validate"/>
    </target>
    
    <target name="renameCanonicalScenes.all" depends="" description="renameCanonicalScenes for each of the example archives" >
        <ant dir="Basic"              target="renameCanonicalScenes"/>
        <ant dir="ConformanceNist"    target="renameCanonicalScenes"/>
        <ant dir="Vrml2.0Sourcebook"  target="renameCanonicalScenes"/>
        <ant dir="Savage"             target="renameCanonicalScenes"/>
        <ant dir="SavageDefense"      target="renameCanonicalScenes"/>
        <ant dir="X3dForWebAuthors"   target="renameCanonicalScenes"/>
    </target>

    <target name="zip.all" depends="" description="zip each of the example archives" >
        <ant dir="Basic"              target="zip"/>
        <ant dir="ConformanceNist"    target="zip"/>
        <ant dir="Vrml2.0Sourcebook"  target="zip"/>
        <ant dir="Savage"             target="zip"/>
        <ant dir="SavageDefense"      target="zip"/>
        <ant dir="X3dForWebAuthors"   target="zip"/>
    </target>
    
    <target name="HelloWorldCopyToArchives" description="Copy HelloWorld.x3d example from common example-archives parent to 2 archives for documentation" >
        <copy todir="Basic/development" preservelastmodified="false" verbose="true">
            <fileset dir="." includes="HelloWorld.x3d"/>
            <fileset dir="." includes="earth-topo*.*"/>
            <fileset dir="." includes="HelloWorld.Tall.png"/>
        </copy>
        <copy todir="X3dForWebAuthors/Chapter01-TechnicalOverview" preservelastmodified="false" verbose="true">
            <fileset dir="." includes="HelloWorld.x3d"/>
            <fileset dir="." includes="earth-topo*.*"/>
            <fileset dir="." includes="HelloWorld.Tall.png"/>
        </copy>
    </target>
    
</project>