source: trunk/lib/docbook/ant-build-docbook.xml @ 3346

Last change on this file since 3346 was 3346, checked in by Nicklas Nordborg, 14 years ago

Updated docbook PDF generation to use FOP 0.93 instead of 0.20

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 30.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8" ?>
2
3<project name="Docbook styler module for ANT" default="help" basedir=".">
4  <property name="undefined"               value="__UNDEFINED__VALUE__" />
5
6  <!-- ## (DW 20040307) Added explicit property 'ant.docbook.styler.dir'. This
7       will be autoinitialized by default, but just in case somebody wants to
8       override the defaults...
9    -->
10  <property name="ant.docbook.styler.dir"  value="${basedir}" />
11
12  <!-- A directory where your docbook XMLs are -->
13  <property name="docbook.xml.dir"         value="${undefined}" />
14 
15  <!-- A directory where all the figures are -->
16  <property name="docbook.resources.dir"   value="${undefined}" />
17 
18  <!-- A directory for output files -->
19  <property name="distribution.dir"        location="${undefined}" />
20
21  <!-- A temp directory -->
22  <property name="build.dir"               location="${undefined}" />
23
24  <!-- Output file name for the rendered docbook file -->
25  <property name="manual.name"             value="index" />
26 
27  <!-- Start file for Docbook processing. -->
28  <property name="index.name"              value="${manual.name}" />
29 
30  <!-- Ouput file name for the docbook pdf file-->
31  <property name="pdf.name"         value="base"/>
32 
33  <property name="docbook.style"           value="plain" />
34  <property name="website.style"           value="plain" />
35
36  <!-- website rendering -->
37  <property name="website.xml.dir"         value="${undefined}" />
38
39  <!-- ## override these properties, if needed -->
40  <property name="temp:docbook.ready.file" location="${build.dir}/docbook-ready-file.tmp"/>
41  <property name="temp:fo.ready.file"      location="${build.dir}/fo-ready-file.tmp" />
42  <!-- ## (MM 20040303) moved all styles (for docbook and for website into sub-folders
43       ## of the styles folder -->
44  <property name="docbook.styles"          location="${ant.docbook.styler.dir}/custom-styles/docbook" />
45  <!-- ## (MM 20040303) added parameter for finding the styles folder for website projects -->
46  <property name="website.styles"          location="${ant.docbook.styler.dir}/custom-styles/website" />
47 
48  <!-- The version of base2 -->
49  <property name="base.version" value="${undefined}"/>
50
51  <path id="ant-extensions">
52    <fileset dir="${ant.docbook.styler.dir}/ant-extensions" includes="**/*.jar" />
53    <pathelement path="${ant.docbook.styler.dir}/ant-extensions" />
54  </path>
55
56  <!-- ##################################### -->
57  <!-- ### {{{ CHECK REQUIRED PROPS      ### -->
58  <!-- ##################################### -->
59 
60  <target name="check.required-properties">
61 
62    <condition property="tmp:ant.docbook.styler.dir" value="true">
63        <and>
64            <!-- ## (dw 20040307) check that we really point at the base directory
65                 of ant-docbook-styler -->
66            <available file="${ant.docbook.styler.dir}" type="dir" />
67            <available file="${ant.docbook.styler.dir}/custom-styles" type="dir" />
68            <available file="${ant.docbook.styler.dir}/docbook" type="dir" />
69        </and>
70    </condition>
71    <fail message="### 'ant.docbook.styler.dir' does not point at the styler's installation directory: ${ant.docbook.styler.dir}"
72        unless="tmp:ant.docbook.styler.dir"/>
73 
74    <condition property="tmp:docbook.xml.dir.ok" value="true">
75        <and>
76            <not>
77                <equals arg1="${docbook.xml.dir}" arg2="${undefined}" />
78            </not>
79            <available file="${docbook.xml.dir}" type="dir" />
80        </and>
81    </condition>
82    <fail message="### Define 'docbook.xml.dir' property pointing at Docbook XMLs folder."
83          unless="tmp:docbook.xml.dir.ok" />
84
85    <condition property="tmp:docbook.resources.dir.ok" value="true">
86        <and>
87            <not>
88                <equals arg1="${docbook.resources.dir}" arg2="${undefined}" />
89            </not>
90            <available file="${docbook.resources.dir}" type="dir" />
91        </and>
92    </condition>
93    <fail message="### Define 'docbook.resources.dir' property pointing at your resources folder."
94          unless="tmp:docbook.resources.dir.ok" />
95
96    <condition property="tmp:docbook.startfile.ok" value="true">
97        <and>
98            <available file="${docbook.xml.dir}/${index.name}.xml" type="file" />
99        </and>
100    </condition>
101    <fail message="### Cannot find root docbook file: ${docbook.xml.dir}/${index.name}.xml"
102          unless="tmp:docbook.startfile.ok" />
103
104    <condition property="tmp:docbook.build.dir.ok" value="true">
105        <and>
106            <not>
107                <equals arg1="${build.dir}" arg2="${undefined}" />
108            </not>
109            <available file="${build.dir}" type="dir" />
110        </and>
111    </condition>
112    <fail message="### Define 'build.dir' property pointing at a temporary folder (will be erased!)."
113          unless="tmp:docbook.build.dir.ok" />         
114
115    <condition property="tmp:docbook.distribution.dir.ok" value="true">
116        <and>
117            <not>
118                <equals arg1="${distribution.dir}" arg2="${undefined}" />
119            </not>
120            <available file="${distribution.dir}" type="dir" />
121        </and>
122    </condition>
123    <fail message="### Define 'distribution.dir' property pointing at your destination folder."
124          unless="tmp:docbook.distribution.dir.ok" />         
125  </target>
126
127  <target name="check.expand.zips">
128  <!--
129    <antcall target="check.expand.docbook-distribution.zip" />
130    <antcall target="check.expand.website-distribution.zip" />
131   -->
132  </target>
133 
134  <target name="check.expand.docbook-distribution.zip">
135    <condition property="tmp:docbook.available" value="true">
136        <and>
137        <available file="${ant.docbook.styler.dir}/docbook/dtd" type="dir" />
138        <available file="${ant.docbook.styler.dir}/docbook/xsl/fo" type="dir" />
139        <available file="${ant.docbook.styler.dir}/docbook/xsl/html" type="dir" />
140        <uptodate srcfile="${ant.docbook.styler.dir}/docbook/docbook.zip" 
141              targetfile="${ant.docbook.styler.dir}/docbook/docbook.zip.tstamp" />
142        </and>
143    </condition>
144    <antcall target="expand.docbook-distribution.zip" />
145  </target>
146 
147  <target name="expand.docbook-distribution.zip" unless="tmp:docbook.available">
148    <echo>
149    #####################################################
150        UNPACKING OR UPGRADING DOCBOOK DISTRIBUTION
151    #####################################################
152    </echo>
153    <delete failonerror="false" quiet="true">
154        <fileset dir="docbook">
155        <include name="dtd/**" />
156        <include name="xsl/**" />
157        </fileset>
158    </delete>
159    <unzip src="docbook/docbook.zip" dest="docbook" overwrite="true" />
160   
161    <taskdef name="LastModifiedMillis" classname="LastModifiedMillis">
162        <classpath refid="ant-extensions" />
163    </taskdef>
164
165    <LastModifiedMillis file="docbook/docbook.zip" property="millis" />
166    <touch file="docbook/docbook.zip.tstamp" millis="${millis}" />
167  </target>
168 
169  <target name="clean">
170    <delete failonerror="false" quiet="true" includeEmptyDirs="true">
171        <fileset dir="docbook">
172        <include name="dtd/**" />
173        <include name="xsl/**" />
174        </fileset>
175    </delete>
176  </target> 
177
178  <target name="check.expand.website-distribution.zip">
179    <condition property="tmp:website.available" value="true">
180        <and>
181        <available file="${ant.docbook.styler.dir}/website/schema" type="dir" />
182        <available file="${ant.docbook.styler.dir}/website/schema/dtd" type="dir" />
183        <available file="${ant.docbook.styler.dir}/website/xsl" type="dir" />
184        <uptodate srcfile="${ant.docbook.styler.dir}/website/website.zip"
185              targetfile="${ant.docbook.styler.dir}/website/website.zip.tstamp" />
186        </and>
187    </condition>
188    <antcall target="expand.website-distribution.zip" />
189  </target>
190 
191  <target name="expand.website-distribution.zip" unless="tmp:website.available">
192    <echo>
193    #####################################################
194        UNPACKING OR UPGRADING WEBSITE DISTRIBUTION
195    #####################################################
196    </echo>
197    <delete failonerror="false" quiet="true">
198        <fileset dir="website">
199        <include name="schema/**" />
200        <include name="xsl/**" />
201        </fileset>
202    </delete>
203    <unzip src="website/website.zip" dest="website" overwrite="true" />
204   
205    <taskdef name="LastModifiedMillis" classname="LastModifiedMillis">
206        <classpath refid="ant-extensions" />
207    </taskdef>
208
209    <LastModifiedMillis file="website/website.zip" property="millis" />
210    <touch file="website/website.zip.tstamp" millis="${millis}" />
211  </target>
212  <!-- }}} -->
213
214
215  <!-- ##################################### -->
216  <!-- ### {{{ PREPARE OUTPUT PATHS      ### -->
217  <!-- ##################################### -->
218
219  <target name="prepare" depends="modules.detection,check.expand.zips, check.required-properties, xsltprocessor">
220  </target>
221 
222  <target name="modules.detection">
223    <available file="${ant.docbook.styler.dir}/module-fop" type="dir"
224               property="module.fop.present" value="true" />
225               
226    <available file="${ant.docbook.styler.dir}/module-xep" type="dir"
227               property="module.xep.present" value="true" />
228    <property file="${ant.docbook.styler.dir}/module-xep/xep-config.properties" />
229
230  </target>
231
232  <!-- }}} --> 
233
234
235  <!-- ########################################################## -->
236  <!-- ### {{{ Prepare for building with docbook              ### -->
237  <!-- ########################################################## -->
238  <target name="copyResources-distribution" unless="resources.nocopy">
239    <copy todir="${distribution.dir}/css" includeemptydirs="false">
240        <fileset dir="${docbook.styles}/${docbook.style}/css"/>
241    </copy>
242    <copy todir="${distribution.dir}/gfx/admonitions" includeemptydirs="false">
243        <fileset dir="${docbook.styles}/${docbook.style}/admonitions" />
244    </copy>
245    <copy todir="${distribution.dir}/figures" includeemptydirs="false">
246        <fileset dir="${docbook.resources.dir}" includes="**/*" />
247    </copy>
248  </target>
249  <target name="copyResources-build">
250    <copy todir="${build.dir}/css" includeemptydirs="false">
251        <fileset dir="${docbook.styles}/${docbook.style}/css"/>
252    </copy>
253    <copy todir="${build.dir}/gfx/admonitions" includeemptydirs="false">
254        <fileset dir="${docbook.styles}/${docbook.style}/admonitions" />
255    </copy>
256    <copy todir="${build.dir}/figures" includeemptydirs="false">
257        <fileset dir="${docbook.resources.dir}" includes="**/*" />
258    </copy>
259  </target>
260
261  <target name="disable.resources.copy">
262    <property name="resources.nocopy" value="true" />
263  </target>
264   
265  <target name="docbook.consolidate"
266          depends="prepare, copyResources-build, copyResources-distribution, create.styler.uri">
267
268    <copy todir="${build.dir}" overwrite="true" filtering="false">
269        <fileset dir="${docbook.xml.dir}" />
270    </copy>
271
272    <property name="catalog.location" location="${ant.docbook.styler.dir}/preprocess/catalog.xml" />
273   
274    <!-- (MM 20040314) make the Java XSLT use the same catalog as the XSLTProc -->
275    <!-- works only with ant 1.6 and newer, but avoids problems when upgrading
276         from Java XSLT to XSLTProc later                                      -->
277    <xmlcatalog id="dtdcatalog">
278            <catalogpath>
279                <fileset file="${catalog.location}"/>
280            </catalogpath>
281    </xmlcatalog>
282
283    <style
284        in      = "${build.dir}/${index.name}.xml"
285        style   = "${ant.docbook.styler.dir}/preprocess/preprocess.xsl"
286        out     = "${temp:docbook.ready.file}"
287        processor = "${xslt.processor}"
288        >
289        <xmlcatalog refid="dtdcatalog"/>
290        <classpath refid="ant-extensions" />
291
292        <!-- <param name="xsltproc.option.debug"  expression="" /> -->
293        <param name="xsltproc.catalog" expression="${catalog.location}" />
294        <param name="xsltproc.option.--nonet"  expression="" />
295    </style>
296  </target>
297  <!-- }}} -->
298
299
300  <!-- ########################################################## -->
301  <!-- ### {{{ builds PDF documentation using FOP             ### -->
302  <!-- ########################################################## -->
303  <property name="module.fop.basedir" location="${ant.docbook.styler.dir}/module-fop" />
304  <target name="pdf.fop" depends="modules.detection,pdf.fop.internal">
305    <fail unless="module.fop.present">
306    ### ERROR: module for PDF FOP rendering not installed. Please download
307    it, and reinstall the styler using 'ant -f ant-build.docbook.xml install'.
308    </fail>
309  </target>
310
311  <target name="pdf.fop.internal" depends="disable.resources.copy,docbook.consolidate" if="module.fop.present">
312   
313    <!-- Get the revision number and the datetime when the latest file was commited -->
314    <svn>
315    <status path="../../doc/src/docbook" lastChangedRevisionProperty="doc.revision" />
316      <status path="../../doc/src/docbook" lastChangedDateProperty="doc.last.modified" />
317  </svn>
318
319    <copy file="${module.fop.basedir}/conf/config.xml"
320      tofile="${build.dir}/config.xml"
321      overwrite="true"
322    >
323        <filterset refid="filterset.fileuris" />
324    </copy>
325   
326    <copy file="${docbook.styles}/${docbook.style}/xsl/customized.pdf-fop.xsl"
327          tofile="${build.dir}/customized.pdf-fop.xsl.tmp"
328          overwrite="true"
329    >
330        <filterset refid="filterset.fileuris" />
331      <filterset>
332          <filter token="doc.revision" value="${doc.revision}" />
333          <filter token="doc.last.modified" value="${doc.last.modified}" />
334          <filter token="base.version" value="${base.version}" />
335        </filterset>
336    </copy>
337
338    <style
339        in      = "${temp:docbook.ready.file}"
340        style   = "${build.dir}/customized.pdf-fop.xsl.tmp"
341        out     = "${build.dir}/fop-ready.fo"
342        processor = "${xslt.processor}"
343        >
344        <classpath refid="ant-extensions" />
345    </style>
346
347    <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
348             <classpath>
349                <fileset dir="${module.fop.basedir}">
350                    <include name="**/*.jar" />
351                </fileset>
352              <fileset dir="../dist">
353                <include name="commons-logging-1.0.4.jar" />
354              </fileset>
355             </classpath>
356    </taskdef>
357
358    <fop format     = "application/pdf" 
359         fofile     = "${build.dir}/fop-ready.fo"
360         outfile    = "${distribution.dir}/${pdf.name}_${base.version}.pdf"
361         messagelevel = "warn"
362         userconfig = "${build.dir}/config.xml"
363       basedir="${build.dir}"
364        />
365
366  </target>
367  <!-- }}} -->
368 
369  <!-- ########################################################## -->
370  <!-- ### {{{ builds PDF documentation using FOP             ### -->
371  <!-- ########################################################## -->
372  <property name="module.xep.basedir" location="${ant.docbook.styler.dir}/module-xep" />
373
374  <target name="pdf.xep" depends="modules.detection, pdf.xep.internal">
375    <fail unless="module.xep.present">
376    ### ERROR: module for PDF XEP rendering not installed. Please download
377    it and look in the readme file for installation instructions.
378    </fail>
379  </target>
380
381  <target name="pdf.xep.internal" depends="disable.resources.copy,docbook.consolidate" if="module.xep.present">
382
383    <copy file="${docbook.styles}/${docbook.style}/xsl/customized.pdf-xep.xsl"
384          tofile="${build.dir}/customized.pdf-xep.xsl.tmp"
385          overwrite="true"
386    >
387        <filterset refid="filterset.fileuris" />
388    </copy>
389
390    <path id="xep.classpath">
391        <fileset dir="${xep.installation.dir}" includes="lib/*.jar" />
392    </path>
393    <available property="xep.task.available" value="true"
394        classname="com.renderx.ant.XEPTask" classpathref="xep.classpath" >
395    </available>
396    <fail unless="xep.task.available">
397** ERROR: XEP task is not available. Make sure you installed XEP module correctly and
398set up XEP's installation directory in the module's configuration property file.
399    </fail>
400    <taskdef name="xep" classname="com.renderx.ant.XEPTask">
401        <classpath refid="xep.classpath" />
402    </taskdef>
403
404    <style
405        in      = "${temp:docbook.ready.file}"
406        style   = "${build.dir}/customized.pdf-xep.xsl.tmp"
407        out     = "${build.dir}/xep-ready.fo"
408        processor = "${xslt.processor}"
409        >
410        <classpath refid="ant-extensions" />
411    </style>
412
413    <xep in="${build.dir}/xep-ready.fo" out="${distribution.dir}/${manual.name}.pdf" format="PDF">
414        <sysproperty key="com.renderx.xep.ROOT" value="${xep.installation.dir}"/>
415        <sysproperty key="com.renderx.xep.FONTLIST" value="${module.xep.basedir}/conf/fonts.xml" />
416        <sysproperty key="com.renderx.xep.METRICS" value="${module.xep.basedir}/conf" />
417    </xep>
418
419  </target>
420  <!-- }}} -->
421
422
423
424 
425  <!-- ########################################################## -->
426  <!-- ### {{{ builds HTML documentation (single and chunked) ### -->
427  <!-- ########################################################## -->
428
429  <target name="html.single" depends="docbook.consolidate"
430          description="Renders a docbook documentation to a single HTML file.">
431
432    <copy file="${docbook.styles}/${docbook.style}/xsl/customized.single.xsl"
433          tofile="${build.dir}/customized.single.xsl.tmp"
434          overwrite="true"
435    >
436        <filterset refid="filterset.fileuris" />
437    </copy>
438
439    <style
440        in      = "${temp:docbook.ready.file}"
441        style   = "${build.dir}/customized.single.xsl.tmp"
442        out     = "${distribution.dir}/${manual.name}.html"
443        processor = "${xslt.processor}"
444        >
445        <classpath refid="ant-extensions" />
446    </style>
447   
448    <delete file="${build.dir}/customized.single.xsl.tmp" />
449
450  </target>
451
452
453  <target name="html.chunked" depends="docbook.consolidate" 
454          description="Renders the manual to a set of HTML files (sectioned).">
455 
456    <pathconvert property="docbook:tmp:chunked.dir" pathSep="," dirSep="/">
457        <path>
458            <pathelement location="${distribution.dir}" />
459        </path>
460    </pathconvert>
461   
462    <!-- Get the revision number and the datetime when the latest file was commited -->
463    <svn>
464    <status path="../../doc/src/docbook" lastChangedRevisionProperty="doc.revision" />
465      <status path="../../doc/src/docbook" lastChangedDateProperty="doc.last.modified" />
466  </svn>
467   
468    <copy file="${docbook.styles}/${docbook.style}/xsl/customized.chunked.xsl"
469          tofile="${build.dir}/customized.chunked.xsl.tmp"
470          overwrite="true"
471    >
472        <filterset refid="filterset.fileuris" />
473        <filterset>
474            <!-- (MM20040315) base.dir and root.filename are tokens used in customized.chunked.xsl
475                 to set the xsl:params correctly there -->
476            <filter token="base.dir" value="${docbook:tmp:chunked.dir}" />
477            <filter token="root.filename" value="${manual.name}" />
478          <filter token="doc.revision" value="${doc.revision}" />
479          <filter token="doc.last.modified" value="${doc.last.modified}" />
480          <filter token="base.version" value="${base.version}" />
481        </filterset>
482    </copy>
483
484    <style
485        in      = "${temp:docbook.ready.file}"
486        style   = "${build.dir}/customized.chunked.xsl.tmp"
487        out     = "${distribution.dir}/docbook-ref-file.tmp"
488        processor = "${xslt.processor}"
489        >
490
491        <classpath refid="ant-extensions" />
492        <!-- <param name="chunker.output.encoding" expression="'UTF-8'" /> -->
493    </style>
494   
495    <delete file="${build.dir}/customized.chunked.xsl.tmp" />
496
497  </target>
498
499  <!-- }}} -->
500
501  <!-- ########################################################################## -->
502  <!-- ### {{{ INSTALLATION                                                       -->
503  <!-- ########################################################################## -->
504  <target name="install.step1">
505    <property name="ant.docbook.styler.dir" location="${basedir}" />
506  </target>
507
508  <target name="install" depends="modules.detection,install.step1,create.styler.uri,check.expand.zips">
509
510    <available classname="org.apache.xml.resolver.Resolver" property="ok:resolver.available" />
511    <fail unless="ok:resolver.available">
512 ##
513 ## FAILED: you must download Jakarta Commons' Resolver
514 ## package and install it in ANT's lib directory.
515 ## Download it from: http://xml.apache.org/commons/
516 ##
517    </fail>
518   
519    <!-- Install modules, if present. -->
520    <antcall target="install.module.fop" />
521
522    <echo>
523 ##
524 ## ANT-DOCBOOK-STYLER INSTALLED.
525 ## ant.docbook.styler.dir is:
526 ## ${basedir}
527 ##
528    </echo>
529   
530  </target>
531 
532  <target name="install.module.fop" if="module.fop.present">
533    <echo>Installing FOP module</echo>
534
535    <copy file="${ant.docbook.styler.dir}/module-fop/conf/config.xml-preinstall"
536          tofile="${ant.docbook.styler.dir}/module-fop/conf/config.xml"
537          overwrite="true"
538    >
539        <filterset refid="filterset.fileuris" />
540    </copy>
541  </target>
542 
543  <!-- }}} --> 
544
545  <!-- ########################################################################## -->
546  <!-- ### {{{ Renders DocBook Website project into HTML                          -->
547  <!-- ########################################################################## -->
548 
549  <target name="website.check.required-properties">
550    <condition property="tmp:ant.docbook.styler.dir" value="true">
551        <and>
552            <!-- ## (dw 20040307) check that we really point at the base directory
553                 of ant-docbook-styler -->
554            <available file="${ant.docbook.styler.dir}" type="dir" />
555            <available file="${ant.docbook.styler.dir}/custom-styles" type="dir" />
556            <available file="${ant.docbook.styler.dir}/docbook" type="dir" />
557        </and>
558    </condition>
559    <fail message="### 'ant.docbook.styler.dir' does not point at the styler's installation directory: ${ant.docbook.styler.dir}"
560        unless="tmp:ant.docbook.styler.dir"/>
561
562    <condition property="tmp:website.xml.dir.ok" value="true">
563        <and>
564            <not>
565                <equals arg1="${website.xml.dir}" arg2="${undefined}" />
566            </not>
567            <available file="${website.xml.dir}" type="dir" />
568        </and>
569    </condition>
570    <fail message="### Define 'website.xml.dir' property pointing at Website XMLs folder."
571          unless="tmp:website.xml.dir.ok" />
572
573    <condition property="tmp:website.startfile.ok" value="true">
574        <and>
575            <available file="${website.xml.dir}/layout.xml" type="file" />
576        </and>
577    </condition>
578    <fail message="### Cannot find root Website file: ${website.xml.dir}/layout.xml"
579          unless="tmp:website.startfile.ok" />
580
581    <condition property="tmp:website.build.dir.ok" value="true">
582        <and>
583            <not>
584                <equals arg1="${build.dir}" arg2="${undefined}" />
585            </not>
586            <available file="${build.dir}" type="dir" />
587        </and>
588    </condition>
589    <fail message="### Define 'build.dir' property pointing at a temporary folder (will be erased!)."
590          unless="tmp:website.build.dir.ok" />         
591
592    <condition property="tmp:website.distribution.dir.ok" value="true">
593        <and>
594            <not>
595                <equals arg1="${distribution.dir}" arg2="${undefined}" />
596            </not>
597            <available file="${distribution.dir}" type="dir" />
598        </and>
599    </condition>
600    <fail message="### Define 'distribution.dir' property pointing at your destination folder."
601          unless="tmp:website.distribution.dir.ok" />         
602  </target>
603 
604
605  <target name="website" depends="check.expand.zips, website.check.required-properties, xsltprocessor, create.styler.uri"
606          description="Renders a docbook Website project into HTML.">
607
608    <property name="website.catalog.location" location="${ant.docbook.styler.dir}/website/catalog.xml" />
609
610    <!-- (MM 20040314) make the Java XSLT use the same catalog as the XSLTProc -->
611    <!-- works only with ant 1.6 and newer, but avoids problems when upgrading
612         from Java XSLT to XSLTProc later                                      -->
613    <xmlcatalog id="websitedtdcatalog">
614            <catalogpath>
615                <fileset file="${website.catalog.location}"/>
616            </catalogpath>
617    </xmlcatalog>
618   
619    <copy todir="${build.dir}" includeemptydirs="false">
620        <fileset dir="${website.styles}/${website.style}" excludes="**/*.xsl" />
621    </copy>
622    <copy todir="${build.dir}" includeemptydirs="false">
623        <fileset dir="${website.xml.dir}" includes="**/*" />
624    </copy>
625    <delete file="${build.dir}/autolayout.xml" />
626
627    <style
628        in      = "${build.dir}/layout.xml"
629        style   = "website/xsl/autolayout.xsl"
630        out     = "${build.dir}/autolayout.xml"
631        processor = "${xslt.processor}"
632        >
633        <xmlcatalog refid="websitedtdcatalog"/>
634        <classpath refid="ant-extensions" />
635        <param name="xsltproc.catalog" expression="${website.catalog.location}" />       
636        <param name="xsltproc.option.--nonet"  expression="" />
637    </style>
638
639    <!-- (MM 20040315) Make sure that XSLT was successful
640              It doesn't fail, if the DTDs cannot be found, though ... -->
641    <condition property="tmp:website.autolayout.xml.ok" value="true">
642            <available file="${build.dir}/autolayout.xml" type="file" />
643    </condition>
644    <fail message="### First step (creation of autolayout.xml) failed while building website."
645          unless="tmp:website.autolayout.xml.ok" />         
646
647    <delete file="${build.dir}/tmp.ref" />
648    <property name="abs.build.dir" location="${build.dir}" />
649
650    <copy file="${website.styles}/${website.style}/style-driver.xsl"
651          tofile="${build.dir}/style-driver.xsl.tmp"
652          overwrite="true"
653    >
654        <filterset refid="filterset.fileuris" />
655    </copy>
656
657    <!-- (MM 20040303) <style...> uses now the temporary style-driver.xsl having the real path
658         for the import file -->
659    <style
660        in      = "${build.dir}/autolayout.xml"
661        style   = "${build.dir}/style-driver.xsl.tmp"
662        out     = "${build.dir}/tmp.ref"
663        processor = "${xslt.processor}"
664        >
665        <xmlcatalog refid="websitedtdcatalog"/>
666        <classpath refid="ant-extensions" />
667        <param name="xsltproc.catalog" expression="${website.catalog.location}" />
668        <param name="xsltproc.option.--nonet"  expression="" />
669        <param name="output-root" expression="${abs.build.dir}" />       
670    </style>
671    <!-- (MM 20040315) Make sure that XSLT was successful
672          It doesn't fail, if the DTDs cannot be found, though ... -->
673    <condition property="tmp:website.tmp.ref.ok" value="true">
674            <available file="${build.dir}/tmp.ref" type="file" />
675    </condition>
676    <fail message="### Second step (creation of HTML files) failed while building website."
677          unless="tmp:website.tmp.ref.ok" />         
678   
679    <!-- (MM 20040303) deleting temporary style-driver.xsl -->
680    <delete file="${build.dir}/style-driver.xsl.tmp" />
681
682    <delete file="${build.dir}/tmp.ref" />
683    <copy todir="${distribution.dir}" includeemptydirs="false">
684        <fileset dir="${build.dir}" excludes="**/*.xml" />
685    </copy>
686  </target>
687  <!-- }}} --> 
688
689  <!-- ########################################################################## -->
690  <!-- ### {{{ XSLT processor recognition. If xsltproc[.exe] is found in path,    -->
691  <!-- ### it will be used for stylesheet processing (much faster than Xalan)     -->
692  <!-- ########################################################################## -->
693  <target name="xsltprocessor">
694    <property environment="env"/>
695
696    <condition  property="executable.file.extension"
697                value=".exe">
698            <os family="windows"/>
699    </condition>
700    <condition  property="executable.file.extension"
701                value="">
702            <os family="unix"/>
703    </condition>
704   
705    <condition  property="tmp:xsltproc.available"
706                value="xsltproc${executable.file.extension}">
707        <or>
708            <and>
709                <os family="windows"/>
710                <available file="xsltproc${executable.file.extension}" filepath="${env.Path}" />
711            </and>
712            <and>
713                <os family="unix"/>
714                <available file="xsltproc${executable.file.extension}" filepath="${env.PATH}" />
715            </and>
716        </or>
717    </condition>
718   
719    <condition property="xslt.processor" value="com.dawidweiss.ant.taskdefs.XsltProcLiaison">
720        <and>
721            <isset property="tmp:xsltproc.available" />
722            <not>
723                <isset property="disable.xsltproc" />
724            </not>
725        </and>
726    </condition>
727   
728    <condition property="xslt.processor" value="com.dawidweiss.ant.taskdefs.SaxonLiaison">
729        <not>
730            <isset property="disable.saxon" />
731        </not>
732    </condition>
733
734    <condition property="xslt.processor" value="trax">
735        <not>
736        <and>
737                <isset property="tmp:xsltproc.available" />
738                <not>
739                    <isset property="disable.xsltproc" />
740                </not>
741        </and>
742        </not>
743    </condition>
744
745    <antcall target="displayXsltProcessorInfo" />
746  </target>
747
748  <target name="displayXsltProcessorInfo"
749          if="tmp:xsltproc.available"
750          unless="disable.xsltproc">
751    <echo>
752   
753#####################################################
754XSLTProc has been found in your path and will be used
755for processing XSLT transformations. If you experience
756any problems, you can switch to Java's default XSLT
757processor by defining 'disable.xsltproc' property.
758#####################################################
759
760    </echo>
761  </target>
762 
763 
764  <target name="create.styler.uri">
765    <pathconvert dirsep="/" property="tmp:ant.docbook.styler.abs">
766        <path>
767        <pathelement location="${ant.docbook.styler.dir}" />
768        </path>
769    </pathconvert>
770    <condition  property="tmp:file.uri.prefix"
771                value="file:///">
772            <os family="windows"/>
773    </condition>
774    <condition  property="tmp:file.uri.prefix"
775                value="file://">
776            <os family="unix"/>
777    </condition>
778    <property name="tmp:ant.docbook.styler.uri"
779        value="${tmp:file.uri.prefix}${tmp:ant.docbook.styler.abs}" />
780
781    <pathconvert dirsep="/" property="tmp:style.abs">
782        <path>
783        <pathelement location="${docbook.styles}/${docbook.style}" />
784        </path>
785    </pathconvert>
786    <property name="tmp:style.uri"
787        value="${tmp:file.uri.prefix}${tmp:style.abs}" />
788     
789    <filterset id="filterset.fileuris">
790        <filter token="ant.docbook.styler.fileuri" value="${tmp:ant.docbook.styler.uri}" />
791        <filter token="docbook.style.fileuri" value="${tmp:style.uri}" />
792    </filterset>
793
794  </target>
795  <!-- }}} -->
796 
797 
798
799
800  <!-- ##################################### -->
801  <!-- ### {{{ HELP ON THIS FILE             ### -->
802  <!-- ##################################### -->
803  <target name="help" description="Displays help about the project.">
804    <echo>
805    Project name: ${ant.project.name}
806    (c) Dawid Weiss, Poznań University of Technology.
807
808    Current JDK: ${ant.java.version}
809    Basedir    : ${basedir}
810    -----------------------------------
811   
812    Use ant -projecthelp for description of available tasks.
813    See the test folder for an example of use.
814
815    </echo>
816  </target>
817  <!-- }}} -->
818
819</project>
Note: See TracBrowser for help on using the repository browser.