DITAblogs (processing)

Ant script used to build this document

To produce this document we used an Ant build script containing targets for building all transformation types (often called "transtypes" or "targets") supported by DITA Open Toolkit. The location of the Toolkit, the location of the source files, and the location of the output files are variables that can be changed. Here is our script:

<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) Copyright VR Communications, Inc. All rights reserved. -->
<!-- Ant script for the DITA Open Toolkit User Guide (DITAOTUG) -->
<!-- Depending on the argument passed to the script at runtime, 
this script processed to one (example: dita2xhtml), multiple, or all output targets. -->
<!-- This is a "user script," meant to be modified.
However, be cautious in modifying the environment initialization section. -->

<!-- -->
<!-- ENVIRONMENT INITIALIZATION SECTION -->
<!-- -->

<!-- The project name is toolkitug. The default output target is xhtml. -->
<project name="toolkitug" default="xhtml">
<!-- This message is echoed to the screen at the beginning of the build process. -->
<echo>Building DITA Open Toolkit User Guide.</echo>
<!-- Allow the build process access to environment variables -->
<property environment="env"/>
<!-- Set toolkit directory from environment variable -->
<property name="toolkit_dir" value="${env.DITA_DIR}"/>
<!-- Note: basedir may be set in a higher-level script that invokes this one.
Some plug-ins depend on its pointing to the Toolkit directory.  
In particular, the Idiom plug-in, which is required for PDF2 processing, requires it. -->
<property name="basedir" value="${env.DITA_DIR}"/>
<!-- Define the location of the project (source file) directory.
In this case, the project directory is up two directory levels from the location of this file. -->
<property name="projdir" value="${ant.file}/../.."/>
<!-- Define the location of the output directory.
In this case, it is a directory directly above the project (source file) directory. -->
<property name="outdir" value="${projdir}/../DITAOTUG_OUTPUT"/>
<property name="PHPexe" value="C:/wamp/php/php.exe"/>
<property name="args.logdir" value="${outdir}"/>
<!-- Set the name of the (master) ditamap -->
<property name="MAP_file" value="DITAOTUG.ditamap"/>
<!-- Set the extension string for the dita files (files can also be .xml) -->
<property name="EXTNAME" value=".dita"/>
<!-- File for using otherprops filtering for non-pdf output -->
<property name="ditaval_nonpdf" value="${projdir}/ditaval_files/otherprops_filtering.ditaval"/>
<!-- Define the path to the Java code -->
<path id="dost.class.path">
<pathelement location="${toolkit_dir}${file.separator}lib${file.separator}dost.jar"/>
</path>
<!-- Define the Ant targets and initialize the processing environment -->
<taskdef name="integrate" classname="org.dita.dost.platform.IntegratorTask">
<classpath refid="dost.class.path"/>
</taskdef>
<!-- Create the default XHTML output and debug cross-reference -->
<target name="xhtml" depends="integrate, ditadebug, ditalinks, dita2xhtml">
</target>
<target name="integrate">
<integrate ditadir="${toolkit_dir}"/>
</target>

<!-- -->
<!-- BEGIN INSTANCE PROCESSING SECTION -->
<!-- -->

<!-- Names of the output types this script is capable of producing -->
<!-- The target names are somewhat arbitrary. The following are traditional,
and they allude to the source and target (for example, dita2xhtml). -->
<target name="alltargets" depends="integrate, dita2xhtml, dita2htmlhelp, 
dita2troff, dita2docbook, dita2javahelp, dita2wordrtf, dita2eclipsecontent,
dita2eclipsehelp, dita2pdf2">
</target>

<!-- Handy abbreviation (all) for alltargets -->
<target name="all" depends="allreports, alltargets"/>

<!-- Create all reports -->
<target name="allreports" depends="ditadebug, ditalinks, ditaauthors, ditaids, ditakeys"/>

<!-- Create the ditamap debug cross-reference -->
<target name="ditadebug">
<echo>Building debugging cross-reference file ditadebug.txt</echo>
<mkdir dir="${outdir}/debug_files"/>
<exec executable="${PHPexe}" dir="${projdir}" output="${outdir}/debug_files/ditadebug.txt">
<arg value="${projdir}/project/tools/ditadebug.php"/>
<arg value="${MAP_file}"/>
</exec>
</target>

<!-- Create plausible preview -->
<target name="preview">
<echo>Building XHTML plausible preview</echo>
<mkdir dir="${outdir}/debug_files"/>
<exec executable="${PHPexe}" dir="${projdir}" output="${outdir}/debug_files/ditapreview.txt">
<arg value="${projdir}/project/tools/ditapreview.php"/>
<arg value="${MAP_file}"/>
<arg value="L"/>
</exec>
</target>

<!-- Create the ditamap URL check -->
<target name="ditalinks">
<echo>Building URL check file ditalinks.txt</echo>
<mkdir dir="${outdir}/debug_files"/>
<exec executable="${PHPexe}" dir="${projdir}" output="${outdir}/debug_files/ditalinks.txt">
<arg value="${projdir}/project/tools/ditalinks.php"/>
<arg value="${MAP_file}"/>
</exec>
</target>

<!-- Create the ditamap author and copyright statistics -->
<target name="ditaauthors">
<echo>Building author/copyright file ditaauth.txt</echo>
<mkdir dir="${outdir}/debug_files"/>
<exec executable="${PHPexe}" dir="${projdir}" output="${outdir}/debug_files/ditaauthors.txt">
<arg value="${projdir}/project/tools/ditaauthors.php"/>
<arg value="${MAP_file}"/>
</exec>
</target>

<!-- Create the ditamap ID listing  -->
<target name="ditaids">
<echo>Building ID list file ditaids.txt</echo>
<mkdir dir="${outdir}/debug_files"/>
<exec executable="${PHPexe}" dir="${projdir}" output="${outdir}/debug_files/ditaids.txt">
<arg value="${projdir}/project/tools/ditaids.php"/>
<arg value="${MAP_file}"/>
</exec>
</target>

<!-- Create the ditamap keyword metadata statistics -->
<target name="ditakeys">
<echo>Building keyword metadata file ditakeys.txt</echo>
<mkdir dir="${outdir}/debug_files"/>
<exec executable="${PHPexe}" dir="${projdir}" output="${outdir}/debug_files/ditakeys.txt">
<arg value="${projdir}/project/tools/ditakeys.php"/>
<arg value="${MAP_file}"/>
</exec>
</target>

<!-- Create xhtml output -->
<target name="dita2xhtml">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/xhtml"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="xhtml"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="no"/>
<property name="args.css" value="${projdir}/css_files/DITAOTUG_CSS.css"/>
<property name="args.csspath" value="CSS"/>
<property name="args.copycss" value="yes"/>
<property name="args.xhtml.toc" value="toc"/>
<property name="dita.extname" value="${EXTNAME}"/>
<property name="dita.input.valfile" value="${ditaval_nonpdf}"/>
</ant>
<!-- Copy index.html to the output directory -->
<copy todir="${outdir}/xhtml">
<fileset dir="${projdir}/build_files"/>
</copy>
</target>

<!-- Create htmlhelp output -->
<target name="dita2htmlhelp">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/htmlhelp"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="htmlhelp"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="args.css" value="${projdir}/css_files/DITAOTUG_CSS.css"/>
<property name="args.csspath" value="CSS"/>
<property name="args.copycss" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
<property name="dita.input.valfile" value="${ditaval_nonpdf}"/>
</ant>
</target>

<!-- Create tocjs output -->
<target name="dita2tocjs">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/tocjs"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="tocjs"/>
<property name="clean.temp" value="no"/>
<property name="args.css" value="${projdir}/css_files/DITAOTUG_CSS.css"/>
<property name="args.csspath" value="CSS"/>
<property name="args.copycss" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
<property name="dita.input.valfile" value="${ditaval_nonpdf}"/>
</ant>
</target>

<!-- Create pdf output -->
<target name="dita2pdf">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/pdf"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="pdf"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<!-- <property name="args.xsl" value="${toolkit_dir}/xsl/xdita2fo-shell.xsl"/> -->
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
	
<!-- Create docbook output -->
<target name="dita2docbook">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/docbook"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="docbook"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
	
<!-- Create javahelp output -->
<target name="dita2javahelp">
<property name="jarfile" value="${outdir}/javahelp/DITAOTUG.jar"/>
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/javahelp"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="javahelp"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
<property name="dita.input.valfile" value="${ditaval_nonpdf}"/>
</ant>
<delete file="${jarfile}"/>
<jar destfile="${jarfile}" basedir="${outdir}/javahelp" includes="**">
</jar>
</target>
	
<!-- Create troff output -->
<target name="dita2troff">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/troff"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="troff"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
	
<!-- Create wordrtf output -->
<target name="dita2wordrtf">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/wordrtf"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="wordrtf"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
	
<!-- Create eclipsecontent output -->
<target name="dita2eclipsecontent">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/eclipsecontent"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="eclipsecontent"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
	
<!-- Create eclipsehelp output -->
<target name="dita2eclipsehelp">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/ditaug_top_1.0"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="eclipsehelp"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
	
<!-- Create FrameMaker Adapter output -->
<target name="dita2fmxml">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/fmxml"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="fmxml"/>
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
	
<!-- Create Idiom FO output -->
<target name="dita2pdf2">
<ant antfile="${toolkit_dir}${file.separator}conductor.xml" target="init">
<property name="args.input" value="${projdir}/${MAP_file}"/>
<property name="output.dir" value="${outdir}/pdf2"/>
<property name="dita.temp.dir" value="${outdir}/temp"/>
<property name="transtype" value="pdf2"/>
<property name="args.draft" value="yes"/>
<property name="args.indexshow" value="yes"/>
<property name="dita.extname" value="${EXTNAME}"/>
</ant>
</target>
</project>
			

In the Windows operating environment we built to all transtypes to make sure they would build cleanly. On Linux, we tested XHTML output only.

We use a Windows batch file (runbuild.bat) to initiate the build. The batch file calls the DITA Ant logger that types a summary of build progress on the console (rather than a more verbose set of messages) and uses a log file to capture the details. Here is our batch file:

ant -Dbasedir=%DITA_DIR% -f ant_scripts\DITAOTUG_all.xml -logger org.dita.dost.log.DITAOTBuildLogger %1
            

This method gives us enough information on the console screen to tell whether or not the build was successful and whether any errors occurred that need immediate attention.