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

Last change on this file since 3249 was 3249, checked in by Martin Svensson, 15 years ago

Fixes #521. Add creation of PDF document

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 30.8 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             </classpath>
353    </taskdef>
354
355    <fop format     = "application/pdf" 
356         fofile     = "${build.dir}/fop-ready.fo"
357         outfile    = "${distribution.dir}/${pdf.name}_${base.version}.pdf"
358         messagelevel = "info"
359         userconfig = "${build.dir}/config.xml"
360       basedir="${build.dir}"
361        />
362
363  </target>
364  <!-- }}} -->
365 
366  <!-- ########################################################## -->
367  <!-- ### {{{ builds PDF documentation using FOP             ### -->
368  <!-- ########################################################## -->
369  <property name="module.xep.basedir" location="${ant.docbook.styler.dir}/module-xep" />
370
371  <target name="pdf.xep" depends="modules.detection, pdf.xep.internal">
372    <fail unless="module.xep.present">
373    ### ERROR: module for PDF XEP rendering not installed. Please download
374    it and look in the readme file for installation instructions.
375    </fail>
376  </target>
377
378  <target name="pdf.xep.internal" depends="disable.resources.copy,docbook.consolidate" if="module.xep.present">
379
380    <copy file="${docbook.styles}/${docbook.style}/xsl/customized.pdf-xep.xsl"
381          tofile="${build.dir}/customized.pdf-xep.xsl.tmp"
382          overwrite="true"
383    >
384        <filterset refid="filterset.fileuris" />
385    </copy>
386
387    <path id="xep.classpath">
388        <fileset dir="${xep.installation.dir}" includes="lib/*.jar" />
389    </path>
390    <available property="xep.task.available" value="true"
391        classname="com.renderx.ant.XEPTask" classpathref="xep.classpath" >
392    </available>
393    <fail unless="xep.task.available">
394** ERROR: XEP task is not available. Make sure you installed XEP module correctly and
395set up XEP's installation directory in the module's configuration property file.
396    </fail>
397    <taskdef name="xep" classname="com.renderx.ant.XEPTask">
398        <classpath refid="xep.classpath" />
399    </taskdef>
400
401    <style
402        in      = "${temp:docbook.ready.file}"
403        style   = "${build.dir}/customized.pdf-xep.xsl.tmp"
404        out     = "${build.dir}/xep-ready.fo"
405        processor = "${xslt.processor}"
406        >
407        <classpath refid="ant-extensions" />
408    </style>
409
410    <xep in="${build.dir}/xep-ready.fo" out="${distribution.dir}/${manual.name}.pdf" format="PDF">
411        <sysproperty key="com.renderx.xep.ROOT" value="${xep.installation.dir}"/>
412        <sysproperty key="com.renderx.xep.FONTLIST" value="${module.xep.basedir}/conf/fonts.xml" />
413        <sysproperty key="com.renderx.xep.METRICS" value="${module.xep.basedir}/conf" />
414    </xep>
415
416  </target>
417  <!-- }}} -->
418
419
420
421 
422  <!-- ########################################################## -->
423  <!-- ### {{{ builds HTML documentation (single and chunked) ### -->
424  <!-- ########################################################## -->
425
426  <target name="html.single" depends="docbook.consolidate"
427          description="Renders a docbook documentation to a single HTML file.">
428
429    <copy file="${docbook.styles}/${docbook.style}/xsl/customized.single.xsl"
430          tofile="${build.dir}/customized.single.xsl.tmp"
431          overwrite="true"
432    >
433        <filterset refid="filterset.fileuris" />
434    </copy>
435
436    <style
437        in      = "${temp:docbook.ready.file}"
438        style   = "${build.dir}/customized.single.xsl.tmp"
439        out     = "${distribution.dir}/${manual.name}.html"
440        processor = "${xslt.processor}"
441        >
442        <classpath refid="ant-extensions" />
443    </style>
444   
445    <delete file="${build.dir}/customized.single.xsl.tmp" />
446
447  </target>
448
449
450  <target name="html.chunked" depends="docbook.consolidate" 
451          description="Renders the manual to a set of HTML files (sectioned).">
452 
453    <pathconvert property="docbook:tmp:chunked.dir" pathSep="," dirSep="/">
454        <path>
455            <pathelement location="${distribution.dir}" />
456        </path>
457    </pathconvert>
458   
459    <!-- Get the revision number and the datetime when the latest file was commited -->
460    <svn>
461    <status path="../../doc/src/docbook" lastChangedRevisionProperty="doc.revision" />
462      <status path="../../doc/src/docbook" lastChangedDateProperty="doc.last.modified" />
463  </svn>
464   
465    <copy file="${docbook.styles}/${docbook.style}/xsl/customized.chunked.xsl"
466          tofile="${build.dir}/customized.chunked.xsl.tmp"
467          overwrite="true"
468    >
469        <filterset refid="filterset.fileuris" />
470        <filterset>
471            <!-- (MM20040315) base.dir and root.filename are tokens used in customized.chunked.xsl
472                 to set the xsl:params correctly there -->
473            <filter token="base.dir" value="${docbook:tmp:chunked.dir}" />
474            <filter token="root.filename" value="${manual.name}" />
475          <filter token="doc.revision" value="${doc.revision}" />
476          <filter token="doc.last.modified" value="${doc.last.modified}" />
477          <filter token="base.version" value="${base.version}" />
478        </filterset>
479    </copy>
480
481    <style
482        in      = "${temp:docbook.ready.file}"
483        style   = "${build.dir}/customized.chunked.xsl.tmp"
484        out     = "${distribution.dir}/docbook-ref-file.tmp"
485        processor = "${xslt.processor}"
486        >
487
488        <classpath refid="ant-extensions" />
489        <!-- <param name="chunker.output.encoding" expression="'UTF-8'" /> -->
490    </style>
491   
492    <delete file="${build.dir}/customized.chunked.xsl.tmp" />
493
494  </target>
495
496  <!-- }}} -->
497
498  <!-- ########################################################################## -->
499  <!-- ### {{{ INSTALLATION                                                       -->
500  <!-- ########################################################################## -->
501  <target name="install.step1">
502    <property name="ant.docbook.styler.dir" location="${basedir}" />
503  </target>
504
505  <target name="install" depends="modules.detection,install.step1,create.styler.uri,check.expand.zips">
506
507    <available classname="org.apache.xml.resolver.Resolver" property="ok:resolver.available" />
508    <fail unless="ok:resolver.available">
509 ##
510 ## FAILED: you must download Jakarta Commons' Resolver
511 ## package and install it in ANT's lib directory.
512 ## Download it from: http://xml.apache.org/commons/
513 ##
514    </fail>
515   
516    <!-- Install modules, if present. -->
517    <antcall target="install.module.fop" />
518
519    <echo>
520 ##
521 ## ANT-DOCBOOK-STYLER INSTALLED.
522 ## ant.docbook.styler.dir is:
523 ## ${basedir}
524 ##
525    </echo>
526   
527  </target>
528 
529  <target name="install.module.fop" if="module.fop.present">
530    <echo>Installing FOP module</echo>
531
532    <copy file="${ant.docbook.styler.dir}/module-fop/conf/config.xml-preinstall"
533          tofile="${ant.docbook.styler.dir}/module-fop/conf/config.xml"
534          overwrite="true"
535    >
536        <filterset refid="filterset.fileuris" />
537    </copy>
538  </target>
539 
540  <!-- }}} --> 
541
542  <!-- ########################################################################## -->
543  <!-- ### {{{ Renders DocBook Website project into HTML                          -->
544  <!-- ########################################################################## -->
545 
546  <target name="website.check.required-properties">
547    <condition property="tmp:ant.docbook.styler.dir" value="true">
548        <and>
549            <!-- ## (dw 20040307) check that we really point at the base directory
550                 of ant-docbook-styler -->
551            <available file="${ant.docbook.styler.dir}" type="dir" />
552            <available file="${ant.docbook.styler.dir}/custom-styles" type="dir" />
553            <available file="${ant.docbook.styler.dir}/docbook" type="dir" />
554        </and>
555    </condition>
556    <fail message="### 'ant.docbook.styler.dir' does not point at the styler's installation directory: ${ant.docbook.styler.dir}"
557        unless="tmp:ant.docbook.styler.dir"/>
558
559    <condition property="tmp:website.xml.dir.ok" value="true">
560        <and>
561            <not>
562                <equals arg1="${website.xml.dir}" arg2="${undefined}" />
563            </not>
564            <available file="${website.xml.dir}" type="dir" />
565        </and>
566    </condition>
567    <fail message="### Define 'website.xml.dir' property pointing at Website XMLs folder."
568          unless="tmp:website.xml.dir.ok" />
569
570    <condition property="tmp:website.startfile.ok" value="true">
571        <and>
572            <available file="${website.xml.dir}/layout.xml" type="file" />
573        </and>
574    </condition>
575    <fail message="### Cannot find root Website file: ${website.xml.dir}/layout.xml"
576          unless="tmp:website.startfile.ok" />
577
578    <condition property="tmp:website.build.dir.ok" value="true">
579        <and>
580            <not>
581                <equals arg1="${build.dir}" arg2="${undefined}" />
582            </not>
583            <available file="${build.dir}" type="dir" />
584        </and>
585    </condition>
586    <fail message="### Define 'build.dir' property pointing at a temporary folder (will be erased!)."
587          unless="tmp:website.build.dir.ok" />         
588
589    <condition property="tmp:website.distribution.dir.ok" value="true">
590        <and>
591            <not>
592                <equals arg1="${distribution.dir}" arg2="${undefined}" />
593            </not>
594            <available file="${distribution.dir}" type="dir" />
595        </and>
596    </condition>
597    <fail message="### Define 'distribution.dir' property pointing at your destination folder."
598          unless="tmp:website.distribution.dir.ok" />         
599  </target>
600 
601
602  <target name="website" depends="check.expand.zips, website.check.required-properties, xsltprocessor, create.styler.uri"
603          description="Renders a docbook Website project into HTML.">
604
605    <property name="website.catalog.location" location="${ant.docbook.styler.dir}/website/catalog.xml" />
606
607    <!-- (MM 20040314) make the Java XSLT use the same catalog as the XSLTProc -->
608    <!-- works only with ant 1.6 and newer, but avoids problems when upgrading
609         from Java XSLT to XSLTProc later                                      -->
610    <xmlcatalog id="websitedtdcatalog">
611            <catalogpath>
612                <fileset file="${website.catalog.location}"/>
613            </catalogpath>
614    </xmlcatalog>
615   
616    <copy todir="${build.dir}" includeemptydirs="false">
617        <fileset dir="${website.styles}/${website.style}" excludes="**/*.xsl" />
618    </copy>
619    <copy todir="${build.dir}" includeemptydirs="false">
620        <fileset dir="${website.xml.dir}" includes="**/*" />
621    </copy>
622    <delete file="${build.dir}/autolayout.xml" />
623
624    <style
625        in      = "${build.dir}/layout.xml"
626        style   = "website/xsl/autolayout.xsl"
627        out     = "${build.dir}/autolayout.xml"
628        processor = "${xslt.processor}"
629        >
630        <xmlcatalog refid="websitedtdcatalog"/>
631        <classpath refid="ant-extensions" />
632        <param name="xsltproc.catalog" expression="${website.catalog.location}" />       
633        <param name="xsltproc.option.--nonet"  expression="" />
634    </style>
635
636    <!-- (MM 20040315) Make sure that XSLT was successful
637              It doesn't fail, if the DTDs cannot be found, though ... -->
638    <condition property="tmp:website.autolayout.xml.ok" value="true">
639            <available file="${build.dir}/autolayout.xml" type="file" />
640    </condition>
641    <fail message="### First step (creation of autolayout.xml) failed while building website."
642          unless="tmp:website.autolayout.xml.ok" />         
643
644    <delete file="${build.dir}/tmp.ref" />
645    <property name="abs.build.dir" location="${build.dir}" />
646
647    <copy file="${website.styles}/${website.style}/style-driver.xsl"
648          tofile="${build.dir}/style-driver.xsl.tmp"
649          overwrite="true"
650    >
651        <filterset refid="filterset.fileuris" />
652    </copy>
653
654    <!-- (MM 20040303) <style...> uses now the temporary style-driver.xsl having the real path
655         for the import file -->
656    <style
657        in      = "${build.dir}/autolayout.xml"
658        style   = "${build.dir}/style-driver.xsl.tmp"
659        out     = "${build.dir}/tmp.ref"
660        processor = "${xslt.processor}"
661        >
662        <xmlcatalog refid="websitedtdcatalog"/>
663        <classpath refid="ant-extensions" />
664        <param name="xsltproc.catalog" expression="${website.catalog.location}" />
665        <param name="xsltproc.option.--nonet"  expression="" />
666        <param name="output-root" expression="${abs.build.dir}" />       
667    </style>
668    <!-- (MM 20040315) Make sure that XSLT was successful
669          It doesn't fail, if the DTDs cannot be found, though ... -->
670    <condition property="tmp:website.tmp.ref.ok" value="true">
671            <available file="${build.dir}/tmp.ref" type="file" />
672    </condition>
673    <fail message="### Second step (creation of HTML files) failed while building website."
674          unless="tmp:website.tmp.ref.ok" />         
675   
676    <!-- (MM 20040303) deleting temporary style-driver.xsl -->
677    <delete file="${build.dir}/style-driver.xsl.tmp" />
678
679    <delete file="${build.dir}/tmp.ref" />
680    <copy todir="${distribution.dir}" includeemptydirs="false">
681        <fileset dir="${build.dir}" excludes="**/*.xml" />
682    </copy>
683  </target>
684  <!-- }}} --> 
685
686  <!-- ########################################################################## -->
687  <!-- ### {{{ XSLT processor recognition. If xsltproc[.exe] is found in path,    -->
688  <!-- ### it will be used for stylesheet processing (much faster than Xalan)     -->
689  <!-- ########################################################################## -->
690  <target name="xsltprocessor">
691    <property environment="env"/>
692
693    <condition  property="executable.file.extension"
694                value=".exe">
695            <os family="windows"/>
696    </condition>
697    <condition  property="executable.file.extension"
698                value="">
699            <os family="unix"/>
700    </condition>
701   
702    <condition  property="tmp:xsltproc.available"
703                value="xsltproc${executable.file.extension}">
704        <or>
705            <and>
706                <os family="windows"/>
707                <available file="xsltproc${executable.file.extension}" filepath="${env.Path}" />
708            </and>
709            <and>
710                <os family="unix"/>
711                <available file="xsltproc${executable.file.extension}" filepath="${env.PATH}" />
712            </and>
713        </or>
714    </condition>
715   
716    <condition property="xslt.processor" value="com.dawidweiss.ant.taskdefs.XsltProcLiaison">
717        <and>
718            <isset property="tmp:xsltproc.available" />
719            <not>
720                <isset property="disable.xsltproc" />
721            </not>
722        </and>
723    </condition>
724   
725    <condition property="xslt.processor" value="com.dawidweiss.ant.taskdefs.SaxonLiaison">
726        <not>
727            <isset property="disable.saxon" />
728        </not>
729    </condition>
730
731    <condition property="xslt.processor" value="trax">
732        <not>
733        <and>
734                <isset property="tmp:xsltproc.available" />
735                <not>
736                    <isset property="disable.xsltproc" />
737                </not>
738        </and>
739        </not>
740    </condition>
741
742    <antcall target="displayXsltProcessorInfo" />
743  </target>
744
745  <target name="displayXsltProcessorInfo"
746          if="tmp:xsltproc.available"
747          unless="disable.xsltproc">
748    <echo>
749   
750#####################################################
751XSLTProc has been found in your path and will be used
752for processing XSLT transformations. If you experience
753any problems, you can switch to Java's default XSLT
754processor by defining 'disable.xsltproc' property.
755#####################################################
756
757    </echo>
758  </target>
759 
760 
761  <target name="create.styler.uri">
762    <pathconvert dirsep="/" property="tmp:ant.docbook.styler.abs">
763        <path>
764        <pathelement location="${ant.docbook.styler.dir}" />
765        </path>
766    </pathconvert>
767    <condition  property="tmp:file.uri.prefix"
768                value="file:///">
769            <os family="windows"/>
770    </condition>
771    <condition  property="tmp:file.uri.prefix"
772                value="file://">
773            <os family="unix"/>
774    </condition>
775    <property name="tmp:ant.docbook.styler.uri"
776        value="${tmp:file.uri.prefix}${tmp:ant.docbook.styler.abs}" />
777
778    <pathconvert dirsep="/" property="tmp:style.abs">
779        <path>
780        <pathelement location="${docbook.styles}/${docbook.style}" />
781        </path>
782    </pathconvert>
783    <property name="tmp:style.uri"
784        value="${tmp:file.uri.prefix}${tmp:style.abs}" />
785     
786    <filterset id="filterset.fileuris">
787        <filter token="ant.docbook.styler.fileuri" value="${tmp:ant.docbook.styler.uri}" />
788        <filter token="docbook.style.fileuri" value="${tmp:style.uri}" />
789    </filterset>
790
791  </target>
792  <!-- }}} -->
793 
794 
795
796
797  <!-- ##################################### -->
798  <!-- ### {{{ HELP ON THIS FILE             ### -->
799  <!-- ##################################### -->
800  <target name="help" description="Displays help about the project.">
801    <echo>
802    Project name: ${ant.project.name}
803    (c) Dawid Weiss, Poznań University of Technology.
804
805    Current JDK: ${ant.java.version}
806    Basedir    : ${basedir}
807    -----------------------------------
808   
809    Use ant -projecthelp for description of available tasks.
810    See the test folder for an example of use.
811
812    </echo>
813  </target>
814  <!-- }}} -->
815
816</project>
Note: See TracBrowser for help on using the repository browser.