f7a7d4e4e72c4aa6a74a60432592df88378f859b
[debian/amanda] / man / xslt / man.xsl
1 <?xml version='1.0'?>
2 <!-- vim:set sts=2 shiftwidth=2 syntax=xml: -->
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4                 version='1.0'>
5
6 <xsl:import href="settings.xsl"/>
7
8 <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
9
10 <xsl:param name="chunk.section.depth" select="0"/>
11 <xsl:param name="chunk.first.sections" select="1"/>
12 <xsl:param name="use.id.as.filename" select="1"/>
13
14 <!-- 
15     Our ulink stylesheet omits @url part if content was specified
16 -->
17 <xsl:template match="ulink">
18   <xsl:variable name="content">
19     <xsl:apply-templates/>
20   </xsl:variable>
21   <xsl:if test="$content = ''">
22     <xsl:text>: </xsl:text>
23   </xsl:if>
24   <xsl:if test="$content != ''">
25     <xsl:value-of select="$content" />
26   </xsl:if>
27   <xsl:if test="$content = ''">
28     <xsl:apply-templates mode="italic" select="@url" />
29   </xsl:if>
30 </xsl:template>
31
32 <xsl:template match="refentry">
33
34   <xsl:variable name="section" select="refmeta/manvolnum"/>
35   <xsl:variable name="name" select="refnamediv/refname[1]"/>
36   <xsl:variable name="base.dir" select="$base.dir"/>
37   <!-- standard man page width is 64 chars; 6 chars needed for the two
38        (x) volume numbers, and 2 spaces, leaves 56 -->
39   <xsl:variable name="twidth" select="(74 - string-length(refmeta/refentrytitle)) div 2"/>
40
41   <xsl:variable name="reftitle" 
42                 select="substring(refmeta/refentrytitle, 1, $twidth)"/>
43
44   <xsl:variable name="title">
45     <xsl:choose>
46       <xsl:when test="refentryinfo/title">
47         <xsl:value-of select="refentryinfo/title"/>
48       </xsl:when>
49       <xsl:when test="../referenceinfo/title">
50         <xsl:value-of select="../referenceinfo/title"/>
51       </xsl:when>
52     </xsl:choose>
53   </xsl:variable>
54
55   <xsl:variable name="date">
56     <xsl:choose>
57       <xsl:when test="refentryinfo/date">
58         <xsl:value-of select="refentryinfo/date"/>
59       </xsl:when>
60       <xsl:when test="../referenceinfo/date">
61         <xsl:value-of select="../referenceinfo/date"/>
62       </xsl:when>
63     </xsl:choose>
64   </xsl:variable>
65
66   <xsl:variable name="productname">
67     <xsl:choose>
68       <xsl:when test="refentryinfo/productname">
69         <xsl:value-of select="refentryinfo/productname"/>
70       </xsl:when>
71       <xsl:when test="../referenceinfo/productname">
72         <xsl:value-of select="../referenceinfo/productname"/>
73       </xsl:when>
74     </xsl:choose>
75   </xsl:variable>
76
77   <xsl:call-template name="write.text.chunk">
78     <xsl:with-param name="filename"
79                     select="concat($base.dir, normalize-space ($name), '.', $section)"/>
80     <xsl:with-param name="content">
81       <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
82 .de Sh \" Subsection
83 .br
84 .if t .Sp
85 .ne 5
86 .PP
87 \fB\\$1\fR
88 .PP
89 ..
90 .de Sp \" Vertical space (when we can't use .PP)
91 .if t .sp .5v
92 .if n .sp
93 ..
94 .de Ip \" List item
95 .br
96 .ie \\n(.$>=3 .ne \\$3
97 .el .ne 3
98 .IP "\\$1" \\$2
99 ..
100 .TH "</xsl:text>
101       <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
102       <xsl:text>" </xsl:text>
103       <xsl:value-of select="refmeta/manvolnum[1]"/>
104       <xsl:text> "</xsl:text>
105       <xsl:value-of select="normalize-space($date)"/>
106       <xsl:text>" "</xsl:text>
107       <xsl:value-of select="normalize-space($productname)"/>
108       <xsl:text>" "</xsl:text>
109       <xsl:value-of select="$title"/>
110       <xsl:text>"
111 </xsl:text>
112       <xsl:apply-templates/>
113       <xsl:text>&#10;</xsl:text>
114
115       <!-- Author section -->
116       <xsl:choose>
117         <xsl:when test="refentryinfo//author">
118           <xsl:apply-templates select="refentryinfo" mode="authorsect"/>
119         </xsl:when>
120       </xsl:choose>
121     </xsl:with-param>
122   </xsl:call-template>
123 </xsl:template>
124
125 <xsl:template match="informalexample|screen|programlisting">
126   <xsl:text>.nf&#10;</xsl:text>
127   <xsl:apply-templates/>
128   <xsl:text>.fi&#10;</xsl:text>
129 </xsl:template>
130
131 <xsl:template match="//emphasis">
132   <xsl:text>\fB</xsl:text>
133   <xsl:apply-templates/>
134   <xsl:text>\fR</xsl:text>
135 </xsl:template>
136
137 <xsl:template match="para|simpara|remark" mode="list">
138   <xsl:variable name="foo">
139     <xsl:apply-templates/>
140   </xsl:variable>
141   <xsl:choose match="node()">
142     <!-- Don't normalize-space() for verbatim paragraphs        -->
143     <xsl:when test="informalexample|screen|programlisting">
144       <xsl:value-of select="$foo"/>
145     </xsl:when>
146     <xsl:otherwise>
147       <xsl:value-of select="normalize-space($foo)"/>
148       <xsl:text>&#10;</xsl:text>
149     </xsl:otherwise>
150   </xsl:choose>
151   <xsl:text>&#10;</xsl:text>
152   <xsl:if test="following-sibling::para or following-sibling::simpara or
153                 following-sibling::remark">
154     <!-- Make sure multiple paragraphs within a list item don't -->
155     <!-- merge together.                                        -->
156     <xsl:text>&#10;</xsl:text>
157   </xsl:if>
158 </xsl:template>
159
160 <xsl:template match="refsect3">
161   <xsl:text>&#10;.SS "</xsl:text>
162   <xsl:value-of select="title[1]"/>
163   <xsl:text>"&#10;</xsl:text>
164   <xsl:apply-templates/>
165 </xsl:template>
166
167
168 </xsl:stylesheet>