oXygen XML Editor

1. Variables. More correctly 'properties' as ant calls them

This document uses variables to refer to the location of the various files and sets of files, e.g. $stylesheets holds the absolute path to the XSLT stylesheets. If I need more than one version of them, I use $ns-stylesheets for the namespaced ones etc. Others might be $stylesheets.175 for a specific version. The problem with this is in remembering which set is in use when I copy a build file over from one document set to use with a new one. I'm currently looking at automatically generating a test file which terminates the build if a property (variable) which is used, is not defined.

[Note]Note

Using ant, all these variables can be stored 'outside' the main ant script, hence have that single level of indirection which keeps them in one place! The syntax to check that a property is actually defined is

<property name="prop.message" value="must be defined, preferably in ${basedir}/${properties.file}!"/>
  <fail message="VariableName ${prop.message}" unless="VariableName"/>

This will cause the build to terminate unless 'VariableName' is defined, allowing you to correct the error. If you don't, mysteriously named files are liable to appear!

I've included a couple of scripts to check on this. One a Python file to check the properties file, the second an XSLT 2.0 stylesheet to check on variables used in build.xml. Both included in the zip file (See Chapter 6

This introduces two files which contain standard ant property definitions yet has them external to the main ant build file which both keeps them in one place and sets them up for re-use in another project. For this to work, only the generic variables should be kept in the 'global' file, variables particular to a specific build being kept within the main build file.

See javarannch for a warning on going overboard with properties files.

See sun.com for a 'syntax' definition (although it's not very clear IMHO). Just watch out for white space on the end of a line... or on the beginning for that matter! Comments start with # in column 1

[Note]Note

ant always uses the first definition of a property and ignores any attempt to change a property using a later definition, you can declare some default properties in build.properties.sh and override them with project specific properties simply by the order in which you state them.

This is the actual build file containing the variables build.properties.sh. Note that this is now shared with the bash version of the build script, i.e. it is referenced from ant as well as bash!


 #properties file for generic docbook ant script.
#Avoids all build specific values!

#Version 1.0
#Date    2009-05-17T06:30:00Z
#Author  Dave Pawson


#Version 1.1
#Date: 2009-05-28T07:37:24Z
#Author Dave Pawson
# Adopted for use with ant as well, for common defs


TODAY_UK=
fintim=




# docbook location: Everything taken relative to this for docbook stuff 
docbook=/sgml/docbook
# Main stylesheets 
stylesheets=${docbook}/docbook-xsl-ns
html_stylesheets=${stylesheets}/html
fo_stylesheets=${stylesheets}/fo
 
# Main Docbook stylesheet is imported via my customization layer 
# (docbook.html.xsl) 

html_stylesheet=docbook.html.xsl


# saxon extensions which come with docbook
dbsaxonextensions=${stylesheets}/extensions/saxon65.jar

# Docbook v5 Schema 
db_schema_rng=$docbook/v5/rng/docbookxi.rng
my_schema_rng=poem.rng  

#
# Working files, used for zip and upload, see ${zip_file_list}
#
#
#
docbook_html_xsl=docbook.html.xsl
poem_rng=poem.rng
docbook_fo_xsl=docbook.fo.xsl
listimages_sh_xsl=listimages.sh.xsl
dpawson_css=dpawson.css
build_properties=build.properties
build_properties_sh=build.properties.sh
build_sh=build.sh
build_xml=build.xml
cp_images_sh=cp.images.sh
docbook_html_xsl=docbook.html.xsl
listimages_sh_xsl=listimages.sh.xsl
listimages_stylesheet=listimages.xsl
imagelist_anttask=copyimages.xml
test_docbook_xml=test.docbook.xml
testvars_xsl=testvars.xsl
testprops_xsl=testprops.xsl
antvars_py=antvars.py
antvars_sh_py=antvars.sh.py
example_catalog=db5.catalog.xml
catalog_manager=CatalogManager.properties


# Input properties:    

basedir=`pwd`
                                    
# all xml files should be in this directry
in_dir=${basedir}
     


# source file for doLayout target 
autolayout_infile=newlayout.xml         
# source file for website transform on second pass  
website_infile=autolayout.xml


# Output Properties: Output directory    
out_dir=${basedir}

                      
out_html_dir=${out_dir}/html
# Main output file used for docbook html transform 
main_outfile=${infile_basename}.html  
            
# fo output 
out_pdf_dir=${out_dir}/pdf
out_pdf_dir=${out_dir}/pdf
main_fo_stylesheet=${in_dir}/docbook.fo.xsl
main_fo_outfile=test.fo

#pdf output
main_pdf_outfile=${infile_basename}.pdf    
     

# global Styles directory, on disk and on website
global_styles=/styles

#local graphics source
local_graphics_src=${in_dir}/graphics

#local graphics target - html
local_graphics_html_tgt=${out_html_dir}/graphics

#local graphics target - pdf
local_graphics_pdf_tgt=${out_pdf_dir}/graphics




# task to copy images to local target

#XSLT stylesheet used to generate copy command (html and fo)
listimages_sh_stylesheet=listimages.sh.xsl


# copy command - used for both html and fo
copy_cmd=cp.images.sh


#CSS stylesheet
css_stylesheet=dpawson.css



# Java locations 

java=/myjava

# zip file build target directory
zip_src_directory=${out_dir}/upload
# zip filename - define in bash.sh or build.xml




# Post XSLT transform parameter. Leave as is for Saxon 
param_args_post="saxon.extensions=1" 


# XSLT  properties 
xslt1_processor=com.icl.saxon.StyleSheet
xslt2_processor=net.sf.saxon.Transform
xslt1_jar=saxon655.jar
xslt2_jar=saxon9.jar


# xsl-fo processing 
fo_processor_class=com.renderx.xep.XSLDriver
xephome=$java/xep




# Catalog resolver 
resolver_jar=resolver.jar
xmlcatalog=/sgml/catalog.xml


# XML parser 
xerces_jar=xerces.jar
xerces_impl_jar=xercesImpl.jar
xml_apis_jar=xml-api
#xerces api
xerces_api_jar=xml-apis.jar

#xinclude processor
xmllint=/usr/bin/xmllint

# Temporary xincluded file
xincluded_file=tmp.xml

#Jing parser
jing_jar=jing.jar



#zip file list of required files
zip_file_list="${docbook_html_xsl}  ${poem_rng}  ${docbook_fo_xsl}  \
${listimages_sh_xsl}  ${dpawson_css}  ${xmlcatalog}   \
${build_properties_sh}  ${build_sh}  ${build_xml}  ${cp_images_sh}  \
${docbook_html_xsl}  ${listimages_sh_xsl}  ${listimages_stylesheet}  \
${test_docbook_xml} ${antvars_py} ${antvars_sh_py} ${testvars_xsl} \
${example_catalog} ${catalog_manager}"

# local directory for uploading
uploaddir=${basedir}/upload


#classpath for Jing, relax NG validator from James Clark
jing_classpath=${java}/jing.jar:${java}/${xslt1_jar}:$java/${xerces_jar}:\
$java/${xerces_api_jar}

# xslt 1 class
xslt1_processor_class=com.icl.saxon.StyleSheet
xslt2_processor=net.sf.saxon.Transform

# path for xslt processor. 
#Includes resolver and extensions and catalogManager.properties file. 
xslt1_processor_classpath=\
${java}/${xslt1_jar}:\
${java}/${resolver_jar}:\
${java}/${xerces_jar}:\
${java}/${xerces_impl_jar}\
${java}/${xml_apis_jar}\
${dbsaxonextensions}:\
/sgml




 

# path for xslt 2.processor. 
#Includes resolver and extensions and catalogManager.properties file.  -->
xslt2_processor_classpath=$java/saxon9.jar:$java/resolver.jar:\
${dbsaxonextensions}:$java/xercesImpl.jar:/sgml:.





#Location of the XML catalog, see 
#http://www.asios-open.org/committees/entity/spec-2001-08-06.html
catalogpath=$xmlcatalog
 

# Paths for xsl-fo processing
fo_processor_classpath=/usr/java/default/lib/tools.jar:\
$java/xep/lib/xep.jar:$xephome/lib/saxon.jar:$xephome/lib/xt.jar 

I'm hoping my naming conventions will make it clear just what is being described. What I found disappointing is that ant and bash don't support the same use of variable names; in ant I was using a.b.c which bash doesn't support! Hence for bash the variables are renamed a_b_c. Ah well. If it itches enough, I'll scratch it. It did. As of late May 09 I now share a common file, build.properties.sh between the bash build and the ant build.

Moving on.