This repository has been archived by the owner on Dec 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build-docbook.xml
executable file
·375 lines (314 loc) · 16.8 KB
/
build-docbook.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
Modified for the GeoNetwork opensource documentation by
Jeroen Ticheler - 07-Feb-2008
This file should not be called directly. Always use the default build.xml
For example type: ant all
This will generate both HTML and PDF documentation
-->
<project name="docbook" default="all" basedir=".">
<!-- Load our properties -->
<property file="${docbook.src.dir}/docbook.properties"/>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Set up the classpath for the XSLT conversion == -->
<!-- == == -->
<!-- ======================================================================== -->
<path id="dbf.classpath">
<fileset dir="${docbook.src.dir}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${dbf.xsl.dir}/extensions">
<include name="${xslt-db.jar}"/>
</fileset>
<pathelement location="${tmp.dir}"/>
</path>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Prepare Path elements to be used when filtering the XSL files == -->
<!-- == == -->
<!-- ======================================================================== -->
<path id="dbf.xml.path" location="${dbf.xml.dir}"/>
<path id="dbf.xsl.path" location="${dbf.xsl.dir}"/>
<path id="src.dir.path" location="${src.dir}"/>
<path id="tmp.dir.path" location="${tmp.dir}"/>
<path id="target.dir.path" location="${target.dir}"/>
<pathconvert dirsep="/" property="dbf.xml.path" refid="dbf.xml.path"/>
<pathconvert dirsep="/" property="dbf.xsl.path" refid="dbf.xsl.path"/>
<pathconvert dirsep="/" property="src.dir.path" refid="src.dir.path"/>
<pathconvert dirsep="/" property="tmp.dir.path" refid="tmp.dir.path"/>
<pathconvert dirsep="/" property="target.dir.path" refid="target.dir.path"/>
<condition property="file.prefix" value="file:///">
<os family="windows"/>
</condition>
<condition property="file.prefix" value="file://">
<os family="unix"/>
</condition>
<!-- This filterset is used to convert the style sheets to reference
the actual locations of the docbook XSLT files -->
<filterset id="filterset.dbf.location">
<filter token="paper.type" value="${paper.type}" />
<filter token="file.prefix" value="${file.prefix}" />
<filter token="dbf.xml" value="${dbf.xml.path}" />
<filter token="dbf.xsl" value="${dbf.xsl.path}" />
<filter token="src.dir" value="${src.dir.path}" />
<filter token="tmp.dir" value="${tmp.dir.path}" />
<filter token="target.dir" value="${target.dir.path}" />
</filterset>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Saxon Converter macro that uses commons-resolver == -->
<!-- == == -->
<!-- == input: The file to transform == -->
<!-- == output: The transformation result == -->
<!-- == style: The Style Sheet used for the transformation == -->
<!-- == == -->
<!-- ======================================================================== -->
<macrodef name="saxon">
<attribute name="input"/>
<attribute name="output"/>
<attribute name="style"/>
<sequential>
<java classname="com.icl.saxon.StyleSheet" fork="true"
dir="${basedir}" classpathref="dbf.classpath">
<jvmarg value="-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl" />
<jvmarg value="-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl" />
<jvmarg value="-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration" />
<arg line="-x org.apache.xml.resolver.tools.ResolvingXMLReader"/>
<arg line="-y org.apache.xml.resolver.tools.ResolvingXMLReader"/>
<arg line="-r org.apache.xml.resolver.tools.CatalogResolver"/>
<arg value="-o"/>
<arg value="@{output}"/>
<arg value="@{input}"/>
<arg value="@{style}"/>
</java>
</sequential>
</macrodef>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Transformation Macro that generates output from Docbook == -->
<!-- == == -->
<!-- == type: Type of transformation (pdf, html, htmlsingle) == -->
<!-- == title: Titlepage to use (html and htmlsingle both use html!) == -->
<!-- == target: Target directory (pdf needs tmp for FOP transform) == -->
<!-- == dir: Subdir where the Docbook XML file is located. Also subdir == -->
<!-- == for the output == -->
<!-- == file: Name of the file (without ending!) to transform == -->
<!-- == == -->
<!-- ======================================================================== -->
<macrodef name="transform">
<attribute name="type"/>
<attribute name="title"/>
<attribute name="target"/>
<attribute name="dir"/>
<attribute name="file"/>
<attribute name="xsl"/>
<attribute name="lang"/>
<sequential>
<property name="@{type}.target.dir" value="${target.dir}/@{dir}/@{target}/@{lang}"/>
<property name="@{type}.target.dir.image" value="${target.dir}/@{dir}/@{target}"/>
<property name="@{type}.target.file" value="${@{type}.target.dir}/@{file}"/>
<property name="@{type}.tmp.style" value="${tmp.dir}/@{type}.xsl"/>
<property name="@{type}.tmp.custom" value="${tmp.dir}/@{type}-style.xsl"/>
<property name="@{type}.tmp.titlepage" value="${tmp.dir}/@{type}-titlepage"/>
<path id="@{type}.target.path" location="${@{type}.target.dir}"/>
<pathconvert dirsep="/" property="@{type}.target.path" refid="@{type}.target.path"/>
<copy overwrite="true" filtering="on" file="${dbf.style.src.dir}/@{type}.xsl" tofile="${@{type}.tmp.style}">
<filterset refid="filterset.dbf.location"/>
<filterset>
<filter token="@{type}.target.dir" value="${@{type}.target.path}" />
</filterset>
</copy>
<copy overwrite="true" failonerror="false" filtering="on" file="${styles.src.dir}/@{type}/custom_@{lang}.xsl" tofile="${@{type}.tmp.custom}">
<filterset refid="filterset.dbf.location"/>
<filterset>
<filter token="@{type}.target.dir" value="${@{type}.target.path}" />
</filterset>
</copy>
<!-- No custom style file around. Use the vanilla one. -->
<copy overwrite="false" failonerror="true" file="${dbf.style.src.dir}/custom.xsl" tofile="${@{type}.tmp.custom}"/>
<mkdir dir="${@{type}.target.dir}/" />
<!-- copy custom title page. If we don't have one, use the custom one. -->
<copy file="${styles.src.dir}/@{title}/titlepage.xml" tofile="${@{type}.tmp.titlepage}.xml" overwrite="true" failonerror="false" />
<copy file="${dbf.xsl.dir}/@{xsl}/titlepage.templates.xml" tofile="${@{type}.tmp.titlepage}.xml" overwrite="false" failonerror="true" />
<saxon input="${@{type}.tmp.titlepage}.xml"
output="${@{type}.tmp.titlepage}.xsl"
style="${dbf.xsl.dir}/template/titlepage.xsl"/>
<copy todir="${@{type}.target.dir.image}/images">
<fileset dir="${docbook.src.dir}/@{dir}/images"/>
</copy>
<copy todir="${@{type}.target.dir.image}/@{lang}/images">
<fileset dir="${docbook.src.dir}/@{dir}/images"/>
</copy>
<saxon input="${docbook.src.dir}/@{dir}/@{file}.xml"
output="${@{type}.target.file}.xml"
style="${@{type}.tmp.style}"/>
</sequential>
</macrodef>
<!-- =========================================================================== -->
<!-- == == -->
<!-- == FOP transformation target definition == -->
<!-- == == -->
<!-- =========================================================================== -->
<taskdef name="fop"
classname="org.apache.fop.tools.anttasks.Fop">
<classpath>
<fileset dir="${docbook.src.dir}/lib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- =========================================================================== -->
<!-- == == -->
<!-- == prepare temporary directories and unzip the docbook DTD and XSL files == -->
<!-- == == -->
<!-- =========================================================================== -->
<target name="prepare">
<fail message="You must set docbook.file and docbook.dir!">
<condition>
<not>
<and>
<isset property="docbook.dir"/>
<isset property="docbook.file"/>
</and>
</not>
</condition>
</fail>
<fail message="You must configure the dbf.basedir from your project.properties. That is usually ${basedir}/docbook!">
<condition>
<not>
<and>
<isset property="dbf.basedir"/>
</and>
</not>
</condition>
</fail>
<mkdir dir="${tmp.dir}" />
<mkdir dir="${dbf.xml.dir}" />
<unzip src="${dbf.zip.src.dir}/docbook-xml-${dbf.xml.version}.zip" dest="${dbf.xml.dir}" />
<mkdir dir="${dbf.xsl.dir}" />
<unzip src="${dbf.zip.src.dir}/docbook-xsl-${dbf.xsl.version}.zip" dest="${target.dir}" />
<copy todir="${tmp.dir}" filtering="on" overwrite="true">
<fileset dir="${dbf.resolver.src.dir}"/>
<filterset refid="filterset.dbf.location"/>
</copy>
</target>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == This is the main target to generate the HTML and PDF docs == -->
<!-- == == -->
<!-- ======================================================================== -->
<target name="all" depends="pdf,html"
description="--> Generate and copy reference documentation"/>
<target name="all_dev" depends="pdf,html_dev"
description="--> Generate and copy developer reference documentation"/>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Clean up the target directory == -->
<!-- == == -->
<!-- ======================================================================== -->
<target name="clean"
description="--> Delete temporary and distribution directories for docs">
<fail message="You must configure the dbf.basedir from your project.properties. That is usually ${basedir}/docbook!">
<condition>
<not>
<and>
<isset property="dbf.basedir"/>
</and>
</not>
</condition>
</fail>
<delete quiet="true" dir="${target.dir}"/>
<delete quiet="true" dir="${basedir}/html"/>
<delete quiet="true" file="${basedir}/Manual.pdf"/>
<delete quiet="true" file="${basedir}/Manual_fra.pdf"/>
<delete quiet="true" file="${basedir}/Manual_XmlServices.pdf"/>
<delete quiet="true" file="${basedir}/docbook_guidelines.pdf"/>
</target>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Create the PDF documentation == -->
<!-- == == -->
<!-- ======================================================================== -->
<target name="pdf"
depends="prepare"
description="--> Generate PDF docs">
<transform type="pdf" target="tmp" title="pdf" xsl="fo" dir="${docbook.dir}" file="${docbook.file}" lang="${lang}"/>
<fop format="application/pdf"
fofile="${pdf.target.file}.xml"
outfile="${basedir}/${docbook.file}.pdf"
messagelevel="${fop.debug}" basedir="${target.dir}/${docbook.dir}/tmp/"
userconfig="${docbook.src.dir}/fop.xconf"/>
</target>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Create the HTML documentation, many pages == -->
<!-- == == -->
<!-- ======================================================================== -->
<target name="html"
depends="prepare"
description="--> Generate HTML docs in multiple files">
<transform type="html" target="html" title="html" xsl="html" dir="${docbook.dir}" file="${docbook.file}" lang="${lang}"/>
<copy todir="${html.target.dir}/images">
<fileset dir="${dbf.xsl.dir}/images/"/>
</copy>
<copy todir="${html.target.dir}/css">
<fileset dir="${css.src.dir}/html"/>
</copy>
<delete file="${html.target.file}.xml"/>
<copy todir="${basedir}/html/usermanual">
<fileset dir="${target.dir}/${docbook.dir}/html"/>
</copy>
</target>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Create the HTML documentation, one big page == -->
<!-- == == -->
<!-- ======================================================================== -->
<target name="htmlsingle"
depends="prepare"
description="--> Generate HTML docs in a single, big file">
<transform type="htmlsingle" target="htmlsingle" title="html" xsl="html" dir="${docbook.dir}" file="${docbook.file}"/>
<copy todir="${htmlsingle.target.dir}/images">
<fileset dir="${dbf.xsl.dir}/images/"/>
</copy>
<copy todir="${htmlsingle.target.dir}/css">
<fileset dir="${css.src.dir}/html"/>
</copy>
<move file="${htmlsingle.target.file}.xml" tofile="${htmlsingle.target.file}.html"/>
</target>
<!-- ======================================================================== -->
<!-- == == -->
<!-- == Create the HTML developer documentation, many pages == -->
<!-- == == -->
<!-- ======================================================================== -->
<target name="html_dev"
depends="prepare"
description="--> Generate HTML developer docs in multiple files">
<transform type="html" target="html" title="html" xsl="html" dir="${docbook.dir}" file="${docbook.file}" lang="${lang}"/>
<copy todir="${html.target.dir}/images">
<fileset dir="${dbf.xsl.dir}/images/"/>
</copy>
<copy todir="${html.target.dir}/css">
<fileset dir="${css.src.dir}/html"/>
</copy>
<delete file="${html.target.file}.xml"/>
<copy todir="${basedir}/html/devmanual">
<fileset dir="${target.dir}/${docbook.dir}/html"/>
</copy>
</target>
</project>