# Ant tasks and scripts

This topic describes detailed Ant tasks and scripts.

The build process including pre-process can be called by using an Ant script. The most important Ant scrip file is called build.xml, it defines and combines common pre-processing and output transformation routines, as well as extension points that allow DITA-OT Plug-ins to add to this common processing.

## Sample ant script

These ant scripts are in samples/ant_sample directory. They are simple and easy to learn. From these files, you can learn how to write your own Ant script to build your own process.

Here is a sample template for writing an Ant script that executes transformation to XHTML in samples/ant_samples directory:

    <?xml version="1.0" encoding="UTF-8" ?>
    <project name="@PROJECT.NAME@_xhtml" default="@DELIVERABLE.NAME@2xhtml" basedir=".">

      <property name="dita.dir" location="${basedir}/../.."/>

      <target name="@DELIVERABLE.NAME@2xhtml">
        <ant antfile="${dita.dir}${file.separator}build.xml">
          <!-- please refer to the toolkit's document for supported parameters, and
               specify them base on your needs -->
          <property name="args.input" location="@DITA.INPUT@"/>
          <property name="output.dir" location="@OUTPUT.DIR@"/>
          <property name="transtype" value="xhtml"/>
        </ant>
      </target>

    </project>

To use this template, modify the following items:

- Replace `@PROJECT.NAME@` with the name of your project, such as "MyDocs".
- Replace `@DELIVERABLE.NAME@` with the name of your deliverable, such as "installDocs".
- Replace `@DITA.INPUT@` with the name of your input file (using either a full path or a relative path from the location of this template).
- Replace `@OUTPUT.DIR@` with the desired output directory (using either a full path or a relative path from the location of this template).

Once you have updated these items, you can run your build with the following command:

    ant -f samples/ant_sample/template_xhtml.xml

The build will convert your input file to XHTML. Note that the build directly calls the Ant script build.xml, which is a common entry point for DITA-OT builds; it in turn imports all of the scripts mentioned above.

Parent topic: Running DITA-OT from Ant
Related reference
Ant argument properties for DITA-OT