2 <!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
3 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
6 <xsl:import href=
"../html/docbook.xsl"/>
7 <xsl:include href=
"synop.xsl"/>
8 <xsl:include href=
"lists.xsl"/>
9 <xsl:include href=
"xref.xsl"/>
11 <!-- Needed for chunker.xsl (for now): -->
12 <xsl:param name=
"chunker.output.method" select=
"'text'"/>
13 <xsl:param name=
"chunker.output.encoding" select=
"'ISO-8859-1'"/>
15 <xsl:output method=
"text"
20 named templates for bold and italic. call like:
22 <xsl:apply-templates mode="bold" select="node-you-want" />
24 <xsl:template mode=
"bold" match=
"*">
25 <xsl:variable name=
"content">
26 <xsl:apply-templates/>
28 <xsl:text>\fB
</xsl:text>
29 <xsl:value-of select=
"$content"/>
30 <xsl:text>\fR
</xsl:text>
33 <xsl:template mode=
"italic" match=
"*">
34 <xsl:variable name=
"content">
35 <xsl:apply-templates/>
37 <xsl:text>\fI
</xsl:text>
38 <xsl:value-of select=
"$content"/>
39 <xsl:text>\fR
</xsl:text>
42 <xsl:template match=
"caution|important|note|tip|warning">
43 <xsl:text> .RS
.Sh
"</xsl:text>
44 <!-- capitalize word -->
46 select="translate (substring (name(.),
1,
1), 'cintw', 'CINTW')
" />
47 <xsl:value-of select="substring (name(),
2)
" />
49 <xsl:text>: </xsl:text>
50 <xsl:value-of select="title[
1]
"/>
52 <xsl:text>" </xsl:text>
53 <xsl:apply-templates/>
54 <xsl:text> .RE
</xsl:text>
57 <xsl:template match=
"refsection|refsect1">
59 <xsl:when test=
"ancestor::refsection">
60 <xsl:text> .SS
"</xsl:text>
61 <xsl:value-of select="title[
1]
"/>
64 <xsl:text> .SH "</xsl:text>
65 <xsl:value-of select=
"translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
68 <xsl:text>" </xsl:text>
69 <xsl:apply-templates/>
72 <xsl:template match="refsect2
">
73 <xsl:text> .SS "</xsl:text>
74 <xsl:value-of select=
"title[1]"/>
75 <xsl:text>" </xsl:text>
76 <xsl:apply-templates/>
79 <xsl:template match="refsynopsisdiv
">
80 <xsl:text> .SH "SYNOPSIS
" </xsl:text>
81 <xsl:apply-templates/>
85 <xsl:template match="para
">
86 <xsl:text> .PP </xsl:text>
87 <xsl:for-each select="node()
">
89 <xsl:when test="self::literallayout|self::informaltable|self::screen|
90 self::programlisting|self::itemizedlist|
91 self::orderedlist|self::variablelist|self::simplelist
">
92 <xsl:text> </xsl:text>
93 <xsl:apply-templates select=".
"/>
95 <xsl:when test="self::text()
">
96 <xsl:if test="starts-with(translate(.,'
',' '), ' ') and
97 preceding-sibling::node()[name(.)!='']
">
98 <xsl:text> </xsl:text>
100 <xsl:variable name="content
">
101 <xsl:apply-templates select=".
"/>
103 <xsl:value-of select="normalize-space($content)
"/>
105 test="translate(substring(., string-length(.),
1),'
',' ') = ' ' and
106 following-sibling::node()[name(.)!='']
">
107 <xsl:text> </xsl:text>
111 <xsl:variable name="content
">
112 <xsl:apply-templates select=".
"/>
114 <xsl:value-of select="normalize-space($content)
"/>
118 <xsl:text> </xsl:text>
121 <xsl:template match="simpara
">
122 <xsl:variable name="content
">
123 <xsl:apply-templates/>
125 <xsl:text> </xsl:text>
126 <xsl:value-of select="normalize-space($content)
"/>
132 <xsl:template match="refentry
">
134 <xsl:variable name="section
">
136 <xsl:when test="refmeta/manvolnum
">
137 <xsl:value-of select="refmeta/manvolnum[
1]
"/>
139 <xsl:when test=".//funcsynopsis
">3</xsl:when>
140 <xsl:otherwise>1</xsl:otherwise>
144 <xsl:variable name="name
" select="refnamediv/refname[
1]
"/>
146 <!-- standard man page width is 64 chars; 6 chars needed for the two
147 (x) volume numbers, and 2 spaces, leaves 56 -->
148 <xsl:variable name="twidth
" select="(
56 - string-length(refmeta/refentrytitle)) div
2"/>
150 <xsl:variable name="reftitle
"
151 select="substring(refmeta/refentrytitle,
1, $twidth)
"/>
153 <xsl:variable name="title
">
155 <xsl:when test="refentryinfo/title
">
156 <xsl:value-of select="refentryinfo/title
"/>
158 <xsl:when test="../referenceinfo/title
">
159 <xsl:value-of select="../referenceinfo/title
"/>
164 <xsl:variable name="date
">
166 <xsl:when test="refentryinfo/date
">
167 <xsl:value-of select="refentryinfo/date
"/>
169 <xsl:when test="../referenceinfo/date
">
170 <xsl:value-of select="../referenceinfo/date
"/>
175 <xsl:variable name="productname
">
177 <xsl:when test="refentryinfo/productname
">
178 <xsl:value-of select="refentryinfo/productname
"/>
180 <xsl:when test="../referenceinfo/productname
">
181 <xsl:value-of select="../referenceinfo/productname
"/>
186 <!-- replace spaces with underscores in the filename -->
187 <xsl:variable name="filename
">
188 <xsl:call-template name="replace-string
">
189 <xsl:with-param name="content
"
190 select="concat(normalize-space ($name), '.', $section)
"/>
191 <xsl:with-param name="replace
" select="' '
"/>
192 <xsl:with-param name="with
" select="'_'
"/>
196 <xsl:call-template name="write.text.chunk
">
197 <xsl:with-param name="filename
" select="$filename
"/>
198 <xsl:with-param name="content
">
199 <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
208 .de Sp \" Vertical space (when we can't use .PP)
214 .ie \\n(.$>=3 .ne \\$3
219 <xsl:value-of select=
"translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
220 <xsl:text>" </xsl:text>
221 <xsl:value-of select="$section
"/>
222 <xsl:text> "</xsl:text>
223 <xsl:value-of select=
"normalize-space($date)"/>
224 <xsl:text>" "</xsl:text>
225 <xsl:value-of select=
"normalize-space($productname)"/>
226 <xsl:text>" "</xsl:text>
227 <xsl:value-of select=
"$title"/>
230 <xsl:apply-templates/>
231 <xsl:text> </xsl:text>
233 <!-- Author section -->
235 <xsl:when test="refentryinfo//author
">
236 <xsl:apply-templates select="refentryinfo
" mode="authorsect
"/>
238 <xsl:when test="/book/bookinfo//author
">
239 <xsl:apply-templates select="/book/bookinfo
" mode="authorsect
"/>
241 <xsl:when test="/article/articleinfo//author
">
242 <xsl:apply-templates select="/article/articleinfo
" mode="authorsect
"/>
248 <!-- Now generate stub include pages for every page documented in
249 this refentry (except the page itself) -->
250 <xsl:for-each select="refnamediv/refname
">
251 <xsl:if test=". != $name
">
252 <xsl:call-template name="write.text.chunk
">
253 <xsl:with-param name="filename
"
254 select="concat(normalize-space(.), '.', $section)
"/>
255 <xsl:with-param name="content
" select="concat('.so man',
256 $section, '/', $name, '.', $section, '
')
"/>
262 <xsl:template match="refmeta
"></xsl:template>
263 <xsl:template match="title
"></xsl:template>
264 <xsl:template match="abstract
"></xsl:template>
266 <xsl:template match="articleinfo|bookinfo|refentryinfo
" mode="authorsect
">
267 <xsl:text>.SH AUTHOR</xsl:text>
268 <xsl:if test="count(.//author)
>1">
269 <xsl:text>S</xsl:text>
271 <xsl:text> </xsl:text>
273 <xsl:for-each select=".//author
">
274 <xsl:if test="position()
> 1">
275 <xsl:text>, </xsl:text>
277 <xsl:variable name="author
">
278 <xsl:apply-templates select=".
"/>
280 <xsl:value-of select="normalize-space($author)
"/>
282 <xsl:text>. </xsl:text>
283 <xsl:if test=".//editor
">
284 <xsl:text>.br Man page edited by </xsl:text>
285 <xsl:apply-templates select=".//editor
"/>
286 <xsl:text>. </xsl:text>
290 <xsl:template match="author|editor
">
291 <xsl:call-template name="person.name
"/>
292 <xsl:apply-templates select="./affiliation/address/email
" />
295 <xsl:template match="copyright
">
296 <xsl:text>Copyright \(co </xsl:text>
297 <xsl:apply-templates select="./year
" />
298 <xsl:text> .Sp </xsl:text>
301 <xsl:template match="email
">
302 <xsl:text> <</xsl:text>
303 <xsl:apply-templates/>
304 <xsl:text>></xsl:text>
307 <xsl:template match="refnamediv
">
308 <xsl:text>.SH NAME </xsl:text>
309 <xsl:for-each select="refname
">
310 <xsl:if test="position()
>1">
311 <xsl:text>, </xsl:text>
313 <xsl:value-of select=".
"/>
315 <xsl:text> \- </xsl:text>
316 <xsl:value-of select="normalize-space (refpurpose)
"/>
319 <xsl:template match="refentry/refentryinfo
"></xsl:template>
321 <xsl:template match="informalexample|screen
">
322 <xsl:text> .IP </xsl:text>
323 <xsl:apply-templates/>
326 <xsl:template match="filename|replaceable|varname
">
327 <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
330 <xsl:template match="option|userinput|envar|errorcode|constant|type
">
331 <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
334 <xsl:template match="emphasis
">
336 <xsl:when test="@role = 'bold' and $emphasis.propagates.style !=
0">
337 <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
340 <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
345 <xsl:template match="quote
">
346 <xsl:text>``</xsl:text>
347 <xsl:apply-templates/>
348 <xsl:text>''</xsl:text>
351 <xsl:template match="programlisting|literallayout
">
352 <xsl:text> .nf </xsl:text>
353 <xsl:apply-templates/>
354 <xsl:text> .fi </xsl:text>
357 <xsl:template match="optional
">
358 <xsl:value-of select="$arg.choice.opt.open.str
"/>
359 <xsl:apply-templates/>
360 <xsl:value-of select="$arg.choice.opt.close.str
"/>
363 <xsl:template name="do-citerefentry
">
364 <xsl:param name="refentrytitle
" select="''
"/>
365 <xsl:param name="manvolnum
" select="''
"/>
367 <xsl:apply-templates mode="bold
" select="$refentrytitle
"/>
368 <xsl:text>(</xsl:text>
369 <xsl:value-of select="$manvolnum
"/>
370 <xsl:text>)</xsl:text>
373 <xsl:template match="citerefentry
">
374 <xsl:call-template name="do-citerefentry
">
375 <xsl:with-param name="refentrytitle
" select="refentrytitle
"/>
376 <xsl:with-param name="manvolnum
" select="manvolnum
"/>
380 <xsl:template match="ulink
">
381 <xsl:variable name="content
">
382 <xsl:apply-templates/>
384 <xsl:variable name="url
" select="@url
"/>
386 <xsl:when test="$url=$content or $content=''
">
387 <xsl:text>\fI</xsl:text>
388 <xsl:value-of select="$url
"/>
389 <xsl:text>\fR</xsl:text>
392 <xsl:value-of select="$content
"/>
393 <xsl:text>: \fI</xsl:text>
394 <xsl:value-of select="$url
"/>
395 <xsl:text>\fR</xsl:text>
400 <!-- Translate some entities to textual equivalents. -->
401 <xsl:template name="replace-string
">
402 <xsl:param name="content
" select="''
"/>
403 <xsl:param name="replace
" select="''
"/>
404 <xsl:param name="with
" select="''
"/>
406 <xsl:when test="not(contains($content,$replace))
">
407 <xsl:value-of select="$content
"/>
410 <xsl:value-of select="substring-before($content,$replace)
"/>
411 <xsl:value-of select="$with
"/>
412 <xsl:call-template name="replace-string
">
413 <xsl:with-param name="content
"
414 select="substring-after($content,$replace)
"/>
415 <xsl:with-param name="replace
" select="$replace
"/>
416 <xsl:with-param name="with
" select="$with
"/>
422 <xsl:template name="replace-dash
">
423 <xsl:param name="content
" select="''
"/>
424 <xsl:call-template name="replace-string
">
425 <xsl:with-param name="content
" select="$content
"/>
426 <xsl:with-param name="replace
" select="'-'
"/>
427 <xsl:with-param name="with
" select="'\-'
"/>
431 <xsl:template name="replace-ndash
">
432 <xsl:param name="content
" select="''
"/>
433 <xsl:call-template name="replace-string
">
434 <xsl:with-param name="content
" select="$content
"/>
435 <xsl:with-param name="replace
" select="'
–'
"/>
436 <xsl:with-param name="with
" select="'-'
"/>
440 <xsl:template name="replace-mdash
">
441 <xsl:param name="content
" select="''
"/>
442 <xsl:call-template name="replace-string
">
443 <xsl:with-param name="content
" select="$content
"/>
444 <xsl:with-param name="replace
" select="'
—'
"/>
445 <xsl:with-param name="with
" select="'--'
"/>
449 <xsl:template name="replace-hellip
">
450 <xsl:param name="content
" select="''
"/>
451 <xsl:call-template name="replace-string
">
452 <xsl:with-param name="content
" select="$content
"/>
453 <xsl:with-param name="replace
" select="'
…'
"/>
454 <xsl:with-param name="with
" select="'...'
"/>
458 <xsl:template name="replace-setmn
">
459 <xsl:param name="content
" select="''
"/>
460 <xsl:call-template name="replace-string
">
461 <xsl:with-param name="content
" select="$content
"/>
462 <xsl:with-param name="replace
" select="'
∖'
"/>
463 <xsl:with-param name="with
" select="'\\'
"/>
467 <xsl:template name="replace-minus
">
468 <xsl:param name="content
" select="''
"/>
469 <xsl:value-of select="translate($content,'
−','-')
"/>
472 <xsl:template name="replace-nbsp
">
473 <xsl:param name="content
" select="''
"/>
474 <xsl:call-template name="replace-string
">
475 <xsl:with-param name="content
" select="$content
"/>
476 <xsl:with-param name="replace
" select="'
 '
"/>
477 <xsl:with-param name="with
" select="'\~'
"/>
481 <xsl:template name="replace-backslash
">
482 <xsl:param name="content
" select="''
"/>
483 <xsl:call-template name="replace-string
">
484 <xsl:with-param name="content
" select="$content
"/>
485 <xsl:with-param name="replace
" select="'\'
"/>
486 <xsl:with-param name="with
" select="'\\'
"/>
490 <!-- if a period character is output at the beginning of a line
491 it will be interpreted as a groff macro, so prefix all periods
492 with "\&
", a zero-width space. -->
493 <xsl:template name="replace-period
">
494 <xsl:param name="content
" select="''
"/>
495 <xsl:call-template name="replace-string
">
496 <xsl:with-param name="content
" select="$content
"/>
497 <xsl:with-param name="replace
" select="'.'
"/>
498 <xsl:with-param name="with
" select="'\
&.'
"/>
502 <xsl:template name="replace-entities
">
503 <xsl:param name="content
" select="''
"/>
504 <xsl:call-template name="replace-hellip
">
505 <xsl:with-param name="content
">
506 <xsl:call-template name="replace-minus
">
507 <xsl:with-param name="content
">
508 <xsl:call-template name="replace-mdash
">
509 <xsl:with-param name="content
">
510 <xsl:call-template name="replace-ndash
">
511 <xsl:with-param name="content
">
512 <xsl:call-template name="replace-dash
">
513 <xsl:with-param name="content
">
514 <xsl:call-template name="replace-setmn
">
515 <xsl:with-param name="content
">
516 <xsl:call-template name="replace-period
">
517 <xsl:with-param name="content
">
518 <xsl:call-template name="replace-nbsp
">
519 <xsl:with-param name="content
">
520 <xsl:call-template name="replace-backslash
">
521 <xsl:with-param name="content
" select="$content
"/>
541 <xsl:template match="dingbat.characters
">
542 <!-- now that I'm using the real serializer, all that dingbat malarky -->
543 <!-- isn't necessary anymore... -->
544 <xsl:param name="dingbat
">bullet</xsl:param>
546 <xsl:when test="$dingbat='bullet'
">\(bu</xsl:when>
547 <xsl:when test="$dingbat='copyright'
">\(co</xsl:when>
548 <xsl:when test="$dingbat='trademark'
">\(tm</xsl:when>
549 <xsl:when test="$dingbat='trade'
">\(tm</xsl:when>
550 <xsl:when test="$dingbat='registered'
">\(rg</xsl:when>
551 <xsl:when test="$dingbat='service'
">(SM)</xsl:when>
552 <xsl:when test="$dingbat='nbsp'
">\~</xsl:when>
553 <xsl:when test="$dingbat='ldquo'
">\(lq</xsl:when>
554 <xsl:when test="$dingbat='rdquo'
">\(rq</xsl:when>
555 <xsl:when test="$dingbat='lsquo'
">`</xsl:when>
556 <xsl:when test="$dingbat='rsquo'
">'</xsl:when>
557 <xsl:when test="$dingbat='em-dash'
">\(em</xsl:when>
558 <xsl:when test="$dingbat='mdash'
">\(em</xsl:when>
559 <xsl:when test="$dingbat='en-dash'
">\(en</xsl:when>
560 <xsl:when test="$dingbat='ndash'
">\(en</xsl:when>
562 <xsl:text>\(bu</xsl:text>
567 <xsl:template match="text()
">
568 <xsl:call-template name="replace-entities
">
569 <xsl:with-param name="content
">
570 <xsl:value-of select=".
"/>
575 <xsl:template match="/
">
577 <xsl:when test="//refentry
">
578 <xsl:apply-templates select="//refentry
"/>
581 <xsl:message>No refentry elements!</xsl:message>