<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 1995-2011 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.
-->

<!-- buildExamplesTemplate.xml is used to produce customized build.xml for each autogenerated X3D example archive build.xml -->

<project name="X3D examples: _archiveName_" default="all" basedir=".">
    <description>Builds and tests the X3D Examples _archiveName_ archive using Ant</description>

    <!-- properties common to all build files, customized for this archive ============================== -->

    <property name="archive.name"                  value="_archiveName_"/>
    <property name="archive.path"                  location="."/>

    <!-- Basic archive has single-section catalog structure, others have 2-section catalog structure  -->
    <property name="numberOfSections"             location="_numberOfSections_"/>
    <property name="subdir"                       location="_subdir_"/>

    <fileset id="x3dScenes" dir="." includes="_x3dScenes_" excludes="_archive/*.*,**/_archive/*.*,_schematron/*.*,**/_schematron/*.*,hide/*.*,**/hide/*.*,InstallingCortonaBrowserAsPowerpointControl_files/*.*,**/build.xml,nbproject/**/*.xml,configuration/**/*.*,**/*Canonical.xml,**/*.nrrd"/>
    <fileset id="xmlFiles"  dir="." includes="_xmlFiles_"  excludes="_archive/*.*,**/_archive/*.*,_schematron/*.*,**/_schematron/*.*,hide/*.*,**/hide/*.*,InstallingCortonaBrowserAsPowerpointControl_files/*.*,**/build.xml,nbproject/**/*.xml,configuration/**/*.*,**/*Canonical.xml,**/*.nrrd"/>

    <!-- properties common to all build files and archives ======================================== -->

    <property environment="env"/>

    <!-- compiled stylesheets are a Saxon feature, false means regular .xslt -->
    <property name="compiled"            value="false"/>
    <!-- http://www.saxonica.com/documentation9.1/using-xsl/compiling.html   -->

    <!-- java jvmarg parameters ignored on server unless forked -->
    <!-- Xj3D converter tends to lock up Netbeans unless forked -->
    <property name="fork"                value="true"/>

    <!-- ignoreSetupDownloadErrors can be overridden by Jenkins configuration, ensure initialized by previous invocations -->
    <property name="ignoreSetupDownloadErrors" value="true"/>

    <!-- note that Netbeans default path is built in and has to be overridden by going to     -->
    <!-- Netbeans > Tools > Options > Miscellaneous > Ant                                     -->
    <!-- and then pointing to C:\apache-ant-1.8.2 (or somesuch locally installed directory)   -->

    <!-- ANT Contrib archive at http://sourceforge.net/projects/ant-contrib/files             -->
    <!-- must have ant-contrib-1.03b.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"/>
    <property name="saxon.jar"           value="saxon9.jar"/>
    <property name="saxononicaSA.dir" location="C:/java/saxonsa9-1-0-6j"/>

    <property name="c14n.dir"            value="../../../tools/canonical/dist/lib"/>
    <property name="c14n.jar"            value="X3dC14n.jar"/>
    <property name="log4j.dir"           value="../../../tools/canonical/lib"/>
    <property name="log4j.jar"           value="log4j-1.2.15.jar"/>

    <property name="stylesheet.dir"      value="../../../stylesheets"/>
    
    <!-- ======================================== -->
    <!-- OS-specific paths for Xj3D, adapted from from NPS-branch build_nps.xml and build.properties -->
    
    <target name="platformInitialize" depends="platformType,initializeWindows,initializeUnix,initializeMac"/>
    <target name="platformType">
        <condition property="isWindows">
            <os family="windows"/>
        </condition>
        <condition property="isMac">
            <os family="mac"/>
        </condition>
        <!-- Based on Apache Ant user-manual example -->
        <condition property="isUnixNotMac">
            <and>
                <os family="unix"/>

                <not>
                    <equals arg1="${os.name}" arg2="Mac OS X"/>
                </not>

            </and>
        </condition>
    </target>
<!--
# ******************************************************************************
# NOTE: The convention here for determining OS architecture assumes Intel (x86) 
# CPUs only.  For non-traditional: amd64, sparc, i386, etc., this convention 
# will not work requiring a manual rename for the path to the native binaries.

# http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#64bit_detection
-->    
    <property name="os.architecture.bitness"  value="x86_${sun.arch.data.model}"/>
    <property name="natives.dir"              value="natives"/>
    <property name="mac.library.path"         value="${natives.dir}"/>
    <property name="win.library.path"         value="${natives.dir}/${os.architecture.bitness}/win"/>
    <property name="linux.library.path"       value="${natives.dir}/${os.architecture.bitness}/linux"/>
    
    <target name="initializeMac" if="isMac" depends="platformType">
        <property name="native.library.path" value="${mac.library.path}"/>
    </target>
    <target name="initializeWindows" if="isWindows" depends="platformType">
        <property name="native.library.path" value="${win.library.path}"/>
    </target>
    <target name="initializeUnix" if="isUnixNotMac" depends="platformType">
        <property name="native.library.path" value="${linux.library.path}"/>
    </target>
    <!-- ======================================== -->

    <!-- all Xj3D.nps jars need to be in same directory for fileset to work properly. -->
    <!-- Prerequisite:  run build_nps.xml 'dist' task to get the .jars built and in the right place -->
    <!-- TODO in order for server-side jenkins to also work, they are retrieved to same directory -->
    <property name="xj3d.dir"            value="C:/Xj3D.nps/jars"/>             <!-- C:/Xj3D.nps/jars -->
    <property name="xj3d.3rdparty.jar"   value="xj3d-2.0-3rdparty-nps.jar"/>    <!-- C:/Xj3D.nps/jars -->
    <property name="xj3d.jar"            value="xj3d-2.0-nps.jar"/>             <!-- C:/Xj3D.nps/jars -->
    <property name="xj3d.browser.jar"    value="xj3d.browser_2.0.0-nps.jar"/>   <!-- C:/Xj3D.nps/apps/browser/jars -->
    <property name="xj3d.cadfilter.jar"  value="xj3d.cadfilter_2.0.0-nps.jar"/> <!-- C:/Xj3D.nps/apps/cadfilter/jars -->
    <!-- see HelloWorld task for path diagnostic messages -->
    <fileset dir="${xj3d.dir}" id="xj3d.jars.all">
        <include name="${xj3d.jar}"/>
        <include name="${xj3d.browser.jar}"/>
        <include name="${xj3d.cadfilter.jar}"/>
        <include name="${xj3d.3rdparty.jar}"/>
    </fileset>
    <!-- site to download latest xj3d jars -->
    <property name="xj3d.jar.site"        value="https://savage.nps.edu/Xj3D.nps/jars"/>
    <!-- prior download location:                http://xmsf.svn.sourceforge.net/svnroot/xmsf/trunk/AuvWorkbench/lib/xj3d/ -->

    <!-- subversion checkout address to download latest x3d configuration files (https prefix works in browser but fails in Ant) -->
    <property name="x3d.sourceforge.site" value="http://x3d.svn.sourceforge.net/svnroot/x3d/www.web3d.org"/>
    <!-- subversion viewvc   address to download latest x3d configuration files, disabled by Sourceforge January 2011
    <property name="x3d.sourceforge.site" value="http://x3d.svn.sourceforge.net/viewvc/x3d/www.web3d.org"/>
    -->

    <property name="X3dSchematronValidityChecks.dir" location="../../../tools/schematron"/>
    <property name="X3dSchematronValidityChecks"        value="X3dSchematronValidityChecks"/>
    <property name="SvrlReportText"                     value="SvrlReportText"/>

    <property name="CreateContentCatalog.dir" location="../../../tools/CreateContentCatalog"/>
    <property name="X3dDtdsSchemas.dir"       location="../../../../specifications"/>
    <property name="resolver.dir"             location="${env.ANT_HOME}/lib"/>
    <length property="resolver.jar.length" file="${resolver.dir}/resolver.jar"/>

<!--
OASIS XML Catalog standard references
         http://www.oasis-open.org/specs/index.php#xmlcatalogs
         http://www.oasis-open.org/committees/download.php/14810/xml-catalogs.pdf
Apache Ant validation and resolver references
         http://ant.apache.org/manual/Types/xmlcatalog.html
         http://ant.apache.org/manual/Tasks/xmlvalidate.html
         http://ant.apache.org/manual/Tasks/schemavalidate.html
         http://ant.apache.org/manual/install.html#librarydependencies
         http://xml.apache.org/commons/components/resolver
         http://www.saxproject.org/apidoc/org/xml/sax/package-summary.html#package_description
         http://xerces.apache.org/xerces-j/features.html
         http://xerces.apache.org/xerces-j/properties.html
-->
    <xmlcatalog id="X3dCatalog">
        <dtd    publicId="ISO//Web3D//DTD X3D 3.0//EN"                                  location="${X3dDtdsSchemas.dir}/x3d-3.0.dtd"/>
        <dtd    publicId="ISO//Web3D//DTD X3D 3.1//EN"                                  location="${X3dDtdsSchemas.dir}/x3d-3.1.dtd"/>
        <dtd    publicId="ISO//Web3D//DTD X3D 3.2//EN"                                  location="${X3dDtdsSchemas.dir}/x3d-3.2.dtd"/>
        <dtd    publicId="ISO//Web3D//DTD X3D 3.3//EN"                                  location="${X3dDtdsSchemas.dir}/x3d-3.3.dtd"/>
        <dtd    publicId="http://www.web3d.org/specifications/x3d-3.0.dtd"              location="${X3dDtdsSchemas.dir}/x3d-3.0.dtd"/>
        <dtd    publicId="http://www.web3d.org/specifications/x3d-3.1.dtd"              location="${X3dDtdsSchemas.dir}/x3d-3.1.dtd"/>
        <dtd    publicId="http://www.web3d.org/specifications/x3d-3.2.dtd"              location="${X3dDtdsSchemas.dir}/x3d-3.2.dtd"/>
        <dtd    publicId="http://www.web3d.org/specifications/x3d-3.3.dtd"              location="${X3dDtdsSchemas.dir}/x3d-3.3.dtd"/>
        <entity publicId="http://www.web3d.org/specifications/x3d-3.0.xsd"              location="${X3dDtdsSchemas.dir}/x3d-3.0.xsd"/>
        <entity publicId="http://www.web3d.org/specifications/x3d-3.1.xsd"              location="${X3dDtdsSchemas.dir}/x3d-3.1.xsd"/>
        <entity publicId="http://www.web3d.org/specifications/x3d-3.2.xsd"              location="${X3dDtdsSchemas.dir}/x3d-3.2.xsd"/>
        <entity publicId="http://www.web3d.org/specifications/x3d-3.3.xsd"              location="${X3dDtdsSchemas.dir}/x3d-3.3.xsd"/>
        <!-- Transitional DTD, versions 3.0 and 3.1 only -->
        <dtd    publicId="file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.0.dtd" location="${X3dDtdsSchemas.dir}/x3d-3.0.dtd"/>
        <dtd    publicId="file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.1.dtd" location="${X3dDtdsSchemas.dir}/x3d-3.1.dtd"/>
        <!-- fallback solution, depends on resolver.jar availability -->
        <xmlcatalog>
            <catalogpath location="${X3dDtdsSchemas.dir}/OasisXmlCatalogX3D.xml" description="external path to same definitions"/>
        </xmlcatalog>
    </xmlcatalog>

    <!-- Ant macro definitions common to all build files, customized for this archive ============================== -->

    <!-- excerpted/adapted from "SAXON XSLT Processing with Ant" by James Fuller, http://ablog.apress.com/?p=753 -->
    <!-- http://www.saxonica.com/documentation/using-xsl/commandline.xml                                         -->
    <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"/>
        <!-- parameterPair1 must have a legal value or saxon fails mysteriously while running under jenkins! java.lang.StringIndexOutOfBoundsException: String index out of range: 0 -->
        <attribute name="parameterPair1" default="-dtd:off"/>
        <sequential>
            <!-- <echo message="Saxon9 processing @{scene}.@{extension} using @{stylesheet}, compiled=@{compiled}, parameterPair1=@{parameterPair1}"/> -->
            <if>
                <equals arg1="@{compiled}" arg2="true" />
                <then>
                    <java classname="net.sf.saxon.Transform" 
                          classpath="${basedir};${saxon.dir}/${saxon.jar};${resolver.dir}/resolver.jar"
                          fork="${fork}"
                          failonerror="false">
                        <!-- TODO
                        <jvmarg value="-Dxml.catalog.files=C:/www.web3d.org/specifications/OasisXmlCatalogX3D.xml"/>
                        <jvmarg value="-Dxml.catalog.verbosity=4"/>
                        use the Apache commons resolver for XML Catalog resolution of online DTD, schema addresses
                        http://sourceforge.net/apps/mediawiki/saxon/index.php?title=XML_Catalogs
                        "How to use a catalog file:  Using catalogs with Saxon"
                        http://www.sagehill.net/docbookxsl/UseCatalog.html
                        download resolver.jar from http://xml.apache.org/commons/dist and install into classpath above,
                        must also have CatalogManager.properties in CLASSPATH
                        <arg value="-r:org.apache.xml.resolver.tools.CatalogResolver"/>
                        <arg value="-x:org.apache.xml.resolver.tools.ResolvingXMLReader"/>
                        <arg value="-y:org.apache.xml.resolver.tools.ResolvingXMLReader"/>
                        <arg value="-u"/> -->  <!-- source file name is resolved to a JAXP Source object -->
                        <!-- <arg value="-t"/> timing information -->
                        <!-- <arg value="-T"/> trace (voluminous) -->
                        <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
                        <arg value="-s:@{scene}.x3d"/>
                        <arg value="-o:@{scene}.@{extension}"/>
                        <arg value="-c:@{stylesheet}.sxx"/>  <!-- compiled stylesheet -->
                        <arg value="@{parameterPair1}"/>
                    </java>
                </then>
                <else> <!-- not compiled -->
                    <java classname="net.sf.saxon.Transform"
                          classpath="${basedir};${saxon.dir}/${saxon.jar};${resolver.dir}/resolver.jar"
                          fork="${fork}"
                          failonerror="false">
                        <!-- TODO
                        <jvmarg value="-Dxml.catalog.files=C:/www.web3d.org/specifications/OasisXmlCatalogX3D.xml"/>
                        <jvmarg value="-Dxml.catalog.verbosity=4"/>
                        use the Apache commons resolver for XML Catalog resolution of online DTD, schema addresses
                        http://sourceforge.net/apps/mediawiki/saxon/index.php?title=XML_Catalogs
                        "How to use a catalog file:  Using catalogs with Saxon"
                        http://www.sagehill.net/docbookxsl/UseCatalog.html
                        download resolver.jar from http://xml.apache.org/commons/dist and install into classpath above,
                        must also have CatalogManager.properties in CLASSPATH
                        <arg value="-r:org.apache.xml.resolver.tools.CatalogResolver"/>
                        <arg value="-x:org.apache.xml.resolver.tools.ResolvingXMLReader"/>
                        <arg value="-y:org.apache.xml.resolver.tools.ResolvingXMLReader"/> -->
                        <!-- <arg value="-t"/> timing information -->
                        <!-- <arg value="-T"/> trace (voluminous) -->
                        <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
                        <arg value="-s:@{scene}.x3d"/>
                        <arg value="-o:@{scene}.@{extension}"/>
                        <arg value="-xsl:@{stylesheet}.xslt"/>  <!-- regular stylesheet -->
                        <arg value="@{parameterPair1}"/>
                    </java>
                </else>
            </if>
        </sequential>
    </macrodef>

    <macrodef name="canonicalX3D" description="convert scene.x3d to sceneCanonical.xml">
        <attribute name="scene"/>
        <sequential>
            <java classname="org.web3d.x3d.tools.x3db.X3dCanonicalizer"
                  classpath="${c14n.dir}/${c14n.jar}"
                       fork="${fork}"
                failonerror="false">
                <arg value="@{scene}.x3d"/>
                <arg value="@{scene}Canonical.xml"/>
            </java>
            <echo message="check well-formedness of canonical form"/>
            <xmlvalidate file="@{scene}Canonical.xml" failonerror="false" warn="true" lenient="yes"/>
            <echo message="check DTD validation  of canonical form"/>
            <xmlvalidate file="@{scene}Canonical.xml" failonerror="false" warn="true">
                <!-- TODO get xmlcatalog working under jenkins
                <attribute name="http://xml.org/sax/features/validation" value="true"/>
                <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
                <xmlcatalog refid="X3dCatalog"/>
                -->
            </xmlvalidate>
            <!-- save prior version to _archive/ subdirectory, then copy canonicalized version as current version -->
            <copy file="@{scene}.x3d"           todir="_archive/"    overwrite="true" failonerror="true" verbose="true" preservelastmodified="true"/>
            <copy file="@{scene}Canonical.xml" tofile="@{scene}.x3d" overwrite="true" failonerror="true" verbose="true" preservelastmodified="true"/>
        </sequential>
    </macrodef>

    <!-- target tasks common to all build files ===================================================================== -->

    <!-- TODO validate.all, -->
    <target name="all" depends="check.ant.version,clean.backups,commonSetup,build,upload" description="clean backups, build, zip and upload this X3D archive">
        <echo message="Copying latest build.out.txt to subdirectory ${archive.name}/_archive/"/>
        <copy file="build.out.txt" todir="_archive/" overwrite="true" failonerror="false"/>
    </target>

    <target name="all.record" description="build all for this X3D archive, record output to file">
        <tstamp>
            <format property="dateStamp" pattern="yyyyMMMMdd"/>
        </tstamp><property name="build.out.filename" value="build.out.${archive.name}.${timestamp.DSTAMP}.txt"/>
        <delete file="${build.out.filename}"/>
        <echo message="logfile ${build.out.filename}"/>
        <echo message="logfile ${build.out.filename}" file="${build.out.filename}"/>
        <echo message=""       append="true"          file="${build.out.filename}"/>
        <record action="start" append="true"          name="${build.out.filename}"/>
        <antcall target="all"/>
        <record name="build.out.${archive.name}.${timestamp.DSTAMP}.txt" action="stop"/>
    </target>

    <target name="build.record" description="build this X3D archive, record output to file">
        <tstamp>
            <format property="dateStamp" pattern="yyyyMMMMdd"/>
        </tstamp>
        <property name="build.out.filename" value="build.out.${archive.name}.${timestamp.DSTAMP}.txt"/>
        <delete file="${build.out.filename}"/>
        <echo message="logfile ${build.out.filename}"/>
        <echo message="logfile ${build.out.filename}" file="${build.out.filename}"/>
        <echo message=""       append="true"          file="${build.out.filename}"/>
        <record action="start" append="true"          name="${build.out.filename}"/>
        <antcall target="build"/>
        <record name="build.out.${archive.name}.${timestamp.DSTAMP}.txt" action="stop"/>
    </target>

    <target name="build" depends="check.ant.version,get.slideshowTools,commonSetup,validate.all,processScenes,catalog,zip" description="build this X3D archive">
    </target>

    <target name="check.ant.version" description="Check for Apache Ant version">
       <echo message="${ant.version}"/>
       <fail message="Build tested with Apache Ant version 1.7 or 1.8">
           <condition>
               <and>
                   <not>
                       <contains string="${ant.version}" substring="1.7"/>
                   </not>
                   <not>
                       <contains string="${ant.version}" substring="1.8"/>
                   </not>
               </and>
           </condition>
       </fail>
    </target>

    <target name="clean.all" depends="clean.backups,clean.duplicates,clean.Canonical.xml,clean.html,clean.schematron,clean.SVG,clean.wrl,clean.x3dv,clean.x3db" description="clean out autogenerated files (only)">
        <echo message="clean/delete autogenerated ${archive.name} catalog pages and files matching *.x3d scenes: *.html *.wrl *.x3db *.x3dv *Canonical.xml"/>
        <!-- delete autogenerated directories, but not _archive directory -->
        <delete dir="_pages"      quiet="true" includeemptydirs="true"/>
        <delete dir="_svg"        quiet="true" includeemptydirs="true"/>
        <delete dir="_schematron" quiet="true" includeemptydirs="true"/>
        <delete verbose="true">
            <fileset dir="." includes="build.out.txt"/>
            <fileset dir="." includes="ContentCatalog*.*"/>
            <fileset dir="." includes="newScene.*"/>
            <fileset dir="." includes="newHtmlPageWithX3dObject.html"/>
            <fileset dir="." includes="newECMAscript.js"/>
            <fileset dir="." includes="newX3dScript.java"/>
            <fileset dir="." includes="HelloWorld.*"/>
            <fileset dir="." includes="earth-topo*.*"/>
            <fileset dir="." includes="*.html" excludes="license.html"/>
            <fileset dir="." includes="*.wrl"/>
            <fileset dir="." includes="*.x3db"/>
            <fileset dir="." includes="*.x3dv"/>
            <fileset dir="." includes="*Canonical.xml"/>
            <fileset dir="." includes="Thumbs.db"/>
            <fileset dir="." includes="*.bak"/>
            <fileset dir="." includes="**/*.$$$$$$"/> <!-- escape $ as $$ -->
        </delete>
        <!-- clean jenkins subdirectories -->
        <delete dir="lib"         quiet="false" includeemptydirs="true"/>
        <delete dir="stylesheets" quiet="false" includeemptydirs="true"/>
    </target>

    <target name="clean.archiveSubdirectories" description="clean out duplicates in _archive subdirectories">
        <echo message="clean/delete backup files for project ${archive.name}"/>
        <delete verbose="true">
            <fileset dir="." includes="**/_archive/*.*"/>
        </delete>
    </target>
    
    <target name="clean.catalog.pages" description="clean out catalog-produced files (only)">
        <echo message="clean/delete autogenerated catalog files"/>
        <delete verbose="true">
                <fileset dir="." includes="**/_pages/*.html"/>
                <fileset dir="." includes="**/viewpointSlideshow.html"/>
        </delete>
        <!-- TODO how to remove directories correctly? -->
        <delete dir="**/_pages" verbose="true"/>
        <delete dir="**/_svg"   verbose="true"/>
    </target>
    
    <target name="clean.media" description="clean out large files (warning, this included necessary files for scene operation)">
        <echo message="clean/delete sound, image and movie files"/>
        <delete verbose="true">
                <fileset dir="." includes="**/*.wav"/>
                <fileset dir="." includes="**/*.gif"/>
                <fileset dir="." includes="**/*.jpg"/>
                <fileset dir="." includes="**/*.mpg"/>
                <fileset dir="." includes="**/*.mov"/>
                <fileset dir="." includes="**/*.ppt"/>
        </delete>
    </target>

    <target name="clean.backups" description="clean out unnecessary backup files (only)">
        <echo message="clean/delete backup files for project ${archive.name}"/>
        <delete verbose="true">
            <fileset dir="." includes="**/_new_pretty_print.html"/>
            <fileset dir="." includes="**/_new_result.wrl"/>
            <fileset dir="." includes="**/_new_result.x3db"/>
            <fileset dir="." includes="**/_new_result.x3dv"/>
            <fileset dir="." includes="**/Thumbs.db"/>
            <fileset dir="." includes="**/*.bak"/>
            <fileset dir="." includes="**/hs_err_pid*.log"/>
            <fileset dir="." includes="**/manifest.mf"/>
            <fileset dir="." includes="**/*.$$$$$$"/> <!-- escape $ as $$ -->
            <fileset dir="." includes="**/*Canonical.x3d"/>
            <fileset dir="." includes="**/*Canonical.x3db"/>
            <fileset dir="." includes="**/*Canonical.x3dv"/>
            <fileset dir="." includes="**/*Canonical.wrl"/>
            <fileset dir="." includes="**/*Canonical.html"/>
        </delete>
    </target>

    <!-- warning!  do not create .x3d file names that end in five or more numeric digits since X3D-Edit uses that as a temporary backup filename -->
    <target name="clean.duplicates" description="clean out duplicate files autogenerated by X3D-Edit, ending with 5 or more numeric values">
        <echo message="clean/delete duplicate files autogenerated by X3D-Edit ending with 5 or more numeric values (*#####.x3d)"/>
        <echo message="  including files matching *#####.x3d scenes: *.html *.wrl *.x3db *.x3dv *Canonical.xml"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="filename.prefix.duplicate"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*[0-9][0-9][0-9][0-9][0-9])(\.x3d|\.x3dv|\.x3db|\.wrl|\.html|Canonical\.xml)"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <if>
                    <equals arg1="${filename.prefix.duplicate}" arg2="" />
                    <then>
                        <!-- not a duplicate, ignore-->
                    </then>
                    <else>
                    <!--<echo>delete ${relative.path1}/${relative.path2}/${name.short}.html</echo> -->
                        <delete file="${relative.path1}/${relative.path2}/${filename.prefix.duplicate}.x3d"/>
                        <delete file="${relative.path1}/${relative.path2}/${filename.prefix.duplicate}.html"/>
                        <delete file="${relative.path1}/${relative.path2}/${filename.prefix.duplicate}.wrl"/>
                        <delete file="${relative.path1}/${relative.path2}/${filename.prefix.duplicate}.x3db"/>
                        <delete file="${relative.path1}/${relative.path2}/${filename.prefix.duplicate}.x3dv"/>
                        <delete file="${relative.path1}/${relative.path2}/${filename.prefix.duplicate}Canonical.xml"/>
                    </else>
                </if>
            </sequential>
        </for>
    </target>

    <target name="clean.html" description="clean out autogenerated *.html files (only)">
        <echo message="clean/delete autogenerated pretty-print files matching *.x3d scenes: *.html "/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
            <!-- <echo>delete ${relative.path1}/${relative.path2}/${name.short}.html</echo> -->
                <delete file="${relative.path1}/${relative.path2}/${name.short}.html"/>
            </sequential>
        </for>
        <echo message="consider clean.SVG if crossSection figures also need removal"/>
    </target>

    <target name="clean.wrl" description="clean out autogenerated *.wrl files (only)">
        <echo message="clean/delete autogenerated files matching *.x3d scenes: *.wrl"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
            <!-- <echo>delete ${relative.path1}/${relative.path2}/${name.short}.wrl</echo> -->
                <delete file="${relative.path1}/${relative.path2}/${name.short}.wrl"/>
            </sequential>
        </for>
    </target>

    <target name="clean.x3db" description="clean out autogenerated *.x3db files">
        <echo message="clean/delete autogenerated files matching *.x3d scenes: *.x3db"/>
        <delete verbose="true">
            <fileset dir="." includes="**/*.x3db"/>
        </delete>
    </target>

    <target name="clean.x3dv" description="clean out autogenerated *.x3dv files (only)">
        <echo message="clean/delete autogenerated files matching *.x3d scenes: *.x3dv"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
            <!-- <echo>delete ${relative.path1}/${relative.path2}/${name.short}.x3dv</echo> -->
                <delete file="${relative.path1}/${relative.path2}/${name.short}.x3dv"/>
            </sequential>
        </for>
    </target>

    <target name="clean.Canonical.xml" description="clean out autogenerated *Canonical.xml files (only)">
        <echo message="clean/delete autogenerated *Canonical.xml files"/>
        <delete verbose="true">
            <fileset dir="." includes="**/*Canonical.xml"/>
        </delete>
    </target>

    <target name="clean.SVG" description="clean out autogenerated *.svg files (only)">
        <!-- SVG crossSection images are generated along with html pretty-print pages for each scene -->
        <echo message="clean/delete autogenerated files matching *.x3d scenes: _svg/*.svg"/>
        <delete verbose="true">
            <fileset dir="." includes="**/_svg/*.svg"/>
        </delete>
    </target>

    <target name="clean.schematron" description="clean out autogenerated schematron validation files (only)">
        <echo message="clean/delete autogenerated files matching *.x3d scenes: _schematron/*"/>
        <delete verbose="true">
            <fileset dir=".">
                <include name="_schematron/*"/>
                <include name="*/_schematron/*"/>
                <include name="*/*/_schematron/*"/>
            </fileset>
        </delete>
    </target>

    <target name="clean.slideshowTools" description="clean out downloaded slideshow tools">
        <echo message="clean out downloaded slideshow tools"/>
        <delete verbose="true" dir="slideshow"/>
    </target>

    <target name="clean.viewpointImages" description="clean out autogenerated viewpoint image files (only)">
        <echo message="clean/delete autogenerated viewpoint image files"/>
        <delete verbose="true">
            <fileset dir=".">
                <include name="*/_viewpoints/*.png"/>
                <include name="*/*/_viewpoints/*.png"/>
            </fileset>
        </delete>
     </target>

    <target name="jenkins" depends="jenkins.prepare,build" description="jenkins tasks">
        <!-- optional dependency:  clean.jenkins -->
        <!-- TODO build,HelloWorld,newScene - fix XML catalog, needs server-side configuration -->
        <delete dir="_archive" failonerror="false" verbose="false"/>
        <antcall target="jenkins.deploy.nightly"/>
        <echo message="jenkins ${archive.name} examples build complete"/>

<!-- Jenkins description (adjusted for each build):
<p>
Create a local version of <a href="ws/Basic/index.html">X3D Basic Examples archive</a> 
by performing version-control source update, build, validate and test tasks.
Also produced:
<a href="ws/Basic/ContentCatalogBasic.xml">content catalog</a>
and
<a href="ws/X3dExamplesBasic.zip">.zip archive</a>.
</p>
<p>
Officially released models and .zip distribution are maintained at 
<a href="http://www.web3d.org/x3d/content/examples/Basic" target="_blank">http://www.web3d.org/x3d/content/examples/Basic</a>.
</p>

<p>
Nightly builds are published at 
<a href="https://savagedefense.nps.navy.mil/SavageDefense/nightly" target="_blank">https://savagedefense.nps.navy.mil/SavageDefense/nightly</a>.
</p>

<p>
Additional example build projects nearby include
<ul>
<li><a href="../X3dExamplesBasic">X3dExamplesBasic</a></li>
<li><a href="../X3dExamplesConformanceNist">X3dExamplesConformanceNist</a></li>
<li><a href="../X3dExamplesVrml2.0Sourcebook">X3dExamplesVrml2.0Sourcebook</a></li>
<li><a href="../X3dExamplesX3dForWebAuthors">X3dExamplesX3dForWebAuthors</a></li>
<li><a href="../X3dExamplesSavage">X3dExamplesSavage</a></li>
<li><a href="https://savagedefense.nps.navy.mil/jenkins/job/X3dExamplesSavageDefense">X3dExamplesSavageDefense</a></li>
</ul>
</p>

<p>Additional information is available at
<a href="https://savage.nps.edu/Savage/developers.html#Jenkins" target="_blank">Savage Developers Guide</a>,
<a href="https://SavageDefense.nps.navy.mil/SavageDefense/developers.html#Jenkins">SavageDefense Developers Guide</a>,
<a href="http://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>
and
<a href="http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>.
</p>
        -->
    </target>

    <target name="clean.jenkins" description="clean files downloaded by jenkins.prepare">
        <echo message="clean/delete directory, files downloaded by jenkins.prepare"/>
        <delete dir="jenkins" failonerror="false" verbose="true"/>
        <mkdir  dir="jenkins"/>
    </target>

    <target name="jenkins.permissions" description="ensure archive files have correct permissions">
        <!-- utility task, not normally needed -->
        <echo message="ensure archive files have correct permissions:"/>
        <property name="verbose" value="true"/>
        <chmod verbose='${verbose}' perm='664' type="file">
            <fileset id="imageFiles" dir=".">
                <include name="**/*.png"/>
                <exclude name="**/.svn/*"/>
            </fileset>
        </chmod>
        <chown verbose='${verbose}' owner='jenkins:jenkins' type="file">
            <fileset refid="imageFiles"/>
        </chown>
    </target>

    <target name="jenkins.deploy.release" description="release jenkins build to website directory" depends="">
        <!-- this task is run in a separate project from the jenkins build nightly project, and so must adapt paths -->
        <!-- local: /var/lib/jenkins/jobs/X3dExamplesSavageDeployRelease/workspace/ -->
        <!-- build: /var/lib/jenkins/jobs/X3dExamplesSavage/workspace/X3dExamplesSavage.zip -->
        <tstamp>
            <format property="dateStamp" pattern="yyyyMMMMdd"/>
        </tstamp>
        <property name="zipFileName" value="X3dExamples${archive.name}.zip"/>
        <!-- mkdir and owner/permission settings for destination directories typically require root or sudo permissions -->
        <if>
            <equals arg1="${archive.name}" arg2="Savage" />
            <then>
            <!--
                <property name="zipFilePath" value="../../../X3dExamplesSavage/ws"/>
                <length property="archive.zip.length" file="${zipFilePath}/${zipFileName}"/>
                <echo message="Backing up prior ${zipFilePath}/${zipFileName} release to public build subdirectory as X3dExamples${archive.name}.${dateStamp}.zip"/>
                <copy file="${zipFilePath}/${zipFileName}" tofile="/var/www/html/X3dExamples${archive.name}.${dateStamp}.zip"        preservelastmodified="true" overwrite="true" force="true" verbose="true"/>
                <echo message="Copying ${zipFilePath}/${zipFileName} (${archive.zip.length} bytes) and X3dExamplesSavageAuvWorkbenchExcerpt.zip to public website"/>
                <copy todir="/var/www/html/"        preservelastmodified="true" overwrite="true" force="true" verbose="true">
                    <fileset dir="${zipFilePath}">
                        <include name="X3dExamplesSavageAuvWorkbenchExcerpt.zip"/>
                        <include name="${zipFileName}"/>
                    </fileset>
                </copy>
                <echo message="================================================================================"/>
                <echo message="Copying all build output files to deploy this jenkins workspace to public website"/>
                <copy todir="/var/www/html/Savage/"        preservelastmodified="true" overwrite="true" force="true" verbose="true">
                    <fileset dir="${zipFilePath}/Savage">
                        <include name="**/*"/>
                        <exclude name="**/.svn/*"/>
                    </fileset>
                </copy>
                -->
                        <!-- no need to filter further since this build only contains the original subversion content and direct products -->
            </then>
            
<!--
echo Post-build jenkins shell script X3dExamplesSavageDeployRelease
echo Copy build products to release deployment directory, preserve timestamps
pwd

echo Copy .zip archives
cp -fv ../../X3dExamplesSavage/workspace/X3dExamplesSavage*.zip /var/www/html/
echo Changing public permissions to readable and executable:
chmod g+rw+X /var/www/html/X3dExamplesSavage*.zip
chmod o+r+X  /var/www/html/X3dExamplesSavage*.zip

echo Copy file assets, Savage
cp -fr ../../X3dExamplesSavage/workspace/Savage /var/www/html/
echo Changing public permissions to readable and executable:
chmod g+rw+X -R /var/www/html/Savage
chmod o+r+X  -R /var/www/html/Savage

echo Cleanup subversion .svn subdirectories
rm -rf /var/www/html/SavageDefense/*/*/.svn
rm -rf /var/www/html/SavageDefense/*/.svn
rm -rf /var/www/html/SavageDefense/.svn
-->

<!--
echo Post-build jenkins shell script X3dExamplesSavageDefenseDeployRelease
echo Copy build products to release deployment directory
pwd
echo Copy .zip archive
cp -fv ../../X3dExamplesSavageDefense/workspace/X3dExamplesSavageDefense.zip /var/www/html/
echo Changing public permissions to readable and executable:
chmod g+rw /var/www/html/X3dExamplesSavage*.zip
chmod o+r  /var/www/html/X3dExamplesSavage*.zip

echo Copy file assets, SavageDefense
cp -fr ../../X3dExamplesSavageDefense/workspace/SavageDefense /var/www/html/
echo Changing public permissions to readable and executable:
chmod g+rw+X -R /var/www/html/SavageDefense
chmod o+r+X  -R /var/www/html/SavageDefense

echo Cleanup subversion .svn subdirectories
rm -rf /var/www/html/SavageDefense/*/*/.svn
rm -rf /var/www/html/SavageDefense/*/.svn
rm -rf /var/www/html/SavageDefense/.svn
-->

<!--
<p>
Deploy release version of locally built Jenkins project
When initiated by an administrator, deploy the release version of Savage using the local nightly-build Jenkins project 
<a href="../X3dExamplesSavage">X3dExamplesSavage</a>.
</p>
<p>
Officially released models and .zip distribution are maintained at 
<a href="https://savage.nps.edu/Savage" target="_blank">https://savage.nps.edu/Savage</a>.
</p>

<p>
Nightly builds are published at 
<a href="https://savage.nps.edu/Savage/nightly" target="_blank">https://savage.nps.edu/Savage/nightly</a>.
</p>

<p>
Nearby: additional X3D Example build projects include
<ul>
<li><a href="../X3dExamplesBasic">X3dExamplesBasic</a></li>
<li><a href="../X3dExamplesConformanceNist">X3dExamplesConformanceNist</a></li>
<li><a href="../X3dExamplesVrml2.0Sourcebook">X3dExamplesVrml2.0Sourcebook</a></li>
<li><a href="../X3dExamplesX3dForWebAuthors">X3dExamplesX3dForWebAuthors</a></li>
<li><a href="../X3dExamplesSavage">X3dExamplesSavage</a></li>
<li><a href="https://savagedefense.nps.navy.mil/jenkins/job/X3dExamplesSavageDefense">X3dExamplesSavageDefense</a></li>
</ul>
</p>

<p>Additional information is available at <a href="https://savage.nps.edu/developers.html" target="_blank">Savage Developers Guide</a>,
<a href="http://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>
and
<a href="http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>.
</p>
-->
        <elseif>
            <equals arg1="${archive.name}" arg2="SavageDefense" />
            <then>
            <!--
                <property name="zipFilePath" value="../../../X3dExamplesSavageDefense/ws"/>
                <length property="archive.zip.length" file="${zipFilePath}/${zipFileName}"/>
                <echo message="Copying current ${zipFilePath}/${zipFileName} (${archive.zip.length} bytes) to public website"/>
                <copy file="${zipFilePath}/${zipFileName}" tofile="/var/www/html/X3dExamples${archive.name}.${dateStamp}.zip" preservelastmodified="true" overwrite="true" force="true" verbose="true"/>
                <copy todir="/var/www/html/"        preservelastmodified="true" overwrite="true" force="true" verbose="true">
                    <fileset dir="${zipFilePath}">
                        <include name="${zipFileName}"/>
                    </fileset>
                </copy>
                <echo message="========================================================================="/>
                <echo message="Copying all build output files to deploy this jenkins workspace to public website"/>
                <copy todir="/var/www/html/SavageDefense" preservelastmodified="true" overwrite="true" force="true" verbose="true">
                    <fileset dir="${zipFilePath}/SavageDefense">
                        <include name="**/*"/>
                        <exclude name="**/.svn/*"/>
                    </fileset>
                </copy>
                -->
                        <!-- no need to filter further since this build only contains the original subversion content and direct products -->
            </then>
<!--
<p>
Deploy release version of locally built Jenkins project <a href="../X3dExamplesSavageDefense">X3dExamplesSavageDefense</a>.
</p>
<p>
This project is controlled-access For Official Use Only (FOUO). 
</p>
<p>
Officially released models and .zip distribution are maintained at 
<a href="https://savagedefense.nps.navy.mil/SavageDefense" target="_blank">https://savagedefense.nps.navy.mil/SavageDefense</a>.
</p>

<p>
Nightly builds are published at 
<a href="https://savagedefense.nps.navy.mil/SavageDefense/nightly" target="_blank">https://savagedefense.nps.navy.mil/SavageDefense/nightly</a>.
</p>

<p>
Nearby: additional X3D Example build projects include
<ul>
<li><a href="https://savage.nps.edu/jenkins/job/X3dExamplesBasic">X3dExamplesBasic</a></li>
<li><a href="https://savage.nps.edu/jenkins/job/X3dExamplesConformanceNist">X3dExamplesConformanceNist</a></li>
<li><a href="https://savage.nps.edu/jenkins/job/X3dExamplesVrml2.0Sourcebook">X3dExamplesVrml2.0Sourcebook</a></li>
<li><a href="https://savage.nps.edu/jenkins/job/X3dExamplesX3dForWebAuthors">X3dExamplesX3dForWebAuthors</a></li>
<li><a href="https://savage.nps.edu/jenkins/job/X3dExamplesSavage">X3dExamplesSavage</a></li>
<li><a href="https://savagedefense.nps.navy.mil/jenkins/job/X3dExamplesSavageDefense">X3dExamplesSavageDefense</a></li>
</ul>
</p>

<p>Additional information is available at 
<a href="https://savage.nps.edu/developers.html" target="_blank">Savage Developers Guide</a>, 
<a href="https://SavageDefense.nps.navy.mil/developers.html" target="_blank">SavageDefense Developers Guide</a>,
<a href="http://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>
and
<a href="http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>.
</p>
-->
        </elseif>
        <else>
            <!-- TODO, not yet implemented:
            <scp sftp="true" remotetodir="${username.web3d}@${sftpServer.web3d}:${sftpDirectory.web3d}" password="${password.web3d}" verbose="true">
                <fileset dir=".">
                    <include name="${zipFilePath}/${zipFileName}"/>
                </fileset>
            </scp>
            -->
        </else>
        </if>
    </target>

    <target name="jenkins.deploy.nightly" description="copy jenkins build .zip to website nightly-build directory" depends="">
        <!-- properties already set by zip task; match them to enable separate invocation -->
        <property name="zipFileName" value="../X3dExamples${archive.name}.zip"/>
        <length property="archive.zip.length" file="${zipFileName}"/>
        <echo message="Completed ${zipFileName} (${archive.zip.length} bytes)"/>
        <!-- server-side mkdir and owner/permission settings for destination directories typically require root or sudo permissions -->
        <!-- prerequisite permissions for destination .zip files:  -rw-rw-r- tomcat tomcat -->
        <if>
            <equals arg1="${archive.name}" arg2="Savage" />
            <then>
                <ant antfile="buildSavageAuvWorkbenchModelDistribution.xml" target="zip.AuvWorkbenchExcerpt"/>
                <property name="excerptZipFileName" value="../X3dExamplesSavageAuvWorkbenchExcerpt.zip"/>
                <length property="excerpt.zip.length" file="${excerptZipFileName}"/>
                <echo message="Completed ${excerptZipFileName} (${excerpt.zip.length} bytes)"/>
                <!--
                <echo message="Copying ${zipFileName} (${archive.zip.length} bytes) to nightly build subdirectory"/>
                <copy todir="/var/www/html/Savage/nightly"        preservelastmodified="true" overwrite="true" force="true" verbose="true">
                    <fileset dir=".">
                        <include name="${zipFileName}"/>
                    </fileset>
                </copy>
                <echo message="Copying ${excerptZipFileName} (${excerpt.zip.length} bytes) to nightly build subdirectory"/>
                <copy todir="/var/www/html/Savage/nightly"        preservelastmodified="true" overwrite="true" force="true" verbose="true">
                    <fileset dir=".">
                        <include name="${excerptZipFileName}"/>
                    </fileset>
                </copy>
                -->
                <!-- TODO SavageStudio excerpt -->
            </then>
        <elseif>
            <equals arg1="${archive.name}" arg2="SavageDefense" />
            <then>
                <!-- location: /var/lib/jenkins/jobs/X3dExamplesSavageDefense/workspace/X3dExamplesSavageDefense.zip -->
                <!--
                <echo message="Copying ${zipFileName} (${archive.zip.length} bytes) to nightly build subdirectory"/>
                <copy todir="/var/www/html/SavageDefense/nightly" preservelastmodified="true" overwrite="true" force="true" verbose="true">
                    <fileset dir=".">
                        <include name="${zipFileName}"/>
                    </fileset>
                </copy>
                -->
            </then>
        </elseif>
        <else>
            <!-- TODO, not yet implemented:
            <scp sftp="true" remotetodir="${username.web3d}@${sftpServer.web3d}:${sftpDirectory.web3d}" password="${password.web3d}" verbose="true">
                <fileset dir=".">
                    <include name="${zipFileName}"/>
                </fileset>
            </scp>
            -->
        </else>
        </if>
    </target>

<!-- Jenkins build server top-level description templates

<h2>Savage Jenkins Build Server</h2>
<p>This online continuous-integration server is used to test open-source code and content distributions.
Projects of interest include the AUV Workbench, X3D Examples, X3D Tools, and NPS source branch of the Xj3D player for X3D.</p>

<h2>SavageDefense Jenkins Build Server</h2>
<p>This online continuous-integration server is used to test open-source code and content distributions.  Projects of interest include TrackDataConversionSuiteDefense and X3dExamplesSavageDefense.</p>


<p>
For Official Use Only (FOUO) data access is restricted to U.S. government employees and contractors.
No classified information is contained in this system.
</p>

<p>
The
<a href="https://savage.nps.edu/developers.html#Jenkins">Savage Developers Guide</a>
contains further information about the various technologies involved and their configuration details.
</p>

<p>
We also maintain the FOUO restricted-access
<a href="https://savage.nps.edu/jenkins">Savage Jenkins Server</a>
and NPS-internal
<a href="https://mmog.ern.nps.edu/jenkins">Savage MMOG Jenkins Server</a>.
</p>
-->

<!-- Post-build execute shell commands for jenkins projects X3dExamplesSavage/X3dExamplesSavageDefense:

echo Post-build jenkins shell script
echo Copy build products to nightly deployment directory, preserve timestamps
pwd
cp -fvp X3dExamplesSavage*.zip /var/www/html/nightly/

echo Changing public permissions to readable and executable:
chmod g+rw+X -R /var/www/html/nightly/X3dExamplesSavage*.zip
chmod o+r+X  -R /var/www/html/nightly/X3dExamplesSavage*.zip

ls -al X3dExamplesSavage*.zip /var/www/html/nightly/X3dExamplesSavage*.zip
-->
<!-- TODO
echo move current copies to avoid later recopying/retimestamping if failed build occurs
mkdir -vp prior
mv    -vf X3dExamplesSavage*.zip prior/
-->
    <target name="jenkins.prepare" description="setup jenkins server-side build"> <!-- depends="clean.jenkins" -->
        <!-- jenkins tasks:  jenkins.prepare, build -->
        <!-- jenkins configuration needs to reset Ant property values to match subdirectories below:
c14n.dir=jenkins/lib
log4j.dir=jenkins/lib
saxon.dir=jenkins/lib
stylesheet.dir=jenkins/stylesheets
xj3d.dir=jenkins/lib
CreateContentCatalog.dir=jenkins/CreateContentCatalog
X3dSchematronValidityChecks.dir=jenkins/schematron
X3dDtdsSchemas.dir=jenkins/specifications
ignoreSetupDownloadErrors=true
        -->
        <!-- jenkins configuration for Ant java options:
-Dxml.catalog.files=jenkins/specifications/OasisXmlCatalogX3D.xml
-Dxml.catalog.verbosity=4
-Xbootclasspath/p:lib/bin
-Dsun.java2d.noddraw=true
-Djava.library.path=lib/bin
        -->
        <property name="jenkins.prepared" value="true"/>
        <property name="catalog.local.dtd" value="" description="use online X3D DTD and schema for catalog autogeneration"/>
        <echo message="Build settings:"/>
        <echo message="                         compiled=${compiled}"/>
        <echo message="                             fork=${fork}"/>
        <echo message="                         c14n.dir=${c14n.dir}"/>
        <echo message="                        log4j.dir=${log4j.dir}"/>
        <echo message="                        saxon.dir=${saxon.dir}"/>
        <echo message="                   stylesheet.dir=${stylesheet.dir}"/>
        <echo message="                         xj3d.dir=${xj3d.dir}"/>
        <echo message="         CreateContentCatalog.dir=${CreateContentCatalog.dir}"/>
        <echo message="  X3dSchematronValidityChecks.dir=${X3dSchematronValidityChecks.dir}"/>
        <echo message="               X3dDtdsSchemas.dir=${X3dDtdsSchemas.dir}"/>
        <echo message="        ignoreSetupDownloadErrors=${ignoreSetupDownloadErrors}"/>
        <echo message="   saxon path: ${saxon.dir}/${saxon.jar}"/>
   <!-- <echo message="resolver path: ${resolver.dir}/resolver.jar (${resolver.jar.length} bytes)"/> -->

        <echo message="get local copies of dependency files in order to independently prepare jenkins server-side build"/>

        <mkdir dir="${X3dDtdsSchemas.dir}"/>
        <get src="${x3d.sourceforge.site}/specifications/OasisXmlCatalogX3D.xml"
                             dest="${X3dDtdsSchemas.dir}/OasisXmlCatalogX3D.xml"    verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/CatalogManager.properties"
                             dest="${X3dDtdsSchemas.dir}/CatalogManager.properties" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.0.dtd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.0.dtd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.1.dtd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.1.dtd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.2.dtd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.2.dtd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.3.dtd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.3.dtd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.0.xsd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.0.xsd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.1.xsd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.1.xsd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.2.xsd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.2.xsd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/specifications/x3d-3.3.xsd"
                             dest="${X3dDtdsSchemas.dir}/x3d-3.3.xsd"               verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>

        <mkdir dir="${stylesheet.dir}"/>
        <get src="${x3d.sourceforge.site}/x3d/stylesheets/X3dToXhtml.xslt"
                                  dest="${stylesheet.dir}/X3dToXhtml.xslt"          verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/stylesheets/X3dToXhtml.sxx"
                                  dest="${stylesheet.dir}/X3dToXhtml.sxx"           verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/stylesheets/X3dToVrml97.xslt"
                                  dest="${stylesheet.dir}/X3dToVrml97.xslt"         verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/stylesheets/X3dToVrml97.sxx"
                                  dest="${stylesheet.dir}/X3dToVrml97.sxx"          verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/stylesheets/X3dToX3dvClassicVrmlEncoding.xslt"
                                  dest="${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.xslt" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/stylesheets/X3dToX3dvClassicVrmlEncoding.sxx"
                                  dest="${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.sxx"  verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/stylesheets/X3dExtrusionToSvgViaXslt1.1.xslt"
                                  dest="${stylesheet.dir}/X3dExtrusionToSvgViaXslt1.1.xslt"  verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>

        <mkdir dir="${c14n.dir}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/canonical/dist/lib/${c14n.jar}"
                                                     dest="${c14n.dir}/${c14n.jar}"  verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>

        <mkdir dir="${log4j.dir}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/canonical/dist/lib/${log4j.jar}"
                                                    dest="${log4j.dir}/${log4j.jar}" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>

        <mkdir dir="${saxon.dir}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/schematron/bin/${saxon.jar}"
                                                dest="${saxon.dir}/${saxon.jar}"     verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>

        <mkdir dir="${xj3d.dir}"/>
        <!-- TODO configure get https certificate handling; use local copy instead
        <get src="${xj3d.jar.site}/${xj3d.jar}"
                 dest="${xj3d.dir}/${xj3d.jar}"           verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${xj3d.jar.site}/${xj3d.cadfilter.jar}"
                 dest="${xj3d.dir}/${xj3d.cadfilter.jar}" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${xj3d.jar.site}/${xj3d.3rdparty.jar}"
                 dest="${xj3d.dir}/${xj3d.3rdparty.jar}"  verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${xj3d.jar.site}/${xj3d.browser.jar}"
                 dest="${xj3d.dir}/${xj3d.browser.jar}"   verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        -->
        
        <if>
            <equals arg1="${archive.name}" arg2="SavageDefense" />
            <then>
                <get src="http://xmsf.svn.sourceforge.net/viewvc/xmsf/trunk/AuvWorkbench/lib/xj3d/${xj3d.jar}"
                                                                                dest="${xj3d.dir}/${xj3d.jar}"           verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
                <get src="http://xmsf.svn.sourceforge.net/viewvc/xmsf/trunk/AuvWorkbench/lib/xj3d/${xj3d.cadfilter.jar}"
                                                                                dest="${xj3d.dir}/${xj3d.cadfilter.jar}" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
                <get src="http://xmsf.svn.sourceforge.net/viewvc/xmsf/trunk/AuvWorkbench/lib/xj3d/${xj3d.3rdparty.jar}"
                                                                                dest="${xj3d.dir}/${xj3d.3rdparty.jar}"  verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
                <get src="http://xmsf.svn.sourceforge.net/viewvc/xmsf/trunk/AuvWorkbench/lib/xj3d/${xj3d.browser.jar}"
                                                                                dest="${xj3d.dir}/${xj3d.browser.jar}"   verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
            </then>
            <else>
                <!-- Xj3D.nps build is on local server savage.nps.edu -->
                <copy file="/var/www/html/Xj3D.nps/jars/${xj3d.jar}"           todir="${xj3d.dir}/" verbose="true"/>
                <copy file="/var/www/html/Xj3D.nps/jars/${xj3d.cadfilter.jar}" todir="${xj3d.dir}/" verbose="true"/>
                <copy file="/var/www/html/Xj3D.nps/jars/${xj3d.3rdparty.jar}"  todir="${xj3d.dir}/" verbose="true"/>
                <copy file="/var/www/html/Xj3D.nps/jars/${xj3d.browser.jar}"   todir="${xj3d.dir}/" verbose="true"/>
            </else>
        </if>

        <mkdir dir="${X3dSchematronValidityChecks.dir}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/schematron/${X3dSchematronValidityChecks}.xslt"
                      dest="${X3dSchematronValidityChecks.dir}/${X3dSchematronValidityChecks}.xslt"             verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/schematron/${X3dSchematronValidityChecks}.sxx"
                      dest="${X3dSchematronValidityChecks.dir}/${X3dSchematronValidityChecks}.sxx"              verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/schematron/${SvrlReportText}.xslt"
                      dest="${X3dSchematronValidityChecks.dir}/${SvrlReportText}.xslt"                          verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/schematron/${SvrlReportText}.sxx"
                      dest="${X3dSchematronValidityChecks.dir}/${SvrlReportText}.sxx"                           verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>

        <mkdir dir="${CreateContentCatalog.dir}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/CreateContentCatalog/CreateContentCatalog.jar"
                                       dest="${CreateContentCatalog.dir}/CreateContentCatalog.jar"              verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/CreateContentCatalog/CreateContentCatalogPages.xslt"
                                       dest="${CreateContentCatalog.dir}/CreateContentCatalogPages.xslt"        verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <!-- DTD to validate content catalog used for creation of example archive html pages -->
        <get src="${x3d.sourceforge.site}/x3d/tools/CreateContentCatalog/ContentCatalog.dtd"
                                       dest="${CreateContentCatalog.dir}/ContentCatalog.dtd"                    verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/CreateContentCatalog/ContentCatalogToXmlSpyProject.xslt"
                                       dest="${CreateContentCatalog.dir}/ContentCatalogToXmlSpyProject.xslt"    verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/tools/CreateContentCatalog/SavageModelingAnalysisLanguage1.0.dtd"
                                       dest="${CreateContentCatalog.dir}/SavageModelingAnalysisLanguage1.0.dtd" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
    
        <!-- Copy viewpoint screen snapshot images to support catalog generation -->
        <if>
            <equals arg1="${archive.name}" arg2="Savage" />
            <then>
                <echo message="Copy viewpoint screen snapshot images to support catalog generation"/>
                <copy todir="." preservelastmodified="true" overwrite="true" verbose="true">
                    <fileset dir="/var/www/html/${archive.name}">
                        <include name="*/*/_viewpoints/*.png"/>
                        <exclude name="**/.svn/*"/>
                    </fileset>
                </copy>
            </then>
        <elseif>
            <equals arg1="${archive.name}" arg2="SavageDefense" />
            <then>
                <echo message="Copy viewpoint screen snapshot images to support catalog generation"/>
                <copy todir="." preservelastmodified="true" overwrite="true" verbose="true">
                    <fileset dir="/var/www/html/${archive.name}">
                        <include name="*/*/_viewpoints/*.png"/>
                        <exclude name="**/.svn/*"/>
                    </fileset>
                </copy>
            </then>
        </elseif>
        </if>
    </target>

    <target name="commonSetup" depends="HelloWorld,newScene" description="Copy setup files from common example archives">
        <!-- each specific example archive redirects to X3dResources.html (formerly help.html) in parent examples directory due to other relative links there -->
        <get src="${x3d.sourceforge.site}/x3d/content/examples/_help.redirect.html"
                                                          dest="help.html"                    verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <!-- here is local copy of X3dResources.html as well -->
        <get src="${x3d.sourceforge.site}/x3d/content/examples/X3dResources.html"
                                                         dest="X3dResources.html"             verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/X3dSceneAuthoringHints.html"
                                                         dest="X3dSceneAuthoringHints.html"   verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/license.html"
                                                         dest="license.html"                  verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/license.txt"
                                                         dest="license.txt"                   verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/newHtmlPageWithX3dObject.html"
                                                         dest="newHtmlPageWithX3dObject.html" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/newECMAscript.js"
                                                         dest="newECMAscript.js"              verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/newX3dScript.java"
                                                         dest="newX3dScript.java"             verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/newStylesheet.xslt"
                                                         dest="newStylesheet.xslt"            verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <antcall target="get.slideshowTools"/>
    </target>

    <target name="get.slideshowTools" description="retrieve slideshow package"> <!-- unless="${ignoreSetupDownloadErrors}" -->
        <echo message="Retrieve open-source google slideshow package http://code.google.com/p/slideshow"/>
        <property name="mootools.zip" value="Slideshow-1.3.2.110508.zip"/>
        <get src="http://slideshow.googlecode.com/files/${mootools.zip}"
                                                  dest="${mootools.zip}" verbose="true" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <mkdir  dir="slideshow"/>
        <unzip dest="slideshow" src="${mootools.zip}"/>
        <move todir="slideshow" verbose="true">
            <fileset dir="slideshow/Slideshow">
              <include name=    "css/**/*"/>
              <include name=    "js/**/*"/>
              <include name="README"/>
              <!--
              <include name="images/**/*"/>
              <include name="index.html"/>
              -->
            </fileset>
        </move>
        <delete  dir="slideshow/Slideshow" verbose="true"/>
        <delete  dir="slideshow/__MACOSX"  verbose="true"/>
        <delete file="${mootools.zip}"     verbose="true"/>
    </target>

    <target name="diagnostics" description="Ant diagnostics, shows jars and classpaths">
        <diagnostics/>
    </target>

    <target name="HelloWorld" description="Copy HelloWorld.x3d example from common example archives and convert to other encodings">
        <delete failonerror="false">
            <fileset dir="." includes="HelloWorld.*"/>
            <fileset dir="." includes="HelloWorldCanonical.*"/>
        </delete>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/HelloWorld.x3d"
                                                         dest="HelloWorld.x3d"       ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/earth-topo.jpg"
                                                         dest="earth-topo.jpg"       ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/earth-topo.png"
                                                         dest="earth-topo.png"       ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/earth-topo.gif"
                                                         dest="earth-topo.gif"       ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/earth-topo-small.gif"
                                                         dest="earth-topo-small.gif" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/HelloWorld.tall.png"
                                                         dest="HelloWorld.tall.png"  ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <echo message="X3dCatalog X3dDtdsSchemas.dir=${X3dDtdsSchemas.dir}"/>
        <echo message="check well-formedness"/>
        <xmlvalidate file="HelloWorld.x3d" failonerror="false" warn="true" lenient="yes"/>
        <echo message="check DTD validation"/>
        <xmlvalidate file="HelloWorld.x3d" failonerror="false" warn="true">
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
        </xmlvalidate>
        <echo message="Convert HelloWorld.x3d to HelloWorld.html using X3dToXhtml.xslt stylesheet"/>
        <!-- http://www.saxonica.com/documentation/using-xsl/commandline.html                           -->
        <!-- java net.sf.saxon.Transform -s:source -o:output [-xsl:stylesheet or -c:compiledStylesheet] -->
        <!-- $(SAXON) -t -s:HelloWorld.x3d -o:HelloWorld.html -xsl:../X3dToXhtml.xslt -->
        <!-- $(SAXON) -t -s:HelloWorld.x3d -o:HelloWorld.html   -c:../X3dToXhtml.sxx  -->
        <!-- note reordering of parameters for source, output contrary to Saxon documentation! -->
        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="${fork}">
        <!--<arg value="-t"/> timing information -->
            <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
            <arg value="-s:HelloWorld.x3d"/>
            <arg value="-o:HelloWorld.html"/>
            <arg value="-xsl:${stylesheet.dir}/X3dToXhtml.xslt"/> <!--  regular stylesheet -->
        <!--<arg value="  -c:${stylesheet.dir}/X3dToXhtml.sxx"/>       compiled stylesheet -->
        </java>
        <echo message="Convert HelloWorld.x3d to HelloWorld.wrl using X3dToVrml97.xslt stylesheet"/>
        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="${fork}">
            <arg value="-warnings:recover"/>
            <arg value="-s:HelloWorld.x3d"/>
            <arg value="-o:HelloWorld.wrl"/>
            <arg value="-xsl:${stylesheet.dir}/X3dToVrml97.xslt"/> <!-- regular stylesheet -->
        <!--<arg value="  -c:${stylesheet.dir}/X3dToVrml97.sxx"/>      compiled stylesheet -->
        </java>
        <echo message="Convert HelloWorld.x3d to HelloWorld.x3dv using X3dToX3dvClassicVrmlEncoding.xslt stylesheet"/>
        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="${fork}">
            <arg value="-warnings:recover"/>
            <arg value="-s:HelloWorld.x3d"/> 
            <arg value="-o:HelloWorld.x3dv"/>
            <arg value="-xsl:${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.xslt"/> <!--  regular stylesheet -->
        <!--<arg value="  -c:${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.sxx"/>       compiled stylesheet -->
        </java>
        <echo message="Convert HelloWorld.x3d to HelloWorldCanonical.xml using canonicalX3D"/>
        <!-- canonicalX3D is locally defined macro -->
        <!-- X3dC14n requires full paths to the scene in order to resolve where to put the *Canonical.xml version -->
        <canonicalX3D scene="${basedir}/HelloWorld"/>
        <!-- now compressed binary encoding -->
        <echo message="Convert HelloWorld.x3d to HelloWorld.x3db using Xj3D cadfilter"/>
        <!-- path diagnostics
        <echo message="{xj3d.dir} {xj3d.jar}=${xj3d.dir}/${xj3d.jar}"/>
        <echo message="{xj3d.dir} {xj3d.browser.jar}=${xj3d.dir}/${xj3d.browser.jar}"/>
        <echo message="{xj3d.dir} {xj3d.cadfilter.jar}=${xj3d.dir}/${xj3d.cadfilter.jar}"/>
        <echo message="{xj3d.dir} {xj3d.3rdparty.jar}=${xj3d.dir}/${xj3d.3rdparty.jar}"/>
        -->
        <java classname="xj3d.filter.CDFFilter" fork="${fork}" dir=".">
            <classpath>
                <pathelement path="${classpath}"/>
                <fileset refid="xj3d.jars.all"/>
            </classpath>
       <!-- <jvmarg value="-verbose"/> -->
            <arg value="Identity"/>
            <arg value="HelloWorld.x3d"/>
            <arg value="HelloWorld.x3db"/>
        </java>
        <if>
            <not>
                <equals arg1="${jenkins.prepared}" arg2="true" />
            </not>
            <then>
                <echo message="all conversions complete, save results in parent directory next to master copy of HelloWorld.x3d"/>
                <copy todir=".." overwrite="true" verbose="true">
                    <fileset dir="." includes="HelloWorld.x3dv"/>
                    <fileset dir="." includes="HelloWorld.x3db"/>
                    <fileset dir="." includes="HelloWorld.wrl"/>
                    <fileset dir="." includes="HelloWorld.html"/>
                    <fileset dir="." includes="HelloWorldCanonical.xml"/>
                </copy>
            </then>
        </if>
    </target>

    <target name="newScene" description="Copy newScene.x3d example from common example archives and convert to other encodings">
        <delete failonerror="false">
            <fileset dir="." includes="newScene*"/>
        </delete>
        <get src="${x3d.sourceforge.site}/x3d/content/examples/newScene.x3d"
                                                         dest="newScene.x3d" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <echo message="X3dCatalog X3dDtdsSchemas.dir=${X3dDtdsSchemas.dir}"/>
        <echo message="check well-formedness"/>
        <xmlvalidate file="newScene.x3d" failonerror="false" warn="true" lenient="yes"/>
        <echo message="check DTD validation"/>
        <xmlvalidate file="newScene.x3d" failonerror="false" warn="true">
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
        </xmlvalidate>
        <echo message="Convert newScene.x3d to newScene.html using X3dToXhtml.xslt regular stylesheet"/> <!-- TODO .sxx compressed stylesheet"/> -->
        <!-- http://www.saxonica.com/documentation/using-xsl/commandline.html                           -->
        <!-- java net.sf.saxon.Transform -s:source -o:output [-xsl:stylesheet or -c:compiledStylesheet] -->
        <!-- $(SAXON) -t -s:newScene.x3d -o:newScene.html -xsl:../X3dToXhtml.xslt -->
        <!-- $(SAXON) -t -s:newScene.x3d -o:newScene.html   -c:../X3dToXhtml.sxx  -->
        <!-- note reordering of parameters for source, output contrary to Saxon documentation! -->
        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="${fork}">
        <!--<arg value="-t"/> timing information -->
            <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
            <arg value="-s:newScene.x3d"/>
            <arg value="-o:newScene.html"/>
            <arg value="-xsl:${stylesheet.dir}/X3dToXhtml.xslt"/> <!--  regular stylesheet -->
        <!--<arg value="  -c:${stylesheet.dir}/X3dToXhtml.sxx"/>       compiled stylesheet -->
        </java>
        <echo message="Convert newScene.x3d to newScene.wrl using X3dToVrml97.xslt regular stylesheet"/> <!-- TODO .sxx compressed stylesheet"/> -->
        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="${fork}">
            <arg value="-warnings:recover"/>
            <arg value="-s:newScene.x3d"/>
            <arg value="-o:newScene.wrl"/>
            <arg value="-xsl:${stylesheet.dir}/X3dToVrml97.xslt"/> <!-- regular stylesheet -->
        <!--<arg value="  -c:${stylesheet.dir}/X3dToVrml97.sxx"/>      compiled stylesheet -->
        </java>
        <echo message="Convert newScene.x3d to newScene.x3dv using X3dToX3dvClassicVrmlEncoding.xslt regular stylesheet"/> <!-- TODO .sxx compressed stylesheet"/> -->
        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="${fork}">
            <arg value="-warnings:recover"/>
            <arg value="-s:newScene.x3d"/>
            <arg value="-o:newScene.x3dv"/>
            <arg value="-xsl:${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.xslt"/> <!--  regular stylesheet -->
        <!--<arg value="  -c:${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.sxx"/>       compiled stylesheet -->
        </java>
        <echo message="Convert newScene.x3d to newSceneCanonical.xml using canonicalX3D"/>
        <!-- canonicalX3D is locally defined macro -->
        <canonicalX3D scene="${basedir}/newScene"/>
        <!-- now compressed binary encoding -->
        <echo message="Convert newScene.x3d to newSceneCanonical.x3db using Xj3D cadfilter"/>
        <java classname="xj3d.filter.CDFFilter" fork="${fork}" dir=".">
            <classpath>
                <pathelement path="${classpath}"/>
                <fileset refid="xj3d.jars.all"/>
            </classpath>
            <arg value="Identity"/>
            <arg value="newScene.x3d"/>
            <arg value="newScene.x3db"/>
        </java>
        <if>
            <not>
                <equals arg1="${jenkins.prepared}" arg2="true" />
            </not>
            <then>
                <echo message="all conversions complete, save results in parent directory next to master copy"/>
                <copy todir=".." overwrite="true" verbose="true">
                    <fileset dir="." includes="newScene.x3dv"/>
                    <fileset dir="." includes="newScene.x3db"/>
                    <fileset dir="." includes="newScene.wrl"/>
                    <fileset dir="." includes="newScene.html"/>
                    <fileset dir="." includes="newSceneCanonical.xml"/>
                </copy>
            </then>
        </if>
    </target>

    <!-- TODO validate.schema.saxonicaSA, -->
    <target name="validate.all" description="XML well formed, DTD and schematron validation for all .x3d examples"
        depends="clean.duplicates,validate.DTD,validate.schematron">
        <echo message="validate.all using all methods: ${archive.name} archive complete"/>
        <!-- TODO
        <echo message="warning: schema validation of all files is a bit slow and is prone to java.lang.StackOverflowError within Ant"/>
        <antcall target="validate.schema.new"/>
        <antcall target="validate.schema.all"/>
        <antcall target="validate.xmllint"/> 
        -->
    </target>

    <target name="validate.DTD" description="XML well formed, DTD validation for all .x3d examples"
        depends="clean.duplicates">
        <!-- XML well-formed checks -->
        <echo message="XML well-formed check: ${archive.name} build.xml and scenes"/>
        <echo message="Verifying Apache Ant XML Catalog resolver classpath: ${resolver.dir}/resolver.jar (${resolver.jar.length} bytes)"/>
        <xmlvalidate failonerror="false" warn="true" lenient="yes" file="build.xml"/>
        <echo message="X3D DTDs and schemas available at http://www.web3d.org/specifications"/>
        <echo message="check well-formedness of X3D scenes"/>
        <xmlvalidate failonerror="false" warn="true" lenient="yes">
            <!-- only check *.x3d files of interest (and *Canonical.xml versions as a double-check) not grandchild directories holding errors or work in progress -->
            <fileset refid="x3dScenes"/>
            <fileset refid="xmlFiles"/>
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
        </xmlvalidate>
        <!-- X3D DTD validation -->
        <echo message="Validate using X3D DTD: ${archive.name} archive"/>
        <xmlvalidate failonerror="false" warn="true">
            <!-- only check *.x3d files of interest (and *Canonical.xml versions as a double-check) not grandchild directories holding errors or work in progress -->
            <fileset refid="x3dScenes"/>
            <fileset refid="xmlFiles"/>
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
        </xmlvalidate>
        <echo>validate.DTD complete.</echo>
    </target>

    <target name="validate.schema.all" description="XML validation for all .x3d examples using X3D schema (caution, time consuming)"
        depends="clean.duplicates">
        <!-- X3D schema validation -->
        <echo message="Validate using X3D schema: ${archive.name} archive"/>
        <echo message="X3D DTDs and schemas available at http://www.web3d.org/specifications"/>
        <!-- TODO need to try increasing stack space to 16m, fullchecking true results in java.lang.StackOverflowError
        at com.sun.org.apache.xerces.internal.impl.xpath.regex.RegularExpression.matchString(RegularExpression.java:1903) -->
        <schemavalidate lenient="false" failonerror="false" fullchecking="false" warn="true">
            <!-- only check *.x3d files of interest, not grandchild directories holding errors or work in progress -->
            <fileset refid="x3dScenes"/>
            <xmlcatalog refid="X3dCatalog"/>
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
            <!-- TODO <fileset refid="xmlFiles"/> -->
        </schemavalidate>
    </target>

    <target name="validate.schema.saxonicaSA" description="XML validation for all .x3d examples using X3D schema (caution, time consuming)"
        depends="clean.duplicates">
        <!-- X3D schema validation -->
        <echo message="Validate using X3D schema,saxonicaSA: ${archive.name} archive"/>
        <echo message="http://www.web3d.org/specifications http://www.saxonica.com"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <echo message="@{file.path.name} validation using X3D schema, saxononicaSA..."/>
                <java classname="com.saxonica.Validate" classpath="${saxononicaSA.dir}/saxon9sa.jar;${saxononicaSA.dir};${saxononicaSA.dir}/saxon-license.lic;." fork="false">
                    <arg value="@{file.path.name}"/>
                </java>
            </sequential>
        </for>
    </target>

    <target name="validate.schema.new" description="XML validation for new or modified .x3d examples using X3D schema"
        depends="clean.duplicates">
        <echo message="Validate using X3D schema: ${archive.name} archive, new scenes"/>
        <echo message="X3D DTDs and schemas available at http://www.web3d.org/specifications"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="@{file.path.name}"/>
                        </filelist>
                    </sourcefiles>
                    <mapper dir="." type="glob" from="*.x3d" to="*Canonical.xml"/>
                    <sequential>
                        <!-- process individual files here.  show full path to facilitate user loading, editing of reported files -->
                        <echo message="@{file.path.name} validation using X3D schema..."/>
                        <schemavalidate file="@{file.path.name}" lenient="false" failonerror="false" fullchecking="true">
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
                        </schemavalidate>
                    </sequential>
                </outofdate>
            </sequential>
        </for>
        <echo>validate.schema.new complete.</echo>
    </target>

    <target name="validate.schematron" description="validate each .x3d scene using X3D Schematron rules (caution: time consuming)"
        depends="clean.duplicates">
        <echo message="Validate using X3D Schematron: ${archive.name} archive"/>
        <echo message="http://www.web3d.org/x3d/tools/schematron/X3dSchematron.html"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <!-- trace
                <echo></echo>
                <echo>@file.path.name       = @{file.path.name}</echo>
                <echo>$archive.path         = ${archive.path}</echo>
                <echo>$relative.path1       = ${relative.path1}</echo>
                <echo>$relative.path2       = ${relative.path2}</echo>
                <echo>$name.short           = ${name.short}</echo>
                -->
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="@{file.path.name}"/>
                        </filelist>
                    </sourcefiles>
                    <mapper dir="." type="glob" from="*.x3d" to="_schematron/*.svrl"/>
                    <sequential>
                        <!-- process individual files here.  show full path to facilitate user loading, editing of reported files -->
                        <mkdir dir="${archive.path}/${relative.path1}/${relative.path2}/_schematron"/>
                        <!-- regular .xslt stylesheet using Ant task:
                        <echo>@{file.path.name} validation using source X3D Schematron rules</echo>
                        <xslt basedir="." destdir="." extension=""
                              style="${X3dSchematronValidityChecks.dir}/${X3dSchematronValidityChecks}.xslt"
                                 in="@{file.path.name}"
                                out="${archive.path}/${relative.path1}/${relative.path2}/_schematron/${name.short}.svrl">
                            <xmlcatalog refid="X3dCatalog"/>
                        </xslt>
                        <xslt basedir="." destdir="." extension=""
                              style="${X3dSchematronValidityChecks.dir}/${SvrlReportText}.xslt"
                                 in="${archive.path}/${relative.path1}/${relative.path2}/_schematron/${name.short}.svrl"
                                out="${archive.path}/${relative.path1}/${relative.path2}/_schematron/${name.short}.svrl.txt">
                            <xmlcatalog refid="X3dCatalog"/>
                        </xslt>
                        -->
                        <!-- compiled .sxx stylesheet using Saxon -->
                        <echo>@{file.path.name} validation using compiled X3D Schematron rules</echo>
                        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="false">
                            <arg value="-warnings:recover"/>
                            <arg value="-c"/>                   <!-- compiled stylesheet -->
                            <arg value="-o"/>
                            <arg value="${relative.path1}/${relative.path2}/_schematron/${name.short}.svrl"/> <!-- ${archive.path}/ -->
                            <arg value="@{file.path.name}"/>
                            <arg value="${X3dSchematronValidityChecks.dir}/${X3dSchematronValidityChecks}.sxx"/>
                        </java>
                        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="false">
                            <arg value="-warnings:recover"/>
                            <arg value="-c"/>                   <!-- compiled stylesheet -->
                            <arg value="-o"/>
                            <arg value="${relative.path1}/${relative.path2}/_schematron/${name.short}.svrl.txt"/> <!-- ${archive.path}/ -->
                            <arg value="${relative.path1}/${relative.path2}/_schematron/${name.short}.svrl"/>
                            <arg value="${X3dSchematronValidityChecks.dir}/${SvrlReportText}.sxx"/>
                        </java>
                        <concat>
                            <filelist dir="." files="${relative.path1}/${relative.path2}/_schematron/${name.short}.svrl.txt"/>
                        </concat>
                    </sequential>
                </outofdate>
            </sequential>
        </for>
        <echo>validate.schematron complete.</echo>
    </target>

    <!-- prerequisite:  xmllint installed on system path.  
         provided as part of libxml library, http://xmlsoft.org
         suggested installation for Windows is cygwin, http://cygwin.com -->
    <!-- TODO:  not working
    <target name="validate.xmllint">
        <for param="filenames">
            <path>
                <fileset dir="." includes="**/*.x3d"/>
            </path>
            <sequential>
                <propertyregex
                    property="path.scene"
                    override="true"
                    input="@{filenames}"
                    regexp="([^\n]*)[\\|/][^\\]*\.x3d"
                    select="\1"/>
                <propertyregex
                    property="filename.prefix"
                    override="true"
                    input="@{filenames}"
                    regexp="([^\\]*\\)*([^\n]*)\.x3d"
                    select="\2"/>
                <echo>Processing ${path.scene}/${filename.prefix}.x3d with xmllint</echo>
                <exec executable="xmllint">
                    <arg value="- -valid"/>
                    <arg value="- -noout"/>
                    <arg value="- -dtdvalid  file:///cygdrive/c/www.web3d.org/specifications/x3d-3.2.dtd"/>
                    <arg value="${path.scene}/${filename.prefix}.x3d"/>
                </exec>
            </sequential>
        </for>
    </target>
    -->

    <target name="refresh.local" depends="clean.backups,clean.duplicates,commonSetup,validate.DTD,processScenes,catalog,zip" description="quick master refresh of all .x3d examples:  processScenes, catalog, zip">
        <echo message="${archive.name} refresh.local complete."/>
    </target>

    <target name="refresh.upload" depends="refresh.local,upload" description="quick master refresh of all .x3d examples, then upload">
        <echo message="${archive.name} refresh.upload complete."/>
    </target>

    <!-- TODO:  subversion update, potentially will need to deconflict naming of tasks -->
    <target name="update.subversion.draft" depends="clean.backups,commonSetup,processScenes" description="update online versions for all .x3d examples">
        <!-- subversion task here -->
        <echo message="${archive.name} update complete."/>
    </target>

    <target name="upload" description="upload all x3d examples and archive files, including .zip">
        <ant dir=".." target="sftp.uploadExampleUpdates.${archive.name}"/>
        <echo message="${archive.name} upload complete."/>
    </target>

    <target name="upload.scenes" depends="clean.backups,clean.duplicates" description="upload scenes in examples archive (overwrite previous versions), do not upload .zip">
        <ant dir=".." target="sftp.uploadExampleUpdates.${archive.name}.scenes"/>
        <echo message="${archive.name} upload.scenes complete."/>
    </target>

    <target name="upload.zip" description="upload .zip examples archive (overwrite previous version)">
        <ant dir=".." target="sftp.uploadExampleUpdates.${archive.name}.zip"/>
        <echo message="${archive.name}.zip upload complete."/>
    </target>

    <target name="processScenes" description="process all scenes with all conversion tasks">
        <echo>TODO: note that if Viewpoint descriptions changed, or the visible rendered scene changed,</echo>
        <echo>      then you must delete the pretty-print .html version in order to trigger target task</echo>
        <echo>      processScenes.captureViewpointImages and regenerate the viewpoint snapshot images.</echo>
        <!-- processScenes.canonicalX3D      occurs first because it replaces original .x3d scene -->
        <!-- processScenes.X3DtoVRML97       occurs second because provides diagnostic scene correctness checks -->
        <!-- processScenes.captureViewpointImages occurs third because it must be performed before processScenes.X3dToXhtml -->
        <!-- this task depends on other tasks to look through the directories, only updating as needed -->
        <antcall target="processScenes.canonicalX3D"/>
        <antcall target="processScenes.X3DtoVRML97"/>
        <!-- processScenes.X3dToXhtml conversion should precede processScenes.captureViewpointImages -->
        <antcall target="processScenes.X3dToXhtml"/>
        <antcall target="processScenes.captureViewpointImages"/>
        <antcall target="processScenes.X3dToX3dvClassicVrmlEncoding"/>
        <antcall target="processScenes.X3dToX3dbCompressedBinaryEncoding"/>
        <echo message="${archive.name} processScenes complete."/>
    </target>

    <target name="processScenes.X3dToXhtml" description="convert each .x3d scene into pretty-print .html version, also generate SVG diagrams of 2D plots such as Extrusion crossSection">
        <echo message="stylesheet compiled=${compiled}"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <!-- trace
                <echo></echo>
                <echo>@file.path.name       = @{file.path.name}</echo>
                <echo>$archive.path         = ${archive.path}</echo>
                <echo>$relative.path1       = ${relative.path1}</echo>
                <echo>$relative.path2       = ${relative.path2}</echo>
                <echo>$name.short           = ${name.short}</echo>
                -->
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="@{file.path.name}"/>
                        </filelist>
                    </sourcefiles>
                    <mapper dir="." type="glob" from="*.x3d" to="*.html"/>
                    <sequential>
                        <!-- process individual files here. show full path to facilitate user loading, editing of reported files -->
                        <echo>${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d processing with X3dToXhtml stylesheet</echo>
                        <!-- Saxon9 is locally defined macro -->
                        <Saxon9  scene="${relative.path1}/${relative.path2}/${name.short}"
                            stylesheet="${stylesheet.dir}/X3dToXhtml"
                             extension="html"
                              compiled="${compiled}"
                        parameterPair1="linkImages=true"/>
                        <!-- TODO -dtd:off -->
                    </sequential>
                </outofdate>
            </sequential>
        </for>
        <!-- clean up erroneous namespace artifacts -->
        <replace dir="." token=' xmlns=""' value="">
            <include name="**/*.svg"/>
        </replace>
        <echo>processScenes.X3dToXhtml complete.</echo>
    </target>

    <target name="processScenes.X3DtoVRML97" description="convert each .x3d scene to .wrl VRML97 version">
        <echo message="stylesheet compiled=${compiled}"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <!-- trace
                <echo></echo>
                <echo>@file.path.name       = @{file.path.name}</echo>
                <echo>$archive.path         = ${archive.path}</echo>
                <echo>$relative.path1       = ${relative.path1}</echo>
                <echo>$relative.path2       = ${relative.path2}</echo>
                <echo>$name.short           = ${name.short}</echo>
                -->
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="@{file.path.name}"/>
                        </filelist>
                    </sourcefiles>
                    <mapper dir="." type="glob" from="*.x3d" to="*.wrl"/>
                    <sequential>
                        <!-- process individual files here.  show full path to facilitate user loading, editing of reported files -->
                        <echo>${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d processing with X3dToVrml97 stylesheet</echo>
                        <!-- Saxon9 is locally defined macro -->
                        <Saxon9  scene="${relative.path1}/${relative.path2}/${name.short}"
                            stylesheet="${stylesheet.dir}/X3dToVrml97"
                             extension="wrl"
                              compiled="${compiled}"/>
                    </sequential>
                </outofdate>
            </sequential>
        </for>
        <echo>processScenes.X3DtoVRML97 complete.</echo>
    </target>

    <target name="processScenes.X3dToX3dvClassicVrmlEncoding">
        <echo message="stylesheet compiled=${compiled}"/>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <!-- trace
                <echo></echo>
                <echo>@file.path.name       = @{file.path.name}</echo>
                <echo>$archive.path         = ${archive.path}</echo>
                <echo>$relative.path1       = ${relative.path1}</echo>
                <echo>$relative.path2       = ${relative.path2}</echo>
                <echo>$name.short           = ${name.short}</echo>
                -->
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="@{file.path.name}"/>
                        </filelist>
                    </sourcefiles>
                    <mapper dir="." type="glob" from="*.x3d" to="*.x3dv"/>
                    <sequential>
                        <!-- process individual files here.  show full path to facilitate user loading, editing of reported files -->
                        <echo>${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d processing with X3dToX3dvClassicVrmlEncoding stylesheet</echo>
                        <!-- Saxon9 is locally defined macro -->
                        <Saxon9  scene="${relative.path1}/${relative.path2}/${name.short}"
                            stylesheet="${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding"
                             extension="x3dv"
                              compiled="${compiled}"/>
                    </sequential>
                </outofdate>
            </sequential>
        </for>
        <echo>processScenes.X3dToX3dvClassicVrmlEncoding complete.</echo>
    </target>

    <target name="processScenes.X3dToX3dbCompressedBinaryEncoding" description="convert each .x3d scene to .x3db Compressed Binary Encoding version">
        <!-- dependency:  local Xj3D build, see xj3d.dir etc. definitions -->
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <!-- trace
                <echo></echo>
                <echo>@file.path.name       = @{file.path.name}</echo>
                <echo>$archive.path         = ${archive.path}</echo>
                <echo>$relative.path1       = ${relative.path1}</echo>
                <echo>$relative.path2       = ${relative.path2}</echo>
                <echo>$name.short           = ${name.short}</echo>
                -->
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="@{file.path.name}"/>
                        </filelist>
                    </sourcefiles>
                    <mapper dir="." type="glob" from="*.x3d" to="*.x3db"/>
                    <sequential>
                        <!-- process individual files here.  show full path to facilitate user loading, editing of reported files -->
                        <echo>${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d processing with Xj3D for .x3db binary compression</echo>
                        <java classname="xj3d.filter.CDFFilter" fork="${fork}" dir=".">
                            <classpath>
                                <pathelement path="${classpath}"/>
                                <fileset refid="xj3d.jars.all"/>
                            </classpath>
                            <arg value="Identity"/>
                            <arg value="${relative.path1}/${relative.path2}/${name.short}.x3d"/>
                            <arg value="${relative.path1}/${relative.path2}/${name.short}.x3db"/>
                        </java>
                    </sequential>
                </outofdate>
            </sequential>
        </for>
        <echo>processScenes.X3dToX3dbCompressedBinaryEncoding complete.</echo>
    </target>

    <target name="processScenes.touchViewpointImages" description="update timestamp on captured viewpoint images to avoid need to reshoot">
        <touch>
            <fileset dir=".">
                <include name="**/_viewpoints/${name.short}.x3d.*.png"/>
            </fileset>
        </touch>
    </target>

<!--
original .x3db converter.sh invocation Xj3D SEP 2008 release:
java  -Xmx450M -Xbootclasspath/p:./bin -Dsun.java2d.noddraw=true -Djava.library.path=./bin 
-classpath .;"%Xj3D_HOME%"/apps/cadfilter/${xj3d.cadfilter.jar};"%Xj3D_HOME%"/jars/xj3d-all_2.0.0.jar xj3d.cadfilter.CDFFilter Identity %1 %2 %3 %4 %5 %6

past invocation problems and fixes documented in http://bugzilla.xj3d.org/show_bug.cgi?id=510

TODO:  fix Xj3D from launching window, instead perform offline rendering while headless to permit server operation,
       possibly by using xvfb X-windows virtual frame buffer
-->

    <target name="processScenes.captureViewpointImages" description="use Xj3D to create snapshot pictures of each viewpoint" depends="platformInitialize">
        <if>
            <not>
                <equals arg1="${jenkins.prepared}" arg2="true" />
            </not>
            <then>
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <!-- trace
                <echo></echo>
                <echo>@file.path.name       = @{file.path.name}</echo>
                <echo>$archive.path         = ${archive.path}</echo>
                <echo>$relative.path1       = ${relative.path1}</echo>
                <echo>$relative.path2       = ${relative.path2}</echo>
                <echo>$name.short           = ${name.short}</echo>
                -->
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d"/>
                        </filelist>
                    </sourcefiles>
                    <!-- match pretty-print .html creation as the trigger for viewpoint capture -->
                    <mapper dir="." type="glob" from="*.x3d" to="*.html"/>
                    <!-- note:  targetfiles match with image filenames is not working, probably due to * wildcard.
                         also note that viewpoint image names are multiple, and each are variations on the original filename.
                         attempted invocations follow.
                    <targetfiles>
                        <pathelement path="${archive.path}/${relative.path1}/${relative.path2}/_viewpoints/${name.short}.x3d.*.png"/>
                    </targetfiles>
                    or
                    <mapper dir="." type="glob" from="*.x3d" to="_viewpoints/*.png"/>
                    -->
                    <sequential>
                        <!-- process individual files here.  show full path to facilitate user loading, editing of reported files -->
                        <echo>${archive.path}/${relative.path1}/${relative.path2}/${name.short}.x3d processing with Xj3D -captureViewpoints</echo>
                        <mkdir dir="${relative.path1}/${relative.path2}/_viewpoints"/>

                        <echo>[java jvmarg -Djava.library.path=${xj3d.dir}/../${native.library.path}]</echo>
                        <java classname="xj3d.browser.Xj3DBrowser" fork="${fork}" dir=".">
                            <classpath>
                                <pathelement path="${classpath}"/>
                                <fileset refid="xj3d.jars.all"/>
                            </classpath>
                            <!-- -Djava.library.path needs to point to jogl.dll driver -->
                            <jvmarg value="-Djava.library.path=${xj3d.dir}/../${native.library.path}"/>
                            <arg value="-captureViewpoints"/>
                            <arg value="${relative.path1}/${relative.path2}/${name.short}.x3d"/>
                        </java>

                        <!-- Xj3D leaves images in same directory as file, rather than launch directory, and so move them to _viewpoints directory.  -->
                        <move todir="${relative.path1}/${relative.path2}/_viewpoints" verbose="true">
                                <fileset dir="${relative.path1}/${relative.path2}">
                                    <include name="${name.short}.x3d.*.png"/>
                                </fileset>
                        </move>
                    </sequential>
                </outofdate>
            </sequential>
        </for>
            </then>
            <else>
                <echo message="No viewpoint capture when run on jenkins server"/>
            </else>
        </if>
        <echo>processScenes.captureViewpointImages complete.</echo>
    </target>

    <target name="canonicalScenesX3dToXml" description="save each canonicalized filename.x3d as filenameCanonical.xml">
        <for param="filenames">
            <path>
                <fileset dir="." includes="**/*Canonical.x3d"/>
            </path>
            <sequential>
                <propertyregex
                    property="filename.prefix"
                    override="true"
                    input="@{filenames}"
                    regexp="([^\\]*\\){6}([^\n]*)Canonical\.x3d"
                    select="\2"/>
                <echo>Moving ${filename.prefix}Canonical.x3d to ${filename.prefix}Canonical.xml</echo>
                <move file="${filename.prefix}Canonical.x3d" tofile="${filename.prefix}Canonical.xml"/>
            </sequential>
        </for>
        <echo>canonicalScenesX3dToXml complete.</echo>
    </target>

    <target name="processScenes.canonicalX3D" description="generate canonical X3D form" depends="clean.duplicates">
        <!-- TODO:  XMLUnit test comparing Filename.x3d to FilenameCanonical.xml -->
        <!-- <echo message="TODO verify Apache XML Catalog resolver classpath: ${resolver.dir}/resolver.jar (${resolver.jar.length} bytes)"/> -->
        <for param="file.path.name">
            <path>
                <fileset refid="x3dScenes"/>
            </path>
            <sequential>
                <propertyregex
                        property="name.short"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path1"
                        override="true"
                        input="@{file.path.name}"
                        regexp="([^\n]*)_archiveName_[\\/]([^\n^\\^/]*)[\\/]([^\n]*)\.x3d"
                        select="\2"/>
                <propertyregex
                        property="relative.path2"
                        override="true"
                        input="@{file.path.name}"
                        regexp="_regexp2_"
                        select="\3"/>
                <!-- trace
                <echo></echo>
                <echo>@file.path.name       = @{file.path.name}</echo>
                <echo>$archive.path         = ${archive.path}</echo>
                <echo>$relative.path1       = ${relative.path1}</echo>
                <echo>$relative.path2       = ${relative.path2}</echo>
                <echo>$name.short           = ${name.short}</echo>
                -->
                <outofdate>
                    <sourcefiles>
                        <filelist>
                            <file name="@{file.path.name}"/>
                        </filelist>
                    </sourcefiles>
                    <mapper dir="." type="glob" from="*.x3d" to="*Canonical.xml"/>
                    <sequential>
                        <copy file="@{file.path.name}" toFile="${relative.path1}/${relative.path2}/${name.short}Canonical.xml"/> <!-- verbose="true" -->
                        <!-- process individual files here.  show full path to facilitate user loading, editing of reported files. -->
                        <echo>@{file.path.name} processed by org.web3d.x3d.tools.x3db.X3dCanonicalizer:</echo>
                        <!-- canonicalX3D is locally defined macro -->
                        <canonicalX3D scene="${relative.path1}/${relative.path2}/${name.short}"/>
                        <!-- check XML header and DOCTYPE -->
                        <echo message="X3dDoctypeChecker ${relative.path1}/${relative.path2}/${name.short}.x3d"/>
                        <java classname="org.web3d.x3d.tools.X3dDoctypeChecker" classpath="${c14n.dir}/${c14n.jar}">
                            <arg value="${relative.path1}/${relative.path2}/${name.short}.x3d"/>
                            <!-- <arg value="-verbose"/> -->
                        </java>
                    </sequential>
                </outofdate>
            </sequential>
        </for>
        <echo>processScenes.canonicalX3D complete.</echo>
    </target>
    
    <target name="X3dToXhtml.xsltNative" description="pretty print all .x3d examples as .html">
        <xslt destdir="." style="${stylesheet.dir}/X3dToXhtml.xslt" force="true">
            <include name="_subdir_/*.x3d"/>
            <mapper type="glob" from="*.x3d" to="*.html"/>
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
        </xslt>
    </target>

    <!-- warning:  xalan crashes Netbeans 5.0 completely without leaving a trace -->
    <target name="X3dToVrml97.xsltNative" description="convert all .x3d examples to .wrl">
        <xslt destdir="." style="${stylesheet.dir}/X3dToVrml97.xslt" force="true">
            <include name="_subdir_/*.x3d"/>
            <mapper type="glob" from="*.x3d" to="*.wrl"/>
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
        </xslt>
    </target>

    <!-- Xalan throws exception but then continues to completion:
         java.lang.ClassCastException: com.sun.org.apache.xalan.internal.xsltc.compiler.Variable  -->
    <target name="X3dToX3dvClassicVrmlEncoding.xsltNative" description="convert all .x3d examples to .x3dv">
        <xslt destdir="." style="${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.xslt" force="true">
            <classpath path="${cp}"/>
            <include name="_subdir_/*.x3d"/>
            <mapper type="glob" from="*.x3d" to="*.x3dv"/>
            <!-- TODO get xmlcatalog working under jenkins
            <attribute name="http://xml.org/sax/features/validation" value="true"/>
            <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
            <xmlcatalog refid="X3dCatalog"/>
            -->
        </xslt>
    </target>

    <path id="project-classpath">
        <pathelement location="."/>
        <pathelement location="${CreateContentCatalog.dir}/CreateContentCatalog.jar"/>
        <pathelement location="${log4j.dir}/${log4j.jar}"/>
        <!-- ensure system JAVA_HOME points to JDK -->
        <pathelement location="${java.home}/lib/rt.jar"/>
        <!--
            <fileset dir="${env.JWSDP_HOME}/jaxp/lib" includes="*.jar"/>
            <pathelement location="${jaxp.apis}/jaxp-api.jar"/>
            <pathelement location="${jaxp.lib}/sax.jar"/>
            <pathelement location="${jaxp.lib}/dom.jar"/>
            <pathelement location="${jaxp.lib}/xercesImpl.jar"/>
            <pathelement location="${jaxp.lib}/xalan.jar"/>
            <pathelement location="${samples.build.dir}/"/>
            -->
    </path>

    <target name="catalog" 
            depends="catalog.builder,catalog.generateHtmlPages,catalog.generateXMLSpyProject,catalog.validate"
            description="generate catalog, XMLSPY project and HTML pages">
    </target>

    <target name="catalog.builder" depends="clean.duplicates" description="generate catalog XML holding archive information by reading directories and X3D files">
        <!-- TODO: modify filenames by adding timestamp -->
        <copy todir="_archive" verbose="true" failonerror="false">
            <fileset dir=".." includes="ContentCatalog${archive.name}.xml,ContentCatalogExamples${archive.name}.spp"/>
        </copy>
        <!-- Will be overridden if called from catalog.server or jenkins -->
        <property name="catalog.local.dtd" value="-localDTD"/>
        <echo  message="catalog.builder: catalog.local.dtd=${catalog.local.dtd} CreateContentCatalog.dir=${CreateContentCatalog.dir}"/>
        <java classname="ContentCatalogBuilder" fork="no">
            <classpath refid="project-classpath"/>
            <arg value="${catalog.local.dtd}"/>
            <arg value="../${archive.name}"/>
            <arg value="${CreateContentCatalog.dir}"/>
        </java>
        <move file="ContentCatalog.xml" tofile="ContentCatalog${archive.name}.xml" overwrite="true" failonerror="false" verbose="true"/>
    </target>

    <target name="catalog.validate" description="validate catalog" unless="jenkins.prepared">
        <echo message="check well-formedness and validate ContentCatalog${archive.name}.xml"/>
        <xmlvalidate file="ContentCatalog${archive.name}.xml" failonerror="false" warn="true"/>
        <xmlvalidate file="ContentCatalog${archive.name}.xml" failonerror="true"  warn="true" lenient="yes"/>
    </target>

    <target name="catalog.generateHtmlPages" description="generate HTML pages for entire catalog">
        <echo message="check well-formedness ${CreateContentCatalog.dir}/CreateContentCatalogPages.xslt"/>
        <xmlvalidate file="${CreateContentCatalog.dir}/CreateContentCatalogPages.xslt" failonerror="true" warn="true" lenient="yes"/>

        <echo message="generate complete set of HTML pages for ${archive.name} examples archive"/>
        <!-- cd    ../examples/; pwd; $(SAXON) -t ContentCatalog.xml $(CONTENT_DRIVE)/$(CONTENT_DIR)/../tools/CreateContentCatalog/CreateContentCatalogPages.xslt -->
        <!-- TODO: Xj3D -captureViewpoint option, selectively adding corresponding links in output HTML -->
        <java classname="net.sf.saxon.Transform" classpath="${saxon.dir}/${saxon.jar};." fork="false">
            <arg value="-t"/>  <!-- timing information -->
            <arg value="-dtd:off"/> <!-- TODO problem with different relative directories while invoking under jenkins -->
            <arg value="-warnings:recover"/> <!-- recover after writing a warning message -->
            <arg value="-s:ContentCatalog${archive.name}.xml"/>
            <arg value="-xsl:${CreateContentCatalog.dir}/CreateContentCatalogPages.xslt"/>
            <!-- passed parameters, can also be locally set value in CatalogManager.properties -->
            <arg value="reduceArchiveSize=${reduceArchiveSize}"/>
            <arg value="jenkins=${jenkins.prepared}"/>
        </java>
    </target>
        
  <!-- Warning:  the next two tasks are only used on subversion servers or by other people building catalogs
         who are not under local version control for CreateContentCatalog -->
    <target name="catalog.retrieve.CreateContentCatalog.jar"
        description="retrieve CreateContentCatalog.jar from SourceForge subversion to support local build">
        <get src="http://x3d.svn.sourceforge.net/viewvc/*checkout*/x3d/www.web3d.org/x3d/tools/CreateContentCatalog/CreateContentCatalog.jar" 
             dest="${CreateContentCatalog.dir}/CreateContentCatalog.jar" ignoreerrors="${ignoreSetupDownloadErrors}"/>
        <copy toDir="${basedir}" 
              file="${CreateContentCatalog.dir}/CreateContentCatalog.jar"/>
    </target>

    <target name="catalog.server" 
            depends="catalog.retrieve.CreateContentCatalog.jar" 
            description="utility task for subversion server-side regeneration of content catalog">
       <antcall target="catalog.builder" inheritAll="true">
           <param name="catalog.local.dtd" value=""/>
       </antcall>            
    </target>

    <target name="catalog.generateXMLSpyProject" description="generate XMLSPY catalog">
        <echo message="check well-formedness ${CreateContentCatalog.dir}/ContentCatalogToXmlSpyProject.xslt"/>
        <xmlvalidate file="${CreateContentCatalog.dir}/ContentCatalogToXmlSpyProject.xslt" failonerror="true" warn="true" lenient="yes"/>
        <echo message="generate XML Spy catalog ContentCatalog${archive.name}.spp"/>
        <xslt   in="ContentCatalog${archive.name}.xml"
                out="ContentCatalog${archive.name}.spp"
                style="${CreateContentCatalog.dir}/ContentCatalogToXmlSpyProject.xslt"
                reloadstylesheet="yes" force="yes">
            <classpath path="${cp}"/>
        </xslt>
        <echo message="validate ContentCatalog${archive.name}.spp"/>
        <xmlvalidate file="ContentCatalog${archive.name}.spp" failonerror="false" warn="true" lenient="yes"/>
    </target>

    <target name="zip.reduced" description="generate .zip distribution, reduced size by omitting .x3dv and C14N .xml versions">
        <property name="reduceArchiveSize" value="true"/>
        <echo message="immutable property set:  reduceArchiveSize=${reduceArchiveSize}"/>
        <antcall target="catalog.generateHtmlPages"/>
        <antcall target="zip"/>
    </target>

    <target name="zip" depends="clean.backups" description="generate .zip distribution">
        <property name="zipFileName" value="../X3dExamples${archive.name}.zip"/>
        <echo>Building ${zipFileName} distribution</echo>
        <!-- TODO:  figure out
        <if>
            <equals arg1="${archive.name}" arg2="Savage">
                <move file="Documents and Settings/All Users/Start Menu/Programs/X3D Extensible 3D Graphics/Savage Modeling Analysis Language (SMAL) metadata.lnk"/>
                <echo message="SavageLinks found"/>
            </equals>
        </if>
        -->
        <zip destfile="${zipFileName}">
            <zipfileset dir="../.." prefix="www.web3d.org/x3d/content/">
                <include name="icons/*.*"/>
                <include name="images/x3d2-s.gif"/>
                <include name="images/web3d_logo2.png"/>
                <include name="../tools/CreateContentCatalog/ContentCatalog.dtd"/>
                <exclude name="**/*.nrrd"/>
                <exclude name="CVS/*"/>
                <exclude name=".svn/*"/>
                <exclude name="_new*.*"/>
                <exclude name="*.bak"/>
                <exclude name="Thumbs.db"/>
                <exclude name="*.$$$$$$"/>
                <exclude name="**/*.$$$$$$"/><!-- escape $ as $$ -->
                <!-- TODO:  debug _archive filters -->
                <exclude name="_archive/*"/>
                <exclude name="**/_archive"/>
                <exclude name="**/_archive/*"/>
                <exclude name="_schematron"/>
                <exclude name="**/_schematron"/>
                <exclude name="**/_schematron/*"/>
                <exclude name="hide/*"/>
                <exclude name="**/hide"/>
                <exclude name="**/hide/*"/>
                <exclude name="jenkins"/>
                <exclude name="nbproject/*"/>
                <exclude name="**/nbproject/*"/>
                <exclude name="**/CVS/*"/>
                <exclude name="**/.svn/*"/>
                <exclude name="**/_new*.*"/>
                <exclude name="**/*.bak"/>
                <exclude name="**/Thumbs.db"/>
            </zipfileset>
            <zipfileset dir="../../../../.." prefix="">
                <include name="index${archive.name}.localRedirect.html"/>
            </zipfileset>
            <zipfileset dir=".." prefix="www.web3d.org/x3d/content/examples/">
                <exclude name="index*Redirect.html"/>
                <include name="images/*.*"/>
                <include name="*.xml"/>
                <include name="Makefile"/>
                <include name="*.html"/>
                <include name="license.*"/>
                <include name="Hello*.*"/>
                <include name="earth-topo*.*"/>
                <include name="newScene.*"/>
                <include name="newHtmlPageWithX3dObject.html"/>
                <include name="newEcmascript.js"/>
                <include name="newX3dScript.java"/>
                <include name="*.x3d"/>
                <include name="*.xml"/>
                <include name="*.html"/>
                <include name="*.wrl"/>
                <include name="*.x3dv"/>
                <include name="*.gif"/>
                <include name="*.jpg"/>
                <include name="*.png"/>
                <include name="*.txt"/>
                <include name="*.pdf"/>
                <include name="*.ppt"/>
                <include name="_pages/*.html"/>
                <include name="_svg/*.svg"/>
                <exclude name="**/*.nrrd"/>
                <exclude name="CVS/*"/>
                <exclude name=".svn/*"/>
                <exclude name="_new*.*"/>
                <exclude name="*.bak"/>
                <exclude name="Thumbs.db"/>
                <exclude name="*.$$$$$$"/>
                <exclude name="**/*.$$$$$$"/><!-- escape $ as $$ -->
                <exclude name="_archive/*"/>
                <exclude name="**/_archive"/>
                <exclude name="**/_archive/*"/>
                <exclude name="_schematron"/>
                <exclude name="**/_schematron"/>
                <exclude name="**/_schematron/*"/>
                <exclude name="hide/*"/>
                <exclude name="**/hide"/>
                <exclude name="**/hide/*"/>
                <exclude name="jenkins"/>
                <exclude name="nbproject/*"/>
                <exclude name="**/nbproject/*"/>
                <exclude name="**/CVS/*"/>
                <exclude name="**/.svn/*"/>
                <exclude name="**/_new*.*"/>
                <exclude name="**/*.bak"/>
                <exclude name="**/Thumbs.db"/>
                <exclude name="Savage/SoundEffects/SavageSoundReadme.html"/>
            </zipfileset>
            <!-- windows shortcuts for this archive, no longer included
            <zipfileset dir="../../../../..">
                <include name="Documents and Settings/All Users/Start Menu/Programs/X3D Extensible 3D Graphics/X3D Examples/${archive.name} examples.lnk"/>
                <include name="WINDOWS/Start Menu/Programs/X3D Extensible 3D Graphics/X3D Examples/${archive.name} examples.lnk"/>
                <include name="WINDOWS/Profiles/All Users/Start Menu/Programs/X3D Extensible 3D Graphics/X3D Examples/${archive.name} examples.lnk"/>
                <include name="WINNT/Profiles/All Users/Start Menu/Programs/X3D Extensible 3D Graphics/X3D Examples/${archive.name} examples.lnk"/>
            </zipfileset>
            -->
            <zipfileset dir="." prefix="www.web3d.org/x3d/content/examples/${archive.name}/">
                <include name="*.xml"/>
                <include name="*.spp"/>
                <include name="Makefile"/>
                <include name="*.html"/>
                <include name="license.*"/>
                <include name="Hello*.*"/>
                <include name="earth-topo*.*"/>
                <include name="newScene.*"/>
                <include name="*/**"/> <!-- all subdirectories -->
                <!-- intermediate directories on 2-level archives hold nothing but directories, no files to match -->
                <include          name="*.x3d"/>
                <include name="_subdir_/*.x3d"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.js"/>
                <include name="_subdir_/*.js"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.xml"/>
                <include name="_subdir_/*.xml"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.dtd"/>
                <include name="_subdir_/*.dtd"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.xsd"/>
                <include name="_subdir_/*.xsd"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.html"/>
                <include name="_subdir_/*.html"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.wrl"/>
                <include name="_subdir_/*.wrl"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.x3dv"/>
                <include name="_subdir_/*.x3dv"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.gif"/>
                <include name="_subdir_/*.gif"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.jpg"/>
                <include name="_subdir_/*.jpg"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.png"/>
                <include name="_subdir_/*.png"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.txt"/>
                <include name="_subdir_/*.txt"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.pdf"/>
                <include name="_subdir_/*.pdf"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.ppt"/>
                <include name="_subdir_/*.ppt"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.mpg"/>
                <include name="_subdir_/*.mpg"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.mpeg"/>
                <include name="_subdir_/*.mpeg"/><!-- ${numberOfSections} level down only -->
                <include          name="*.xls"/>
                <include name="_subdir_/*.xls"/><!-- ${numberOfSections} level down only -->
                <include          name="*.wmv"/>
                <include name="_subdir_/*.wmv"/> <!-- ${numberOfSections} level down only -->
                <include          name="*.au"/>
                <include name="_subdir_/*.au"/>  <!-- ${numberOfSections} level down only -->
                <!-- autogenerated html-catalog content -->
                <include name="_pages/*.html"/>
                <include   name="*/_pages/*.html"/>
                <include name="*/*/_pages/*.html"/>
                <include     name="_svg/*.svg"/>
                <include   name="*/_svg/*.svg"/>
                <include name="*/*/_svg/*.svg"/>
                <exclude name="**/*.nrrd"/>
                <exclude name="_new*.*"/>
                <exclude name="*.bak"/>
                <exclude name="Thumbs.db"/>
                <exclude name="*.$$$$$$"/>
                <exclude name="**/*.$$$$$$"/><!-- escape $ as $$ -->
                <exclude name="_archive/*"/>
                <exclude name="**/_archive"/>
                <exclude name="**/_archive/*"/>
                <exclude name="_schematron"/>
                <exclude name="**/_schematron"/>
                <exclude name="**/_schematron/*"/>
                <exclude name="jenkins"/>
                <exclude name="nbproject/*"/>
                <exclude name="**/nbproject/*"/>
                <exclude name="CVS/*"/>
                <exclude name="**/CVS/*"/>
                <exclude name=".svn/*"/>
                <exclude name="**/.svn/*"/>
                <exclude name="**/_new*.*"/>
                <exclude name="**/*.bak"/>
                <exclude name="**/Thumbs.db"/>
                <exclude name="SoundEffects/**/*.*"/><!-- Savage archive -->
            </zipfileset>
        </zip>
        <length property="archive.zip.length" file="${zipFileName}"/>
        <echo>${zipFileName} (${archive.zip.length} bytes) complete</echo>
    </target>

    <!-- TODO:  targets for timestamp, makeWindowsShortcuts, others from Makefile -->

    <!--
    <path id="classpath">
        <fileset dir="${saxon.dir}" includes="*.jar"/>
    </path>
    <property name="cp" location="${classpath}"/>
    <target name="newScene.error" description="Copy newScene.x3d example from common example archives and convert to other encodings.  Warning:  does not override Xalan in Netbeans and fails.">
        <echo>xslt classpath=${cp}</echo>
        <delete>
            <fileset dir="." includes="newScene.*"/>
        </delete>
        <copy todir=".">
            <fileset dir=".." includes="newScene.x3d"/>
        </copy>
        <xmlvalidate file="newScene.x3d" failonerror="true" warn="true"/>
        <xslt in="newScene.x3d" out="newScene.html" style="${stylesheet.dir}/X3dToXhtml.xslt"  reloadstylesheet="yes">
                <classpath path="${cp}"/>
        </xslt>
        <xslt in="newScene.x3d" out="newScene.wrl"  style="${stylesheet.dir}/X3dToVrml97.xslt" reloadstylesheet="yes">
                <classpath path="${cp}"/>
        </xslt>
        <xslt in="newScene.x3d" out="newScene.x3dv" style="${stylesheet.dir}/X3dToX3dvClassicVrmlEncoding.xslt" reloadstylesheet="yes" basedir="." processor="trax" destdir=".">
                <classpath path="${saxon.dir}/${saxon.jar}"/>
        </xslt>
    </target>
-->

</project>

