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"
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"
16 <!-- ********************************************************************
17 $Id: docbook.xsl 8841 2010-08-14 07:21:25Z mzjn $
18 ********************************************************************
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.
24 ******************************************************************** -->
26 <!-- ==================================================================== -->
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 <xsl:include href="pi.xsl"/>
43 <!-- * we rename the following just to avoid using params with "man" -->
44 <!-- * prefixes in the table.xsl stylesheet (because that stylesheet -->
45 <!-- * can potentially be reused for more than just man output) -->
46 <xsl:param name="tbl.font.headings" select="$man.font.table.headings"/>
47 <xsl:param name="tbl.font.title" select="$man.font.table.title"/>
49 <xsl:param name="stylesheet.result.type" select="'manpages'"/>
51 <!-- ==================================================================== -->
53 <xsl:template match="/">
54 <!-- * Get a title for current doc so that we let the user -->
55 <!-- * know what document we are processing at this point. -->
56 <xsl:variable name="doc.title">
57 <xsl:call-template name="get.doc.title"/>
60 <!-- * when we find a namespaced document, strip the -->
61 <!-- * namespace and then continue processing it. -->
62 <xsl:when test="//self::db:*">
63 <xsl:call-template name="log.message">
64 <xsl:with-param name="level">Note</xsl:with-param>
65 <xsl:with-param name="source" select="$doc.title"/>
66 <xsl:with-param name="context-desc">
67 <xsl:text>namesp. cut</xsl:text>
69 <xsl:with-param name="message">
70 <xsl:text>stripped namespace before processing</xsl:text>
73 <xsl:variable name="stripns">
74 <xsl:apply-templates mode="stripNS"/>
76 <xsl:call-template name="log.message">
77 <xsl:with-param name="level">Note</xsl:with-param>
78 <xsl:with-param name="source" select="$doc.title"/>
79 <xsl:with-param name="context-desc">
80 <xsl:text>namesp. cut</xsl:text>
82 <xsl:with-param name="message">
83 <xsl:text>processing stripped document</xsl:text>
86 <xsl:apply-templates select="exsl:node-set($stripns)"/>
88 <xsl:when test="//*[local-name() = 'refentry']">
89 <!-- * Check to see if we have any refentry children in this -->
90 <!-- * document; if so, process them. The reason we use -->
91 <!-- * local-name()=refentry (instead of just //refentry) to to -->
92 <!-- * check for refentry children is because this stylsheet is -->
93 <!-- * also post-processed by the stylesheet build to create the -->
94 <!-- * manpages/profile-docbook.xsl, and the refentry child check -->
95 <!-- * in the profile-docbook.xsl stylesheet won't work if we do -->
96 <!-- * a simple //refentry check. -->
97 <xsl:apply-templates select="//refentry"/>
98 <!-- * if $man.output.manifest.enabled is non-zero, -->
99 <!-- * generate a manifest file -->
100 <xsl:if test="not($man.output.manifest.enabled = 0)">
101 <xsl:call-template name="generate.manifest">
102 <xsl:with-param name="filename">
104 <xsl:when test="not($man.output.manifest.filename = '')">
105 <!-- * If a name for the manifest file is specified, -->
106 <!-- * use that name. -->
107 <xsl:value-of select="$man.output.manifest.filename"/>
110 <!-- * Otherwise, if user has unset -->
111 <!-- * $man.output.manifest.filename, default to -->
112 <!-- * using "MAN.MANIFEST" as the filename. Because -->
113 <!-- * $man.output.manifest.enabled is non-zero and -->
114 <!-- * so we must have a filename in order to -->
115 <!-- * generate the manifest. -->
116 <xsl:text>MAN.MANIFEST</xsl:text>
124 <!-- * Otherwise, the document does not contain any -->
125 <!-- * refentry elements, so log/emit message and stop. -->
126 <xsl:call-template name="log.message">
127 <xsl:with-param name="level">Erro</xsl:with-param>
128 <xsl:with-param name="source" select="$doc.title"/>
129 <xsl:with-param name="context-desc">
130 <xsl:text> no refentry</xsl:text>
132 <xsl:with-param name="message">
133 <xsl:text>No refentry elements found</xsl:text>
134 <xsl:if test="$doc.title != ''">
135 <xsl:text> in "</xsl:text>
137 <xsl:when test="string-length($doc.title) > 30">
138 <xsl:value-of select="substring($doc.title,1,30)"/>
139 <xsl:text>...</xsl:text>
142 <xsl:value-of select="$doc.title"/>
145 <xsl:text>"</xsl:text>
147 <xsl:text>.</xsl:text>
154 <!-- ============================================================== -->
156 <xsl:template match="refentry">
157 <xsl:param name="lang">
158 <xsl:call-template name="l10n.language"/>
160 <!-- * Just use the first refname found as the "name" of the man -->
161 <!-- * page (which may different from the "title"...) -->
162 <xsl:variable name="first.refname" select="refnamediv[1]/refname[1]"/>
164 <xsl:call-template name="root.messages">
165 <xsl:with-param name="refname" select="$first.refname"/>
168 <!-- * Because there are several times when we need to check *info of -->
169 <!-- * each refentry and its ancestors, we get those and store the -->
170 <!-- * data from them as a node-set in memory. -->
172 <!-- * Make a node-set with contents of *info -->
173 <xsl:variable name="get.info"
174 select="ancestor-or-self::*/*[substring(local-name(),
175 string-length(local-name()) - 3) = 'info']"
177 <xsl:variable name="info" select="exsl:node-set($get.info)"/>
179 <!-- * The get.refentry.metadata template is in -->
180 <!-- * ../common/refentry.xsl. It looks for metadata in $info -->
181 <!-- * and in various other places and then puts it into a form -->
182 <!-- * that's easier for us to digest. -->
183 <xsl:variable name="get.refentry.metadata">
184 <xsl:call-template name="get.refentry.metadata">
185 <xsl:with-param name="refname" select="$first.refname"/>
186 <xsl:with-param name="info" select="$info"/>
187 <xsl:with-param name="prefs" select="$refentry.metadata.prefs"/>
190 <xsl:variable name="refentry.metadata" select="exsl:node-set($get.refentry.metadata)"/>
192 <!-- * Assemble the various parts into a complete page, then store into -->
193 <!-- * $manpage.contents so that we can manipluate them further. -->
194 <xsl:variable name="manpage.contents">
195 <!-- * preprocessor invocation (need for legacy AT&T troff use) -->
196 <!-- * this tells troff to pre-process the page through tbl(1) -->
197 <!-- * (groff can figure it out automatically, but AT&T troff can't) -->
198 <xsl:text>'\" t </xsl:text>
199 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
200 <!-- * top.comment = commented-out section at top of roff source -->
201 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
202 <xsl:call-template name="top.comment">
203 <xsl:with-param name="info" select="$info"/>
204 <xsl:with-param name="date" select="$refentry.metadata/date"/>
205 <xsl:with-param name="title" select="$refentry.metadata/title"/>
206 <xsl:with-param name="manual" select="$refentry.metadata/manual"/>
207 <xsl:with-param name="source" select="$refentry.metadata/source"/>
208 <xsl:with-param name="refname" select="$first.refname"/>
210 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
211 <!-- * TH.title.line = title line in header/footer of man page -->
212 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
213 <xsl:call-template name="TH.title.line">
214 <!-- * .TH TITLE section extra1 extra2 extra3 -->
216 <!-- * According to the man(7) man page: -->
218 <!-- * extra1 = date, "the date of the last revision" -->
219 <!-- * extra2 = source, "the source of the command" -->
220 <!-- * extra3 = manual, "the title of the manual -->
221 <!-- * (e.g., Linux Programmer's Manual)" -->
223 <!-- * So, we end up with: -->
225 <!-- * .TH TITLE section date source manual -->
227 <xsl:with-param name="title" select="$refentry.metadata/title"/>
228 <xsl:with-param name="section" select="$refentry.metadata/section"/>
229 <xsl:with-param name="extra1" select="$refentry.metadata/date"/>
230 <xsl:with-param name="extra2" select="$refentry.metadata/source"/>
231 <xsl:with-param name="extra3" select="$refentry.metadata/manual"/>
233 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
234 <!-- * (re)define some macros -->
235 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
236 <xsl:call-template name="define.portability.macros"/>
237 <xsl:if test="not($man.output.better.ps.enabled = 0)">
238 <xsl:call-template name="define.macros"/>
240 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
241 <!-- * Set default hyphenation, justification, indentation, and -->
242 <!-- * line-breaking -->
243 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
244 <xsl:call-template name="set.default.formatting"/>
245 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
246 <!-- * Main body of man page -->
247 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
248 <xsl:text>.\" ----------------------------------------------------------------- </xsl:text>
249 <xsl:text>.\" * MAIN CONTENT STARTS HERE * </xsl:text>
250 <xsl:text>.\" ----------------------------------------------------------------- </xsl:text>
251 <xsl:apply-templates/>
252 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
253 <!-- * AUTHOR section -->
254 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
255 <xsl:if test="not($man.authors.section.enabled = 0)">
256 <xsl:call-template name="author.section">
257 <xsl:with-param name="info" select="$info"/>
260 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
261 <!-- * COPYRIGHT section -->
262 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
263 <xsl:if test="not($man.copyright.section.enabled = 0)">
264 <xsl:call-template name="copyright.section">
265 <xsl:with-param name="info" select="$info"/>
268 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
269 <!-- * NOTES list (only if user wants endnotes numbered and/or listed) -->
270 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
271 <xsl:if test="$man.endnotes.list.enabled != 0 or
272 $man.endnotes.are.numbered != 0">
273 <xsl:call-template name="endnotes.list"/>
275 </xsl:variable> <!-- * end of manpage.contents -->
277 <!-- * Prepare the page contents for final output, then store in -->
278 <!-- * $manpage.contents.prepared so the we can pass it on to the -->
279 <!-- * write.text.chunk() function -->
280 <xsl:variable name="manpage.contents.prepared">
281 <!-- * "Preparing" the page contents involves, at a minimum, -->
282 <!-- * doubling any backslashes found (so they aren't interpreted -->
283 <!-- * as roff escapes). -->
285 <!-- * If $charmap.enabled is true, "preparing" the page contents also -->
286 <!-- * involves applying a character map to convert Unicode symbols and -->
287 <!-- * special characters into corresponding roff escape sequences. -->
288 <xsl:call-template name="prepare.manpage.contents">
289 <xsl:with-param name="content" select="$manpage.contents"/>
293 <!-- * Write the prepared page contents to disk to create -->
294 <!-- * the final man page. -->
295 <xsl:call-template name="write.man.file">
296 <xsl:with-param name="name" select="$first.refname"/>
297 <xsl:with-param name="section" select="$refentry.metadata/section"/>
298 <xsl:with-param name="lang" select="$lang"/>
299 <xsl:with-param name="content" select="$manpage.contents.prepared"/>
302 <!-- * Generate "stub" (alias) pages (if any needed) -->
303 <xsl:call-template name="write.stubs">
304 <xsl:with-param name="first.refname" select="$first.refname"/>
305 <xsl:with-param name="section" select="$refentry.metadata/section"/>
306 <xsl:with-param name="lang" select="$lang"/>