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,v 1.1 2007/03/10 05:15:34 scott Exp $
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=
"param.xsl"/>
30 <xsl:include href=
"utility.xsl"/>
31 <xsl:include href=
"info.xsl"/>
32 <xsl:include href=
"other.xsl"/>
33 <xsl:include href=
"refentry.xsl"/>
34 <xsl:include href=
"block.xsl"/>
35 <xsl:include href=
"inline.xsl"/>
36 <xsl:include href=
"synop.xsl"/>
37 <xsl:include href=
"lists.xsl"/>
38 <xsl:include href=
"endnotes.xsl"/>
39 <xsl:include href=
"table.xsl"/>
41 <!-- * we rename the following just to avoid using params with "man" -->
42 <!-- * prefixes in the table.xsl stylesheet (because that stylesheet -->
43 <!-- * can potentially be reused for more than just man output) -->
44 <xsl:param name=
"tbl.font.headings" select=
"$man.font.table.headings"/>
45 <xsl:param name=
"tbl.font.title" select=
"$man.font.table.title"/>
47 <!-- ==================================================================== -->
49 <xsl:template match=
"/">
51 <xsl:when test=
"//refentry">
52 <!-- * Check to see if we have any refentry children in this -->
53 <!-- * document; if so, process them. -->
54 <xsl:apply-templates select=
"//refentry"/>
55 <!-- * if $man.output.manifest.enabled is non-zero, -->
56 <!-- * generate a manifest file -->
57 <xsl:if test=
"not($man.output.manifest.enabled = 0)">
58 <xsl:call-template name=
"generate.manifest">
59 <xsl:with-param name=
"filename">
61 <xsl:when test=
"not($man.output.manifest.filename = '')">
62 <!-- * If a name for the manifest file is specified, -->
63 <!-- * use that name. -->
64 <xsl:value-of select=
"$man.output.manifest.filename"/>
67 <!-- * Otherwise, if user has unset -->
68 <!-- * $man.output.manifest.filename, default to -->
69 <!-- * using "MAN.MANIFEST" as the filename. Because -->
70 <!-- * $man.output.manifest.enabled is non-zero and -->
71 <!-- * so we must have a filename in order to -->
72 <!-- * generate the manifest. -->
73 <xsl:text>MAN.MANIFEST
</xsl:text>
81 <!-- * Otherwise, the document does not contain any -->
82 <!-- * refentry elements, so emit message and stop. -->
83 <xsl:variable name=
"title">
84 <!-- * Get a title so that we let the user know what -->
85 <!-- * document we are processing at this point. -->
87 <xsl:when test=
"title">
88 <xsl:value-of select=
"title[1]"/>
90 <xsl:when test=
"substring(local-name(*[1]),
91 string-length(local-name(*[1])-3) = 'info')
93 <xsl:value-of select=
"*[1]/title[1]"/>
98 <xsl:text>Note: No refentry elements found in
"</xsl:text>
99 <xsl:value-of select="local-name(.)
"/>
100 <xsl:if test="$title != ''
">
102 <xsl:when test="string-length($title)
> 30">
103 <xsl:value-of select="substring($title,
1,
30)
"/>
104 <xsl:text>...</xsl:text>
107 <xsl:value-of select="$title
"/>
111 <xsl:text>"</xsl:text>
117 <!-- ============================================================== -->
119 <xsl:template match=
"refentry">
120 <xsl:param name=
"lang">
121 <xsl:call-template name=
"l10n.language"/>
123 <!-- * Just use the first refname found as the "name" of the man -->
124 <!-- * page (which may different from the "title"...) -->
125 <xsl:variable name=
"first.refname" select=
"refnamediv[1]/refname[1]"/>
127 <xsl:call-template name=
"root.messages">
128 <xsl:with-param name=
"refname" select=
"$first.refname"/>
131 <!-- * Because there are several times when we need to check *info of -->
132 <!-- * each refentry and its ancestors, we get those and store the -->
133 <!-- * data from them as a node-set in memory. -->
135 <!-- * Make a node-set with contents of *info -->
136 <xsl:variable name=
"get.info"
137 select=
"ancestor-or-self::*/*[substring(local-name(),
138 string-length(local-name()) - 3) = 'info']"
140 <xsl:variable name=
"info" select=
"exsl:node-set($get.info)"/>
142 <!-- * The get.refentry.metadata template is in -->
143 <!-- * ../common/refentry.xsl. It looks for metadata in $info -->
144 <!-- * and in various other places and then puts it into a form -->
145 <!-- * that's easier for us to digest. -->
146 <xsl:variable name=
"get.refentry.metadata">
147 <xsl:call-template name=
"get.refentry.metadata">
148 <xsl:with-param name=
"refname" select=
"$first.refname"/>
149 <xsl:with-param name=
"info" select=
"$info"/>
150 <xsl:with-param name=
"prefs" select=
"$refentry.metadata.prefs"/>
153 <xsl:variable name=
"refentry.metadata" select=
"exsl:node-set($get.refentry.metadata)"/>
155 <!-- * Assemble the various parts into a complete page, then store into -->
156 <!-- * $manpage.contents so that we can manipluate them further. -->
157 <xsl:variable name=
"manpage.contents">
158 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
159 <!-- * top.comment = commented-out section at top of roff source -->
160 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
161 <xsl:call-template name=
"top.comment">
162 <xsl:with-param name=
"info" select=
"$info"/>
163 <xsl:with-param name=
"date" select=
"$refentry.metadata/date"/>
164 <xsl:with-param name=
"title" select=
"$refentry.metadata/title"/>
165 <xsl:with-param name=
"manual" select=
"$refentry.metadata/manual"/>
166 <xsl:with-param name=
"source" select=
"$refentry.metadata/source"/>
168 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
169 <!-- * TH.title.line = title line in header/footer of man page -->
170 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
171 <xsl:call-template name=
"TH.title.line">
172 <!-- * .TH TITLE section extra1 extra2 extra3 -->
174 <!-- * According to the man(7) man page: -->
176 <!-- * extra1 = date, "the date of the last revision" -->
177 <!-- * extra2 = source, "the source of the command" -->
178 <!-- * extra3 = manual, "the title of the manual -->
179 <!-- * (e.g., Linux Programmer's Manual)" -->
181 <!-- * So, we end up with: -->
183 <!-- * .TH TITLE section date source manual -->
185 <xsl:with-param name=
"title" select=
"$refentry.metadata/title"/>
186 <xsl:with-param name=
"section" select=
"$refentry.metadata/section"/>
187 <xsl:with-param name=
"extra1" select=
"$refentry.metadata/date"/>
188 <xsl:with-param name=
"extra2" select=
"$refentry.metadata/source"/>
189 <xsl:with-param name=
"extra3" select=
"$refentry.metadata/manual"/>
191 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
192 <!-- * Set default hyphenation, justification, indentation, and -->
193 <!-- * line-breaking -->
194 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
195 <xsl:call-template name=
"set.default.formatting"/>
196 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
197 <!-- * Main body of man page -->
198 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
199 <xsl:apply-templates/>
200 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
201 <!-- * AUTHOR section -->
202 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
203 <xsl:call-template name=
"author.section">
204 <xsl:with-param name=
"info" select=
"$info"/>
206 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
207 <!-- * COPYRIGHT section -->
208 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
209 <xsl:call-template name=
"copyright.section">
210 <xsl:with-param name=
"info" select=
"$info"/>
212 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
213 <!-- * NOTES list (only if user wants endnotes numbered and/or listed) -->
214 <!-- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
215 <xsl:if test=
"$man.endnotes.list.enabled != 0 or
216 $man.endnotes.are.numbered != 0">
217 <xsl:call-template name=
"endnotes.list"/>
219 </xsl:variable> <!-- * end of manpage.contents -->
221 <!-- * Prepare the page contents for final output, then store in -->
222 <!-- * $manpage.contents.prepared so the we can pass it on to the -->
223 <!-- * write.text.chunk() function -->
224 <xsl:variable name=
"manpage.contents.prepared">
225 <!-- * "Preparing" the page contents involves, at a minimum, -->
226 <!-- * doubling any backslashes found (so they aren't interpreted -->
227 <!-- * as roff escapes). -->
229 <!-- * If $charmap.enabled is true, "preparing" the page contents also -->
230 <!-- * involves applying a character map to convert Unicode symbols and -->
231 <!-- * special characters into corresponding roff escape sequences. -->
232 <xsl:call-template name=
"prepare.manpage.contents">
233 <xsl:with-param name=
"content" select=
"$manpage.contents"/>
237 <!-- * Write the prepared page contents to disk to create -->
238 <!-- * the final man page. -->
239 <xsl:call-template name=
"write.man.file">
240 <xsl:with-param name=
"name" select=
"$first.refname"/>
241 <xsl:with-param name=
"section" select=
"$refentry.metadata/section"/>
242 <xsl:with-param name=
"lang" select=
"$lang"/>
243 <xsl:with-param name=
"content" select=
"$manpage.contents.prepared"/>
246 <!-- * Generate "stub" (alias) pages (if any needed) -->
247 <xsl:call-template name=
"write.stubs">
248 <xsl:with-param name=
"first.refname" select=
"$first.refname"/>
249 <xsl:with-param name=
"section" select=
"$refentry.metadata/section"/>
250 <xsl:with-param name=
"lang" select=
"$lang"/>