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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
|
<?xml version="1.0"?>
<!--
Copyright 2003-2005 The Apache Software Foundation or its licensors, as
applicable.
Licensed 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.
-->
<!--
* This software is based on initial work of Joe Orton <jorton redhat.com>
* (contributed to the ASF) which is based on the db2man stylesheets developed
* by Martijn van Beers. db2man is now part of docbook-xsl, which is
* licensed under the following terms:
*
* Copyright
* =========
*
* Copyright (C) 1999, 2000, 2001, 2002 Norman Walsh
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the ``Software''), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* Except as contained in this notice, the names of individuals
* credited with contribution to this software shall not be used in
* advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization
* from the individuals in question.
*
* Any stylesheet derived from this Software that is publically
* distributed will be identified with a different name and the
* version strings in any derived Software will be changed so that
* no possibility of confusion between the derived package and this
* Software will exist.
*
* Warranty
* ========
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER
* CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/ -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY lf SYSTEM "../xsl/util/lf.xml">
]>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- -->
<!-- params injected from elsewhere -->
<!-- -->
<xsl:param name="section" select="'1'" />
<xsl:param name="date" />
<!-- Constants used for case translation -->
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<!-- ==================================================================== -->
<!-- <manualpage> -->
<!-- Process an entire document into an nroff formatted man page -->
<!-- ==================================================================== -->
<xsl:template match="manualpage">
<!-- start at the beginning ;-) -->
<xsl:text>.\" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>&lf;
<xsl:text>.\" DO NOT EDIT! Generated from XML source.</xsl:text>&lf;
<xsl:text>.\" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>&lf;
<xsl:text>.de Sh \" Subsection</xsl:text>&lf;
<xsl:text>.br</xsl:text>&lf;
<xsl:text>.if t .Sp</xsl:text>&lf;
<xsl:text>.ne 5</xsl:text>&lf;
<xsl:text>.PP</xsl:text>&lf;
<xsl:text>\fB\\$1\fR</xsl:text>&lf;
<xsl:text>.PP</xsl:text>&lf;
<xsl:text>..</xsl:text>&lf;
<xsl:text>.de Sp \" Vertical space (when we can't use .PP)</xsl:text>&lf;
<xsl:text>.if t .sp .5v</xsl:text>&lf;
<xsl:text>.if n .sp</xsl:text>&lf;
<xsl:text>..</xsl:text>&lf;
<xsl:text>.de Ip \" List item</xsl:text>&lf;
<xsl:text>.br</xsl:text>&lf;
<xsl:text>.ie \\n(.$>=3 .ne \\$3</xsl:text>&lf;
<xsl:text>.el .ne 3</xsl:text>&lf;
<xsl:text>.IP "\\$1" \\$2</xsl:text>&lf;
<xsl:text>..</xsl:text>&lf;
<!-- reftitle -->
<xsl:text>.TH "</xsl:text>
<!-- standard man page width is 64 chars; 6 chars needed for the two
(x) volume numbers, and 2 spaces, leaves 56 -->
<xsl:value-of select="substring(translate(substring-before(
normalize-space(title), ' - '), $lowercase, $uppercase), 1, (56 -
string-length(substring-before(normalize-space(title), ' - '))) div 2)" />
<xsl:text>" </xsl:text>
<!-- section -->
<xsl:value-of select="$section" />
<xsl:text> "</xsl:text>
<!-- date; perhaps injected via ant later. -->
<xsl:value-of select="$date" />
<xsl:text>" "</xsl:text>
<!-- productname -->
<xsl:value-of select="'Apache HTTP Server'" />
<xsl:text>" "</xsl:text>
<!-- title -->
<xsl:value-of select="substring-before(normalize-space(title), ' - ')" />
<xsl:text>"</xsl:text>&lf;
<!-- reorder the paragraphs a bit -->
<xsl:apply-templates select="title" />&lf;
<xsl:apply-templates select="section[@id='synopsis']" />&lf;
<xsl:apply-templates select="summary" />&lf;
<xsl:apply-templates select="section[@id!='synopsis']" />&lf;
</xsl:template>
<!-- /manualpage -->
<!-- ==================================================================== -->
<!-- <manualpage><title> -->
<!-- Process heading -->
<!-- ==================================================================== -->
<xsl:template match="manualpage/title">
&lf;
<xsl:text>.SH NAME</xsl:text>&lf;
<xsl:variable name="text">
<xsl:call-template name="filter.escape">
<xsl:with-param name="text" select="normalize-space(.)" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="substring-before($text, ' - ')" />
<xsl:text> \- </xsl:text>
<xsl:value-of select="substring-after($text, ' - ')" />
</xsl:template>
<!-- /manualpage/title -->
<!-- ==================================================================== -->
<!-- <p> -->
<!-- Process paragraph -->
<!-- ==================================================================== -->
<xsl:template match="p">
&lf;
<xsl:text>.PP</xsl:text>&lf;
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="self::text()">
<xsl:if test="starts-with(translate(., ' ', ' '), ' ') and
preceding-sibling::node()[name(.) != '']">
<xsl:text> </xsl:text>
</xsl:if>
<xsl:variable name="content">
<xsl:apply-templates select="." />
</xsl:variable>
<xsl:value-of select="normalize-space($content)"/>
<xsl:if test="translate(substring(., string-length(.), 1), ' ',
' ') = ' ' and following-sibling::node()[name(.) != '']">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="content">
<xsl:apply-templates select="." />
</xsl:variable>
<xsl:value-of select="normalize-space($content)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>&lf;
</xsl:template>
<!-- /p -->
<!-- ==================================================================== -->
<!-- <section> -->
<!-- process main section -->
<!-- ==================================================================== -->
<xsl:template match="section">
&lf;
<xsl:text>.SH "</xsl:text>
<xsl:call-template name="filter.escape">
<xsl:with-param name="text"
select="normalize-space(translate(title, $lowercase, $uppercase))"/>
</xsl:call-template>
<xsl:text>"</xsl:text>&lf;
<xsl:apply-templates />
</xsl:template>
<xsl:template match="section/title" />
<!-- /section -->
<!-- ==================================================================== -->
<!-- <section><section> -->
<!-- process subsection -->
<!-- ==================================================================== -->
<xsl:template match="section/section">
&lf;
<xsl:text>.SS "</xsl:text>
<xsl:call-template name="filter.escape">
<xsl:with-param name="text" select="normalize-space(title)"/>
</xsl:call-template>
<xsl:text>"</xsl:text>&lf;
<xsl:apply-templates />
</xsl:template>
<!-- /section/section -->
<!-- ==================================================================== -->
<!-- <summary> -->
<!-- process summary section -->
<!-- ==================================================================== -->
<xsl:template match="summary">
&lf;
<xsl:text>.SH "</xsl:text>
<xsl:call-template name="filter.escape">
<xsl:with-param name="text" select="normalize-space(translate($message
[@id='summary'], $lowercase, $uppercase))"/>
</xsl:call-template>
<xsl:text>"</xsl:text>&lf;
<xsl:apply-templates />
</xsl:template>
<!-- /summary -->
<!-- ==================================================================== -->
<!-- <var>, <em> -->
<!-- show it somewhat special (italic) -->
<!-- ==================================================================== -->
<xsl:template match="var|em">
<xsl:text>\fI</xsl:text>
<xsl:apply-templates />
<xsl:text>\fR</xsl:text>
</xsl:template>
<!-- ==================================================================== -->
<!-- <strong> -->
<!-- show it somewhat special (bold) -->
<!-- ==================================================================== -->
<xsl:template match="strong">
<xsl:text>\fB</xsl:text>
<xsl:apply-templates />
<xsl:text>\fR</xsl:text>
</xsl:template>
<!-- ==================================================================== -->
<!-- <directive> -->
<!-- ==================================================================== -->
<xsl:template match="directive">
<xsl:if test="@type = 'section'"><</xsl:if>
<xsl:apply-templates />
<xsl:if test="@type = 'section'">></xsl:if>
</xsl:template>
<!-- ==================================================================== -->
<!-- <dl> -->
<!-- ==================================================================== -->
<xsl:template match="dl">
&lf;
<xsl:apply-templates />&lf;
</xsl:template>
<!-- ==================================================================== -->
<!-- <dt> -->
<!-- ==================================================================== -->
<xsl:template match="dt">
&lf;
<xsl:text>.TP</xsl:text>&lf;
<xsl:variable name="dt-content">
<xsl:apply-templates />
</xsl:variable>
<xsl:value-of select="normalize-space($dt-content)" />&lf;
<xsl:variable name="dd-content">
<xsl:apply-templates
select="following-sibling::dd[position() = 1]/node()" />
</xsl:variable>
<xsl:value-of select="normalize-space($dd-content)" />
</xsl:template>
<!-- /dt -->
<!-- ==================================================================== -->
<!-- <example> -->
<!-- ==================================================================== -->
<xsl:template match="example[ancestor::dd]">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="example[not(ancestor::dd)]">
&lf;
<xsl:text>.nf</xsl:text>&lf;
<xsl:apply-templates />&lf;
<xsl:text>.fi</xsl:text>&lf;
</xsl:template>
<!-- /example -->
<!-- ==================================================================== -->
<!-- simple table support ... (exactly 2 columns) -->
<!-- ==================================================================== -->
<xsl:template match="table/tr">
<xsl:if test="count(./*) > 2">
<xsl:message terminate="yes">
FATAL: only tables with two (2) columns are supported.
</xsl:message>
</xsl:if>
&lf;
<xsl:text>.Ip "\(bu \s-1</xsl:text>
<xsl:variable name="first-content">
<xsl:apply-templates select="./*[1]/node()" />
</xsl:variable>
<xsl:value-of select="normalize-space($first-content)" />
<xsl:text>\s0 \- </xsl:text>
<xsl:variable name="second-content">
<xsl:apply-templates select="./*[2]/node()" />
</xsl:variable>
<xsl:value-of select="normalize-space($second-content)" />&lf;
</xsl:template>
<!-- /table/tr -->
<!-- ==================================================================== -->
<!-- text filter -->
<!-- ==================================================================== -->
<xsl:template match="text()">
<xsl:choose>
<xsl:when test="normalize-space(.) != ''">
<xsl:call-template name="filter.escape">
<xsl:with-param name="text" select="." />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ==================================================================== -->
<!-- pass through content -->
<!-- ==================================================================== -->
<xsl:template match="a|code|module|table|program">
<xsl:apply-templates />
</xsl:template>
<!-- ==================================================================== -->
<!-- remove some stuff from the output -->
<!-- ==================================================================== -->
<xsl:template match="parentdocument|seealso|dd|td|example/br" />
<!-- ==================================================================== -->
<!-- the rest will be rejected -->
<!-- ==================================================================== -->
<xsl:template match="*">
<xsl:message terminate="yes">
FATAL: the behaviour of the <<xsl:value-of select="local-name()" />>
element was not tested. You need to modify
the XSLT stylesheet in order to get it work.
</xsl:message>
</xsl:template>
<!-- ==================================================================== -->
<!-- filter.escape -->
<!-- escape special characters -->
<!-- ==================================================================== -->
<xsl:template name="filter.escape">
<xsl:param name="text" />
<xsl:choose>
<xsl:when test="contains($text, '\')">
<xsl:call-template name="filter.escape.period">
<xsl:with-param name="text" select="substring-before($text, '\')" />
</xsl:call-template>
<xsl:text>\\</xsl:text>
<xsl:call-template name="filter.escape">
<xsl:with-param name="text" select="substring-after($text, '\\')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="filter.escape.period">
<xsl:with-param name="text" select="$text" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- /filter.escape -->
<!-- ==================================================================== -->
<!-- filter.period -->
<!-- accompanying template to filter.escape -->
<!-- ==================================================================== -->
<xsl:template name="filter.escape.period">
<xsl:param name="text" />
<xsl:choose>
<xsl:when test="contains($text, '.')"><!-- period replaced by \&. -->
<xsl:value-of select="substring-before($text, '.')" />
<xsl:text>\&.</xsl:text>
<xsl:call-template name="filter.escape.period">
<xsl:with-param name="text" select="substring-after($text, '.')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- /filter.escape.period -->
</xsl:stylesheet>
|