Debian Codegraph @

docs/xsl-generic/manpages/docbook.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:exsl="http://exslt.org/common"
4 xmlns:ng="http://docbook.org/docbook-ng"
5 xmlns:db="http://docbook.org/ns/docbook"
6 exclude-result-prefixes="exsl"
7 version='1.0'>
8
9 <xsl:import href="../html/docbook.xsl"/>
10 <xsl:import href="../html/manifest.xsl"/>
11 <!-- * html-synop.xsl file is generated by build -->
12 <xsl:import href="html-synop.xsl"/>
13 <xsl:output method="text"
14 encoding="UTF-8"
15 indent="no"/>
16 <!-- ********************************************************************
17 $Id: docbook.xsl 7153 2007-07-26 14:08:55Z xmldoc $
18 ********************************************************************
19
20 This file is part of the XSL DocBook Stylesheet distribution.
21 See ../README or http://docbook.sf.net/release/xsl/current/ for
22 copyright and other information.
23
24 ******************************************************************** -->
25
26 <!-- ==================================================================== -->
27
28 <xsl:include href="../common/refentry.xsl"/>
29 <xsl:include href="../common/charmap.xsl"/>
30 <xsl:include href="param.xsl"/>
31 <xsl:include href="utility.xsl"/>
32 <xsl:include href="info.xsl"/>
33 <xsl:include href="other.xsl"/>
34 <xsl:include href="refentry.xsl"/>
35 <xsl:include href="block.xsl"/>
36 <xsl:include href="inline.xsl"/>
37 <xsl:include href="synop.xsl"/>
38 <xsl:include href="lists.xsl"/>
39 <xsl:include href="endnotes.xsl"/>
40 <xsl:include href="table.xsl"/>
41
42 <!-- * we rename the following just to avoid using params with "man" -->
43 <!-- * prefixes in the table.xsl stylesheet (because that stylesheet -->
44 <!-- * can potentially be reused for more than just man output) -->
45 <xsl:param name="tbl.font.headings" select="$man.font.table.headings"/>
46 <xsl:param name="tbl.font.title" select="$man.font.table.title"/>
47
48 <!-- ==================================================================== -->
49
50 <xsl:template match="/">
51 <!-- * Get a title for current doc so that we let the user -->
52 <!-- * know what document we are processing at this point. -->
53 <xsl:variable name="doc.title">
54 <xsl:call-template name="get.doc.title"/>
55 </xsl:variable>
56 <xsl:choose>
57 <!-- * when we find a namespaced document, strip the -->
58 <!-- * namespace and then continue processing it. -->
59 <xsl:when test="//self::db:*">
60 <xsl:call-template name="log.message">
61 <xsl:with-param name="level">Note</xsl:with-param>
62 <xsl:with-param name="source" select="$doc.title"/>
63 <xsl:with-param name="context-desc">
64 <xsl:text>namesp. cut</xsl:text>
65 </xsl:with-param>
66 <xsl:with-param name="message">
67 <xsl:text>stripped namespace before processing</xsl:text>
68 </xsl:with-param>
69 </xsl:call-template>
70 <xsl:variable name="stripns">
71 <xsl:apply-templates mode="stripNS"/>
72 </xsl:variable>
73 <xsl:call-template name="log.message">
74 <xsl:with-param name="level">Note</xsl:with-param>
75 <xsl:with-param name="source" select="$doc.title"/>
76 <xsl:with-param name="context-desc">
77 <xsl:text>namesp. cut</xsl:text>
78 </xsl:with-param>
79 <xsl:with-param name="message">
80 <xsl:text>processing stripped document</xsl:text>
81 </xsl:with-param>
82 </xsl:call-template>
83 <xsl:apply-templates select="exsl:node-set($stripns)"/>
84 </xsl:when>
85 <xsl:when test="//*[local-name() = 'refentry']">
86 <!-- * Check to see if we have any refentry children in this -->
87 <!-- * document; if so, process them. The reason we use -->
88 <!-- * local-name()=refentry (instead of just //refentry) to to -->
89 <!-- * check for refentry children is because this stylsheet is -->
90 <!-- * also post-processed by the stylesheet build to create the -->
91 <!-- * manpages/profile-docbook.xsl, and the refentry child check -->
92 <!-- * in the profile-docbook.xsl stylesheet won't work if we do -->
93 <!-- * a simple //refentry check. -->
94 <xsl:apply-templates select="//refentry"/>
95 <!-- * if $man.output.manifest.enabled is non-zero, -->
96 <!-- * generate a manifest file -->
97 <xsl:if test="not($man.output.manifest.enabled = 0)">
98 <xsl:call-template name="generate.manifest">
99 <xsl:with-param name="filename">
100 <xsl:choose>
101 <xsl:when test="not($man.output.manifest.filename = '')">
102 <!-- * If a name for the manifest file is specified, -->
103 <!-- * use that name. -->
104 <xsl:value-of select="$man.output.manifest.filename"/>
105 </xsl:when>
106 <xsl:otherwise>
107 <!-- * Otherwise, if user has unset -->
108 <!-- * $man.output.manifest.filename, default to -->
109 <!-- * using "MAN.MANIFEST" as the filename. Because -->
110 <!-- * $man.output.manifest.enabled is non-zero and -->
111 <!-- * so we must have a filename in order to -->
112 <!-- * generate the manifest. -->
113 <xsl:text>MAN.MANIFEST</xsl:text>
114 </xsl:otherwise>
115 </xsl:choose>
116 </xsl:with-param>
117 </xsl:call-template>
118 </xsl:if>
119 </xsl:when>
120 <xsl:otherwise>
121 <!-- * Otherwise, the document does not contain any -->
122 <!-- * refentry elements, so log/emit message and stop. -->
123 <xsl:call-template name="log.message">
124 <xsl:with-param name="level">Erro</xsl:with-param>
125 <xsl:with-param name="source" select="$doc.title"/>
126 <xsl:with-param name="context-desc">
127 <xsl:text> no refentry</xsl:text>
128 </xsl:with-param>
129 <xsl:with-param name="message">
130 <xsl:text>No refentry elements found</xsl:text>
131 <xsl:if test="$doc.title != ''">
132 <xsl:text> in "</xsl:text>
133 <xsl:choose>
134 <xsl:when test="string-length($doc.title) &gt; 30">
135 <xsl:value-of select="substring($doc.title,1,30)"/>
136 <xsl:text>...</xsl:text>
137 </xsl:when>
138 <xsl:otherwise>
139 <xsl:value-of select="$doc.title"/>
140 </xsl:otherwise>
141 </xsl:choose>
142 <xsl:text>"</xsl:text>
143 </xsl:if>
144 <xsl:text>.</xsl:text>
145 </xsl:with-param>
146 </xsl:call-template>
147 </xsl:otherwise>
148 </xsl:choose>
149 </xsl:template>
150
151 <!-- ============================================================== -->
152
153 <xsl:template match="refentry">
154 <xsl:param name="lang">
155 <xsl:call-template name="l10n.language"/>
156 </xsl:param>
157 <!-- * Just use the first refname found as the "name" of the man -->
158 <!-- * page (which may different from the "title"...) -->
159 <xsl:variable name="first.refname" select="refnamediv[1]/refname[1]"/>
160
161 <xsl:call-template name="root.messages">
162 <xsl:with-param name="refname" select="$first.refname"/>
163 </xsl:call-template>
164
165 <!-- * Because there are several times when we need to check *info of -->
166 <!-- * each refentry and its ancestors, we get those and store the -->
167 <!-- * data from them as a node-set in memory. -->
168
169 <!-- * Make a node-set with contents of *info -->
170 <xsl:variable name="get.info"
171 select="ancestor-or-self::*/*[substring(local-name(),
172 string-length(local-name()) - 3) = 'info']"
173 />
174 <xsl:variable name="info" select="exsl:node-set($get.info)"/>
175
176 <!-- * The get.refentry.metadata template is in -->
177 <!-- * ../common/refentry.xsl. It looks for metadata in $info -->
178 <!-- * and in various other places and then puts it into a form -->
179 <!-- * that's easier for us to digest. -->
180 <xsl:variable name="get.refentry.metadata">
181 <xsl:call-template name="get.refentry.metadata">
182 <xsl:with-param name="refname" select="$first.refname"/>
183 <xsl:with-param name="info" select="$info"/>
184 <xsl:with-param name="prefs" select="$refentry.metadata.prefs"/>
185 </xsl:call-template>
186 </xsl:variable>
187 <xsl:variable name="refentry.metadata" select="exsl:node-set($get.refentry.metadata)"/>
188
189 <!-- * Assemble the various parts into a complete page, then store into -->
190 <!-- * $manpage.contents so that we can manipluate them further. -->
191 <xsl:variable name="manpage.contents">
192 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
193 <!-- * top.comment = commented-out section at top of roff source -->
194 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
195 <xsl:call-template name="top.comment">
196 <xsl:with-param name="info" select="$info"/>
197 <xsl:with-param name="date" select="$refentry.metadata/date"/>
198 <xsl:with-param name="title" select="$refentry.metadata/title"/>
199 <xsl:with-param name="manual" select="$refentry.metadata/manual"/>
200 <xsl:with-param name="source" select="$refentry.metadata/source"/>
201 </xsl:call-template>
202 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
203 <!-- * TH.title.line = title line in header/footer of man page -->
204 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
205 <xsl:call-template name="TH.title.line">
206 <!-- * .TH TITLE section extra1 extra2 extra3 -->
207 <!-- * -->
208 <!-- * According to the man(7) man page: -->
209 <!-- * -->
210 <!-- * extra1 = date, "the date of the last revision" -->
211 <!-- * extra2 = source, "the source of the command" -->
212 <!-- * extra3 = manual, "the title of the manual -->
213 <!-- * (e.g., Linux Programmer's Manual)" -->
214 <!-- * -->
215 <!-- * So, we end up with: -->
216 <!-- * -->
217 <!-- * .TH TITLE section date source manual -->
218 <!-- * -->
219 <xsl:with-param name="title" select="$refentry.metadata/title"/>
220 <xsl:with-param name="section" select="$refentry.metadata/section"/>
221 <xsl:with-param name="extra1" select="$refentry.metadata/date"/>
222 <xsl:with-param name="extra2" select="$refentry.metadata/source"/>
223 <xsl:with-param name="extra3" select="$refentry.metadata/manual"/>
224 </xsl:call-template>
225 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
226 <!-- * Set default hyphenation, justification, indentation, and -->
227 <!-- * line-breaking -->
228 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
229 <xsl:call-template name="set.default.formatting"/>
230 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
231 <!-- * Main body of man page -->
232 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
233 <xsl:apply-templates/>
234 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
235 <!-- * AUTHOR section -->
236 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
237 <xsl:if test="not($man.authors.section.enabled = 0)">
238 <xsl:call-template name="author.section">
239 <xsl:with-param name="info" select="$info"/>
240 </xsl:call-template>
241 </xsl:if>
242 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
243 <!-- * COPYRIGHT section -->
244 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
245 <xsl:if test="not($man.copyright.section.enabled = 0)">
246 <xsl:call-template name="copyright.section">
247 <xsl:with-param name="info" select="$info"/>
248 </xsl:call-template>
249 </xsl:if>
250 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
251 <!-- * NOTES list (only if user wants endnotes numbered and/or listed) -->
252 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
253 <xsl:if test="$man.endnotes.list.enabled != 0 or
254 $man.endnotes.are.numbered != 0">
255 <xsl:call-template name="endnotes.list"/>
256 </xsl:if>
257 </xsl:variable> <!-- * end of manpage.contents -->
258
259 <!-- * Prepare the page contents for final output, then store in -->
260 <!-- * $manpage.contents.prepared so the we can pass it on to the -->
261 <!-- * write.text.chunk() function -->
262 <xsl:variable name="manpage.contents.prepared">
263 <!-- * "Preparing" the page contents involves, at a minimum, -->
264 <!-- * doubling any backslashes found (so they aren't interpreted -->
265 <!-- * as roff escapes). -->
266 <!-- * -->
267 <!-- * If $charmap.enabled is true, "preparing" the page contents also -->
268 <!-- * involves applying a character map to convert Unicode symbols and -->
269 <!-- * special characters into corresponding roff escape sequences. -->
270 <xsl:call-template name="prepare.manpage.contents">
271 <xsl:with-param name="content" select="$manpage.contents"/>
272 </xsl:call-template>
273 </xsl:variable>
274
275 <!-- * Write the prepared page contents to disk to create -->
276 <!-- * the final man page. -->
277 <xsl:call-template name="write.man.file">
278 <xsl:with-param name="name" select="$first.refname"/>
279 <xsl:with-param name="section" select="$refentry.metadata/section"/>
280 <xsl:with-param name="lang" select="$lang"/>
281 <xsl:with-param name="content" select="$manpage.contents.prepared"/>
282 </xsl:call-template>
283
284 <!-- * Generate "stub" (alias) pages (if any needed) -->
285 <xsl:call-template name="write.stubs">
286 <xsl:with-param name="first.refname" select="$first.refname"/>
287 <xsl:with-param name="section" select="$refentry.metadata/section"/>
288 <xsl:with-param name="lang" select="$lang"/>
289 </xsl:call-template>
290
291 </xsl:template>
292
293 </xsl:stylesheet>