4.3. ant properties

In order to keep the build file flexible (being lazy again, it would be nice to be able to use this build file for other Websites without too much change) a number of properties are used. Example 8 shows this section of the build file

Example 8. build.xml properties

<!-- 
This is the ant build file for use with Norm Walsh Website DTD and stylesheets
Revision: 1.2
Date    : 2008-02-06T13:09:16Z
Author  : DaveP
Updated to work with ant 1.7.0 and the resolver from Apache              1
 -->

 <!-- Set the base directory to the location of the xml files -->
<project 
     name="mywebsite"   
     basedir="/2008/files/mywebsite"              
     default="help">                        
  <description>Build Docbook  Website </description>
 
 <!-- Docbook location: 
    Everything taken relative to this for Docbook stuff -->
 <property name="docbookHome" value="/sgml/docbook"/>             2
 <!--  stylesheet location-->
 <property name="sSheetHome" value="${docbookHome}"/>      
 <!-- Website DTD and stylesheets -->
<property name="websiteHome" value="${docbookHome}/website"/>     3


 
<!-- Stylesheet to use for Website processing. Normally as below
<property name="website.stylesheet" 
   value="${websiteHome}/xsl/chunk-website.xsl"/>                    4
 I added customization, so I call this via an import  -->
<property name="website.stylesheet" value="mywebsite.xsl"/>          


 <!-- Stylesheet to use for layout file -->
<property name="autolayout.stylesheet" 
   value="${websiteHome}/xsl/autolayout.xsl"/>                       5

              
<!-- Input properties:  -->                                      
<!-- all files should be in this directry-->
<property name="in.dir" value="${basedir}"/>                     6                  

<!-- source file for layout target -->
<property name="autolayout.infile" value="layout.xml"/>          7
                
<!-- source file for Website transform on second pass --> 
<property name="website.infile" value="autolayout.xml"/>         8

           
<!-- Output Properties: Output directory -->  
 <property name="out.dir" value="${in.dir}/html" />              9
           <!-- all input files -->          

 <!-- Null (dummy)output file for Website transform -->
 <property name="website.outfile" value="op.html"/>   
 <!-- output file for Website first pass, layout -->
 <property name="autolayout.outfile" value="autolayout.xml"/>    10

  <!-- Post XSLT transform parameter. Leave as is for Saxon -->
 <property name="param.args.post" value="saxon.extensions=1"/>   11



    <!-- XSLT engine class -->
 <property name="xslt.processor.class" value="com.icl.saxon.StyleSheet" />
 <!-- path for xslt processor. 
     Includes resolver and extensions and catalogManager.properties file.  -->

 <path id="xslt.processor.classpath">                             12            
    <pathelement path="/myjava/saxon655.jar" />  <!-- Saxon jar -->
    <pathelement path="/myjava/resolver.jar"/> <!-- resolver jar -->
    <pathelement 
    path="${websiteHome}/extensions/saxon64.jar"/> 
          <!-- docbook extensions -->
  <pathelement path="/sgml"/> <!-- for catalogManager.properties -->   13 
 </path>

 <!-- Use latest javac -->
  <property name="build.compiler" value="modern"/>                           
  

1

Header information - reminds me which version I'm dealing with

2

Where to find Docbook in general

3

Where to find Website

4

Which file to use for the phase 2 build, commented out here, since I use a customization layer which imports this file (mywebsite.xsl)

5

Stylesheet to use for phase 1 (starts to use the previously defined properties)

6

Where to find the xml input files!

7

What is the phase 1 input file called

8

What is the phase 2 input file called

9

Where to put all output files

10

The output filename for the first task, layout

11

A parameter to pass to the xslt processor. Needed for Website

12

Select your xslt processor!

13

Where to find the resolver file (more later)


Yes, I agree, that is quite a list of properties. Quite possibly too many. What it does do is allow the flexibility to define something somewhere and use it later, knowing that things won't break! The general usage is:

The ${..} format is the way to replace the name (in braces), with its value as previously defined. Once that is clear, properties become easy to use.

The next step is to look at the first task. But only if you're interested.