4
Licensed to the Apache Software Foundation (ASF) under one or more
5
contributor license agreements. See the NOTICE file distributed with
6
this work for additional information regarding copyright ownership.
7
The ASF licenses this file to You under the Apache License, Version 2.0
8
(the "License"); you may not use this file except in compliance with
9
the License. You may obtain a copy of the License at
11
http://www.apache.org/licenses/LICENSE-2.0
13
Unless required by applicable law or agreed to in writing, software
14
distributed under the License is distributed on an "AS IS" BASIS,
15
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
See the License for the specific language governing permissions and
17
limitations under the License.
21
* This software is based on initial work of Joe Orton <jorton redhat.com>
22
* (contributed to the ASF) which is based on the db2man stylesheets developed
23
* by Martijn van Beers. db2man is now part of docbook-xsl, which is
24
* licensed under the following terms:
29
* Copyright (C) 1999, 2000, 2001, 2002 Norman Walsh
31
* Permission is hereby granted, free of charge, to any person
32
* obtaining a copy of this software and associated documentation
33
* files (the ``Software''), to deal in the Software without
34
* restriction, including without limitation the rights to use,
35
* copy, modify, merge, publish, distribute, sublicense, and/or
36
* sell copies of the Software, and to permit persons to whom the
37
* Software is furnished to do so, subject to the following
40
* The above copyright notice and this permission notice shall be
41
* included in all copies or substantial portions of the Software.
43
* Except as contained in this notice, the names of individuals
44
* credited with contribution to this software shall not be used in
45
* advertising or otherwise to promote the sale, use or other
46
* dealings in this Software without prior written authorization
47
* from the individuals in question.
49
* Any stylesheet derived from this Software that is publically
50
* distributed will be identified with a different name and the
51
* version strings in any derived Software will be changed so that
52
* no possibility of confusion between the derived package and this
53
* Software will exist.
58
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
59
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
60
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
61
* NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER
62
* CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
63
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
64
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
65
* OTHER DEALINGS IN THE SOFTWARE.
68
<!DOCTYPE xsl:stylesheet [
69
<!ENTITY lf SYSTEM "../xsl/util/lf.xml">
71
<xsl:stylesheet version="1.0"
72
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
75
<!-- params injected from elsewhere -->
77
<xsl:param name="section" select="'1'" />
78
<xsl:param name="date" />
80
<!-- Constants used for case translation -->
81
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
82
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
84
<!-- ==================================================================== -->
86
<!-- Process an entire document into an nroff formatted man page -->
87
<!-- ==================================================================== -->
88
<xsl:template match="manualpage">
89
<!-- start at the beginning ;-) -->
90
<xsl:text>.\" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>&lf;
91
<xsl:text>.\" DO NOT EDIT! Generated from XML source.</xsl:text>&lf;
92
<xsl:text>.\" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</xsl:text>&lf;
93
<xsl:text>.de Sh \" Subsection</xsl:text>&lf;
94
<xsl:text>.br</xsl:text>&lf;
95
<xsl:text>.if t .Sp</xsl:text>&lf;
96
<xsl:text>.ne 5</xsl:text>&lf;
97
<xsl:text>.PP</xsl:text>&lf;
98
<xsl:text>\fB\\$1\fR</xsl:text>&lf;
99
<xsl:text>.PP</xsl:text>&lf;
100
<xsl:text>..</xsl:text>&lf;
101
<xsl:text>.de Sp \" Vertical space (when we can't use .PP)</xsl:text>&lf;
102
<xsl:text>.if t .sp .5v</xsl:text>&lf;
103
<xsl:text>.if n .sp</xsl:text>&lf;
104
<xsl:text>..</xsl:text>&lf;
105
<xsl:text>.de Ip \" List item</xsl:text>&lf;
106
<xsl:text>.br</xsl:text>&lf;
107
<xsl:text>.ie \\n(.$>=3 .ne \\$3</xsl:text>&lf;
108
<xsl:text>.el .ne 3</xsl:text>&lf;
109
<xsl:text>.IP "\\$1" \\$2</xsl:text>&lf;
110
<xsl:text>..</xsl:text>&lf;
113
<xsl:text>.TH "</xsl:text>
114
<!-- standard man page width is 64 chars; 6 chars needed for the two
115
(x) volume numbers, and 2 spaces, leaves 56 -->
116
<xsl:value-of select="substring(translate(substring-before(
117
normalize-space(title), ' - '), $lowercase, $uppercase), 1, (56 -
118
string-length(substring-before(normalize-space(title), ' - '))) div 2)" />
119
<xsl:text>" </xsl:text>
122
<xsl:value-of select="$section" />
123
<xsl:text> "</xsl:text>
125
<!-- date; perhaps injected via ant later. -->
126
<xsl:value-of select="$date" />
127
<xsl:text>" "</xsl:text>
130
<xsl:value-of select="'Apache HTTP Server'" />
131
<xsl:text>" "</xsl:text>
134
<xsl:value-of select="substring-before(normalize-space(title), ' - ')" />
135
<xsl:text>"</xsl:text>&lf;
137
<!-- reorder the paragraphs a bit -->
138
<xsl:apply-templates select="title" />&lf;
139
<xsl:apply-templates select="section[@id='synopsis']" />&lf;
140
<xsl:apply-templates select="summary" />&lf;
141
<xsl:apply-templates select="section[@id!='synopsis']" />&lf;
146
<!-- ==================================================================== -->
147
<!-- <manualpage><title> -->
148
<!-- Process heading -->
149
<!-- ==================================================================== -->
150
<xsl:template match="manualpage/title">
152
<xsl:text>.SH NAME</xsl:text>&lf;
153
<xsl:variable name="text">
154
<xsl:call-template name="filter.escape">
155
<xsl:with-param name="text" select="normalize-space(.)" />
158
<xsl:value-of select="substring-before($text, ' - ')" />
159
<xsl:text> \- </xsl:text>
160
<xsl:value-of select="substring-after($text, ' - ')" />
162
<!-- /manualpage/title -->
165
<!-- ==================================================================== -->
167
<!-- Process paragraph -->
168
<!-- ==================================================================== -->
169
<xsl:template match="p">
171
<xsl:text>.PP</xsl:text>&lf;
173
<xsl:for-each select="node()">
175
<xsl:when test="self::text()">
176
<xsl:if test="starts-with(translate(., ' ', ' '), ' ') and
177
preceding-sibling::node()[name(.) != '']">
178
<xsl:text> </xsl:text>
180
<xsl:variable name="content">
181
<xsl:apply-templates select="." />
183
<xsl:value-of select="normalize-space($content)"/>
184
<xsl:if test="translate(substring(., string-length(.), 1), ' ',
185
' ') = ' ' and following-sibling::node()[name(.) != '']">
186
<xsl:text> </xsl:text>
190
<xsl:variable name="content">
191
<xsl:apply-templates select="." />
193
<xsl:value-of select="normalize-space($content)"/>
201
<!-- ==================================================================== -->
203
<!-- process main section -->
204
<!-- ==================================================================== -->
205
<xsl:template match="section">
207
<xsl:text>.SH "</xsl:text>
208
<xsl:call-template name="filter.escape">
209
<xsl:with-param name="text"
210
select="normalize-space(translate(title, $lowercase, $uppercase))"/>
212
<xsl:text>"</xsl:text>&lf;
213
<xsl:apply-templates />
215
<xsl:template match="section/title" />
219
<!-- ==================================================================== -->
220
<!-- <section><section> -->
221
<!-- process subsection -->
222
<!-- ==================================================================== -->
223
<xsl:template match="section/section">
225
<xsl:text>.SS "</xsl:text>
226
<xsl:call-template name="filter.escape">
227
<xsl:with-param name="text" select="normalize-space(title)"/>
229
<xsl:text>"</xsl:text>&lf;
230
<xsl:apply-templates />
232
<!-- /section/section -->
235
<!-- ==================================================================== -->
237
<!-- process summary section -->
238
<!-- ==================================================================== -->
239
<xsl:template match="summary">
241
<xsl:text>.SH "</xsl:text>
242
<xsl:call-template name="filter.escape">
243
<xsl:with-param name="text" select="normalize-space(translate($message
244
[@id='summary'], $lowercase, $uppercase))"/>
246
<xsl:text>"</xsl:text>&lf;
247
<xsl:apply-templates />
252
<!-- ==================================================================== -->
254
<!-- show it somewhat special (italic) -->
255
<!-- ==================================================================== -->
256
<xsl:template match="var|em">
257
<xsl:text>\fI</xsl:text>
258
<xsl:apply-templates />
259
<xsl:text>\fR</xsl:text>
263
<!-- ==================================================================== -->
265
<!-- show it somewhat special (bold) -->
266
<!-- ==================================================================== -->
267
<xsl:template match="strong">
268
<xsl:text>\fB</xsl:text>
269
<xsl:apply-templates />
270
<xsl:text>\fR</xsl:text>
274
<!-- ==================================================================== -->
276
<!-- ==================================================================== -->
277
<xsl:template match="directive">
278
<xsl:if test="@type = 'section'"><</xsl:if>
279
<xsl:apply-templates />
280
<xsl:if test="@type = 'section'">></xsl:if>
284
<!-- ==================================================================== -->
286
<!-- ==================================================================== -->
287
<xsl:template match="dl">
289
<xsl:apply-templates />&lf;
293
<!-- ==================================================================== -->
295
<!-- ==================================================================== -->
296
<xsl:template match="dt">
298
<xsl:text>.TP</xsl:text>&lf;
300
<xsl:variable name="dt-content">
301
<xsl:apply-templates />
303
<xsl:value-of select="normalize-space($dt-content)" />&lf;
305
<xsl:variable name="dd-content">
307
select="following-sibling::dd[position() = 1]/node()" />
309
<xsl:value-of select="normalize-space($dd-content)" />
314
<!-- ==================================================================== -->
316
<!-- ==================================================================== -->
317
<xsl:template match="example[ancestor::dd]">
318
<xsl:apply-templates/>
321
<xsl:template match="example[not(ancestor::dd)]">
323
<xsl:text>.nf</xsl:text>&lf;
324
<xsl:apply-templates />&lf;
325
<xsl:text>.fi</xsl:text>&lf;
330
<!-- ==================================================================== -->
331
<!-- simple table support ... (exactly 2 columns) -->
332
<!-- ==================================================================== -->
333
<xsl:template match="table/tr">
334
<xsl:if test="count(./*) > 2">
335
<xsl:message terminate="yes">
336
FATAL: only tables with two (2) columns are supported.
341
<xsl:text>.Ip "\(bu \s-1</xsl:text>
342
<xsl:variable name="first-content">
343
<xsl:apply-templates select="./*[1]/node()" />
345
<xsl:value-of select="normalize-space($first-content)" />
347
<xsl:text>\s0 \- </xsl:text>
348
<xsl:variable name="second-content">
349
<xsl:apply-templates select="./*[2]/node()" />
351
<xsl:value-of select="normalize-space($second-content)" />&lf;
356
<!-- ==================================================================== -->
358
<!-- ==================================================================== -->
359
<xsl:template match="text()">
361
<xsl:when test="normalize-space(.) != ''">
362
<xsl:call-template name="filter.escape">
363
<xsl:with-param name="text" select="." />
367
<xsl:text> </xsl:text>
373
<!-- ==================================================================== -->
374
<!-- pass through content -->
375
<!-- ==================================================================== -->
376
<xsl:template match="a|code|module|table|program">
377
<xsl:apply-templates />
381
<!-- ==================================================================== -->
382
<!-- remove some stuff from the output -->
383
<!-- ==================================================================== -->
384
<xsl:template match="parentdocument|seealso|dd|td|example/br" />
387
<!-- ==================================================================== -->
388
<!-- the rest will be rejected -->
389
<!-- ==================================================================== -->
390
<xsl:template match="*">
391
<xsl:message terminate="yes">
392
FATAL: the behaviour of the <<xsl:value-of select="local-name()" />>
393
element was not tested. You need to modify
394
the XSLT stylesheet in order to get it work.
399
<!-- ==================================================================== -->
400
<!-- filter.escape -->
401
<!-- escape special characters -->
402
<!-- ==================================================================== -->
403
<xsl:template name="filter.escape">
404
<xsl:param name="text" />
407
<xsl:when test="contains($text, '\')">
408
<xsl:call-template name="filter.escape.period">
409
<xsl:with-param name="text" select="substring-before($text, '\')" />
411
<xsl:text>\\</xsl:text>
412
<xsl:call-template name="filter.escape">
413
<xsl:with-param name="text" select="substring-after($text, '\\')" />
417
<xsl:call-template name="filter.escape.period">
418
<xsl:with-param name="text" select="$text" />
423
<!-- /filter.escape -->
426
<!-- ==================================================================== -->
427
<!-- filter.period -->
428
<!-- accompanying template to filter.escape -->
429
<!-- ==================================================================== -->
430
<xsl:template name="filter.escape.period">
431
<xsl:param name="text" />
434
<xsl:when test="contains($text, '.')"><!-- period replaced by \&. -->
435
<xsl:value-of select="substring-before($text, '.')" />
436
<xsl:text>\&.</xsl:text>
437
<xsl:call-template name="filter.escape.period">
438
<xsl:with-param name="text" select="substring-after($text, '.')" />
442
<xsl:value-of select="$text" />
446
<!-- /filter.escape.period -->