VirtualBox

source: vbox/trunk/doc/manual/docbook2latex.xsl@ 96758

Last change on this file since 96758 was 96615, checked in by vboxsync, 2 years ago

doc/manual/docbook2latex.xsl: Also eliminate package utf8.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 50.2 KB
Line 
1<?xml version="1.0"?>
2
3<!--
4 docbook2latex.xslt:
5 translates a DocBook XML source into a LaTeX source file,
6 which can be processed with pdflatex to produce a
7 pretty PDF file.
8
9 Note: In the LaTeX output, this XSLT encodes all quotes
10 with \QUOTE{} commands, which are not defined in this
11 file. This is because XSLT does not support regular
12 expressions natively and therefore it is rather difficult
13 to implement proper "pretty quotes" (different glyphs for
14 opening and closing quotes) in XSLT. The doc/manual/
15 makefile solves this by running sed over the LaTeX source
16 once more, replacing all \QUOTE{} commands with
17 \OQ{} and \CQ{} commands, which _are_ defined to the
18 pretty quotes for English in the LaTeX output generated
19 by this XSLT (see below).
20-->
21<!--
22 Copyright (C) 2006-2022 Oracle and/or its affiliates.
23
24 This file is part of VirtualBox base platform packages, as
25 available from https://www.virtualbox.org.
26
27 This program is free software; you can redistribute it and/or
28 modify it under the terms of the GNU General Public License
29 as published by the Free Software Foundation, in version 3 of the
30 License.
31
32 This program is distributed in the hope that it will be useful, but
33 WITHOUT ANY WARRANTY; without even the implied warranty of
34 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
35 General Public License for more details.
36
37 You should have received a copy of the GNU General Public License
38 along with this program; if not, see <https://www.gnu.org/licenses>.
39
40 SPDX-License-Identifier: GPL-3.0-only
41-->
42
43<xsl:stylesheet
44 version="1.0"
45 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
46 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
47 xmlns:str="http://xsltsl.org/string"
48>
49
50 <xsl:import href="string.xsl"/>
51 <xsl:import href="common-formatcfg.xsl"/>
52
53 <xsl:variable name="g_nlsChapter">
54 <xsl:choose>
55 <xsl:when test="$TARGETLANG='de_DE'">Kapitel</xsl:when>
56 <xsl:when test="$TARGETLANG='fr_FR'">chapitre</xsl:when>
57 <xsl:when test="$TARGETLANG='en_US'">chapter</xsl:when>
58 <xsl:otherwise>
59 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
60 </xsl:otherwise>
61 </xsl:choose>
62 </xsl:variable>
63
64 <xsl:variable name="g_nlsPage">
65 <xsl:choose>
66 <xsl:when test="$TARGETLANG='de_DE'">auf Seite</xsl:when>
67 <xsl:when test="$TARGETLANG='fr_FR'">page</xsl:when>
68 <xsl:when test="$TARGETLANG='en_US'">page</xsl:when>
69 <xsl:otherwise>
70 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
71 </xsl:otherwise>
72 </xsl:choose>
73 </xsl:variable>
74
75 <xsl:variable name="g_nlsNote">
76 <xsl:choose>
77 <xsl:when test="$TARGETLANG='de_DE'">Hinweis</xsl:when>
78 <xsl:when test="$TARGETLANG='fr_FR'">Note</xsl:when>
79 <xsl:when test="$TARGETLANG='en_US'">Note</xsl:when>
80 <xsl:otherwise>
81 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
82 </xsl:otherwise>
83 </xsl:choose>
84 </xsl:variable>
85
86 <xsl:variable name="g_nlsWarning">
87 <xsl:choose>
88 <xsl:when test="$TARGETLANG='de_DE'">Warnung</xsl:when>
89 <xsl:when test="$TARGETLANG='fr_FR'">Avertissement</xsl:when>
90 <xsl:when test="$TARGETLANG='en_US'">Warning</xsl:when>
91 <xsl:otherwise>
92 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
93 </xsl:otherwise>
94 </xsl:choose>
95 </xsl:variable>
96
97 <!-- command synopsis -->
98 <xsl:variable name="arg.rep.repeat.str.tex">\ldots{}</xsl:variable>
99 <xsl:variable name="arg.or.sep.tex"> |~</xsl:variable>
100
101 <xsl:output method="text"/>
102
103 <xsl:strip-space elements="*"/>
104 <xsl:preserve-space elements="para"/>
105
106 <xsl:template match="/book">
107 <xsl:text>
108\documentclass[oneside,a4paper,10pt,DIV10]{scrbook}
109\usepackage{geometry}
110\geometry{top=3cm,bottom=4cm}
111\usepackage[T1]{fontenc}
112\usepackage{tabulary}
113\usepackage[pdftex,
114 a4paper,
115 colorlinks=true,
116 linkcolor=blue,
117 urlcolor=darkgreen,
118 bookmarksnumbered,
119 bookmarksopen=true,
120 bookmarksopenlevel=0,
121 hyperfootnotes=false,
122 plainpages=false,
123 pdfpagelabels
124 ]{hyperref}
125
126\usepackage{nameref}
127\usepackage{graphicx}
128\usepackage{hyperref}
129\usepackage{fancybox}
130\usepackage{alltt}
131\usepackage{color}
132\usepackage{scrextend}
133\definecolor{darkgreen}{rgb}{0,0.6,0}
134\tymin=21pt
135
136</xsl:text>
137 <xsl:if test="$TARGETLANG='de_DE'">\usepackage[ngerman]{babel}&#10;\PrerenderUnicode{ü}</xsl:if>
138<!-- <xsl:if test="$TARGETLANG='fr_FR'">\usepackage[french]{babel}&#10;\FrenchItemizeSpacingfalse&#10;\renewcommand{\FrenchLabelItem}{\textbullet}</xsl:if>
139 this command is no longer understood by TexLive2008
140 -->
141 <xsl:text>
142
143% use Palatino as serif font:
144% \usepackage{mathpazo}
145\usepackage{charter}
146% use Helvetica as sans-serif font:
147\usepackage{helvet}
148
149% use Bera Mono (a variant of Bitstream Vera Mono) as typewriter font
150% (requires texlive-fontsextra)
151\usepackage[scaled]{beramono}
152% previously: use Courier as typewriter font:
153% \usepackage{courier}
154
155\definecolor{colNote}{rgb}{0,0,0}
156\definecolor{colWarning}{rgb}{0,0,0}
157\definecolor{colScreenFrame}{rgb}{0,0,0}
158\definecolor{colScreenText}{rgb}{0,0,0}
159
160% number headings down to this level
161\setcounter{secnumdepth}{3}
162% more space for the section numbers
163\makeatletter
164\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.9em}}
165\renewcommand*\l@subsection{\@dottedtocline{2}{4.4em}{3.8em}}
166\renewcommand*\l@subsubsection{\@dottedtocline{3}{8.2em}{3.8em}}
167\renewcommand*\@pnumwidth{1.7em}
168\renewcommand*\@tocrmarg{5.0em}
169\makeatother
170
171% more tolerance at 2nd wrap stage:
172\tolerance = 1000
173% allow 3rd wrap stage:
174\emergencystretch = 10pt
175% no Schusterjungen:
176\clubpenalty = 10000
177% no Hurenkinder:
178\widowpenalty = 10000
179\displaywidowpenalty = 10000
180% max pdf compression:
181\pdfcompresslevel9
182
183% opening and closing quotes: the OQ and CQ macros define this (and the makefile employs some sed magic also)
184</xsl:text>
185 <xsl:choose>
186 <xsl:when test="$TARGETLANG='de_DE'">
187 <xsl:text>\newcommand\OQ{\texorpdfstring{\glqq}{"}}&#10;\newcommand\CQ{\texorpdfstring{\grqq}{"}}&#10;</xsl:text>
188 </xsl:when>
189 <xsl:when test="$TARGETLANG='fr_FR'">
190 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
191 </xsl:when>
192 <xsl:when test="$TARGETLANG='en_US'">
193 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
194 </xsl:when>
195 <xsl:otherwise>
196 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
197 </xsl:otherwise>
198 </xsl:choose>
199
200 <xsl:apply-templates />
201
202 <xsl:text>
203\end{sloppypar}
204\end{document}
205 </xsl:text>
206
207 </xsl:template>
208
209 <xsl:template match="bookinfo">
210 <xsl:apply-templates />
211 <xsl:text>&#x0a;\newcommand\docbookbookinfocopyright{Copyright \copyright{} \docbookbookinfocopyrightyear{} \docbookbookinfocopyrightholder{}}&#x0a;
212\author{ \docbooktitleedition \\ %
213\\ %
214</xsl:text>
215 <xsl:if test="//bookinfo/address">
216 <xsl:text>\docbookbookinfoaddress \\ %
217\\ %
218</xsl:text>
219 </xsl:if>
220 <xsl:text>\docbookbookinfocopyright \\ %
221}
222
223\title{\docbooktitle \\
224\docbooksubtitle}
225% \subtitle{\docbooksubtitle}
226\hypersetup{pdfauthor=\docbookcorpauthor}
227\hypersetup{pdftitle=\docbooktitle{} \docbooksubtitle{}}
228
229\hyphenation{da-ta-ba-ses}
230\hyphenation{deb-conf}
231\hyphenation{VirtualBox}
232
233\begin{document}
234% bird/2018-05-14: Use sloppypar so we don't push path names and other long words
235% thru the right margin. TODO: Find better solution? microtype?
236\begin{sloppypar}
237% \maketitle
238%\begin{titlepage}
239\thispagestyle{empty}
240\begin{minipage}{\textwidth}
241\begin{center}
242\includegraphics[width=4cm]{images/vboxlogo.png}
243\end{center}%
244\vspace{10mm}
245
246{\fontsize{40pt}{40pt}\selectfont\rmfamily\bfseries%
247\begin{center}
248\docbooktitle
249\end{center}%
250\vspace{10mm}
251}
252
253{\fontsize{30pt}{30pt}\selectfont\rmfamily\bfseries%
254\begin{center}
255\docbooksubtitle
256\end{center}%
257\vspace{10mm}
258}
259
260{\fontsize{16pt}{20pt}\selectfont\rmfamily%
261\begin{center}
262</xsl:text>
263 <xsl:if test="//bookinfo/othercredit">
264 <xsl:text>\docbookbookinfoothercreditcontrib{}: \docbookbookinfoothercreditfirstname{} \docbookbookinfoothercreditsurname
265
266\vspace{8mm}
267</xsl:text>
268 </xsl:if>
269 <xsl:text>\docbooktitleedition
270
271\vspace{2mm}
272
273\docbookbookinfocopyright
274
275\vspace{2mm}
276
277\docbookbookinfoaddress
278\end{center}%
279}
280
281%\end{titlepage}
282\end{minipage}
283
284\tableofcontents
285 </xsl:text>
286 </xsl:template>
287
288 <xsl:template match="subtitle">
289 <xsl:choose>
290 <xsl:when test="name(..)='bookinfo'">
291 <xsl:text>\newcommand\docbooksubtitle{</xsl:text>
292 <xsl:apply-templates />
293 <xsl:text>}</xsl:text>
294 </xsl:when>
295 </xsl:choose>
296 </xsl:template>
297
298 <!-- Determins the section depth, returning a number 1,2,3,4,5,6,7,... -->
299 <xsl:template name="get-section-level">
300 <xsl:param name="a_Node" select=".."/>
301 <xsl:for-each select="$a_Node"> <!-- makes it current -->
302 <xsl:choose>
303 <xsl:when test="self::sect1"><xsl:text>1</xsl:text></xsl:when>
304 <xsl:when test="self::sect2"><xsl:text>2</xsl:text></xsl:when>
305 <xsl:when test="self::sect3"><xsl:text>3</xsl:text></xsl:when>
306 <xsl:when test="self::sect4"><xsl:text>4</xsl:text></xsl:when>
307 <xsl:when test="self::sect5"><xsl:text>5</xsl:text></xsl:when>
308 <xsl:when test="self::section">
309 <xsl:value-of select="count(ancestor::section) + 1"/>
310 </xsl:when>
311 <xsl:when test="self::simplesect">
312 <xsl:variable name="tmp">
313 <xsl:call-template name="get-section-level">
314 <xsl:with-param name="a_Node" select="parent::*"/>
315 </xsl:call-template>
316 </xsl:variable>
317 <xsl:value-of select="$tmp + 1"/>
318 </xsl:when>
319 <xsl:when test="self::preface"><xsl:text>0</xsl:text></xsl:when>
320 <xsl:when test="self::chapter"><xsl:text>0</xsl:text></xsl:when>
321 <xsl:when test="self::appendix"><xsl:text>0</xsl:text></xsl:when>
322 <xsl:when test="self::article"><xsl:text>0</xsl:text></xsl:when>
323 <xsl:otherwise>
324 <xsl:message terminate="yes">get-section-level was called on non-section element: <xsl:value-of select="."/> </xsl:message>
325 </xsl:otherwise>
326 </xsl:choose>
327 </xsl:for-each>
328 </xsl:template>
329
330 <!--
331 Inserts \hypertarget{@id} that can be referenced via the /A "nameddest=@id"
332 command line or #nameddest=@id URL parameter.
333
334 TODO: The placement of the target could be improved on. The raisebox
335 stuff is a crude hack to make it a little more acceptable. -->
336 <xsl:template name="title-wrapper">
337 <xsl:param name="texcmd" select="concat('\',name(..))"/>
338 <xsl:param name="refid" select="../@id"/>
339 <xsl:param name="role" select="../@role"/>
340
341 <xsl:call-template name="xsltprocNewlineOutputHack"/>
342 <xsl:if test="$texcmd='\chapter' and $role='frontmatter'">
343 <xsl:text>\frontmatter&#x0a;</xsl:text>
344 </xsl:if>
345 <xsl:if test="$texcmd='\chapter' and ../preceding-sibling::*[1][@role='frontmatter']">
346 <xsl:text>\mainmatter&#x0a;</xsl:text>
347 </xsl:if>
348 <xsl:choose>
349 <xsl:when test="$refid">
350 <xsl:text>&#x0a;</xsl:text>
351 <xsl:value-of select="$texcmd"/>
352 <xsl:if test="not(contains($texcmd, '*'))">
353 <xsl:text>[</xsl:text> <!-- for toc -->
354 <xsl:apply-templates />
355 <xsl:text>]</xsl:text>
356 </xsl:if>
357 <xsl:text>{</xsl:text> <!-- for doc -->
358 <xsl:text>\raisebox{\ht\strutbox}{\hypertarget{</xsl:text>
359 <xsl:value-of select="$refid"/>
360 <xsl:text>}{}}</xsl:text>
361 <xsl:apply-templates />
362 <xsl:text>}</xsl:text>
363 </xsl:when>
364 <xsl:otherwise>
365 <xsl:text>&#x0a;</xsl:text><xsl:value-of select="$texcmd"/><xsl:text>{</xsl:text>
366 <xsl:apply-templates />
367 <xsl:text>}</xsl:text>
368 </xsl:otherwise>
369 </xsl:choose>
370 </xsl:template>
371
372 <xsl:template match="title">
373 <xsl:variable name="refid" select="../@id" />
374 <xsl:choose>
375 <xsl:when test="name(..)='bookinfo'">
376 <xsl:text>\newcommand\docbooktitle{</xsl:text>
377 <xsl:apply-templates />
378 <xsl:text>}</xsl:text>
379 </xsl:when>
380 <xsl:when test="name(..)='chapter'">
381 <xsl:call-template name="title-wrapper"/>
382 </xsl:when>
383 <xsl:when test="name(..)='preface'">
384 <xsl:call-template name="title-wrapper">
385 <xsl:with-param name="texcmd">\chapter</xsl:with-param>
386 </xsl:call-template>
387 </xsl:when>
388 <xsl:when test="name(..)='sect1' and ../../@role='frontmatter'">
389 <xsl:call-template name="title-wrapper">
390 <xsl:with-param name="texcmd">\section*</xsl:with-param>
391 </xsl:call-template>
392 </xsl:when>
393 <xsl:when test="name(..)='sect1'">
394 <xsl:call-template name="title-wrapper">
395 <xsl:with-param name="texcmd">\section</xsl:with-param>
396 </xsl:call-template>
397 </xsl:when>
398 <xsl:when test="parent::sect2[@role='not-in-toc'] or parent::refsect1 or (parent::section and count(ancestor::section) = 2)">
399 <xsl:call-template name="title-wrapper">
400 <xsl:with-param name="texcmd">\subsection*</xsl:with-param>
401 </xsl:call-template>
402 </xsl:when>
403 <xsl:when test="name(..)='sect2'">
404 <xsl:call-template name="title-wrapper">
405 <xsl:with-param name="texcmd">\subsection</xsl:with-param>
406 </xsl:call-template>
407 </xsl:when>
408 <xsl:when test="parent::sect3[@role='not-in-toc'] or parent::refsect2 or (parent::section and count(ancestor::section) = 3)">
409 <xsl:call-template name="title-wrapper">
410 <xsl:with-param name="texcmd">\subsubsection*</xsl:with-param>
411 </xsl:call-template>
412 </xsl:when>
413 <xsl:when test="name(..)='sect3'">
414 <xsl:call-template name="title-wrapper">
415 <xsl:with-param name="texcmd">\subsubsection</xsl:with-param>
416 </xsl:call-template>
417 </xsl:when>
418 <xsl:when test="parent::sect4[@role='not-in-toc'] or parent::refsect3 or (parent::section and count(ancestor::section) = 4)">
419 <xsl:call-template name="title-wrapper">
420 <xsl:with-param name="texcmd">\paragraph*</xsl:with-param>
421 </xsl:call-template>
422 </xsl:when>
423 <xsl:when test="name(..)='sect4'">
424 <xsl:call-template name="title-wrapper">
425 <xsl:with-param name="texcmd">\paragraph</xsl:with-param>
426 </xsl:call-template>
427 </xsl:when>
428 <xsl:when test="parent::sect5[@role='not-in-toc'] or parent::refsect4 or (parent::section and count(ancestor::section) = 5)">
429 <xsl:call-template name="title-wrapper">
430 <xsl:with-param name="texcmd">\subparagraph*</xsl:with-param>
431 </xsl:call-template>
432 </xsl:when>
433 <xsl:when test="name(..)='sect5'">
434 <xsl:call-template name="title-wrapper">
435 <xsl:with-param name="texcmd">\subparagraph</xsl:with-param>
436 </xsl:call-template>
437 </xsl:when>
438 <xsl:when test="name(..)='appendix'">
439 <xsl:call-template name="title-wrapper">
440 <xsl:with-param name="texcmd">\chapter</xsl:with-param>
441 </xsl:call-template>
442 </xsl:when>
443 <xsl:when test="name(..)='glossdiv'">
444 <xsl:call-template name="title-wrapper">
445 <xsl:with-param name="texcmd">\section*</xsl:with-param>
446 </xsl:call-template>
447 </xsl:when>
448
449 <xsl:when test="parent::simplesect">
450 <xsl:if test="../@role">
451 <xsl:message terminate="yes">Role not allowed with simplesect: <xsl:value-of select="../@role"/></xsl:message>
452 </xsl:if>
453 <xsl:variable name="level">
454 <xsl:call-template name="get-section-level">
455 <xsl:with-param name="a_Node" select=".."/>
456 </xsl:call-template>
457 </xsl:variable>
458 <xsl:choose>
459 <xsl:when test="$level = 1">
460 <xsl:call-template name="title-wrapper"><xsl:with-param name="texcmd">\section*</xsl:with-param></xsl:call-template>
461 </xsl:when>
462 <xsl:when test="$level = 2">
463 <xsl:call-template name="title-wrapper"><xsl:with-param name="texcmd">\subsection*</xsl:with-param></xsl:call-template>
464 </xsl:when>
465 <xsl:when test="$level = 3">
466 <xsl:call-template name="title-wrapper"><xsl:with-param name="texcmd">\subsubsection*</xsl:with-param></xsl:call-template>
467 </xsl:when>
468 <xsl:when test="$level = 4">
469 <xsl:call-template name="title-wrapper"><xsl:with-param name="texcmd">\paragraph*</xsl:with-param></xsl:call-template>
470 </xsl:when>
471 <xsl:when test="$level = 5">
472 <xsl:call-template name="title-wrapper"><xsl:with-param name="texcmd">\subparagraph*</xsl:with-param></xsl:call-template>
473 </xsl:when>
474 <xsl:otherwise>
475 <xsl:message terminate="yes">Unsupported simplesect/title depth: <xsl:value-of select="$level"/></xsl:message>
476 </xsl:otherwise>
477 </xsl:choose>
478 </xsl:when>
479
480 </xsl:choose>
481 <xsl:if test="$refid">
482 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
483 </xsl:if>
484 <xsl:text>&#x0a;</xsl:text>
485 </xsl:template>
486
487 <xsl:template match="edition">
488 <xsl:choose>
489 <xsl:when test="name(..)='bookinfo'">
490 <xsl:text>\newcommand\docbooktitleedition{</xsl:text>
491 <xsl:apply-templates />
492 <xsl:text>}&#x0a;</xsl:text>
493 </xsl:when>
494 </xsl:choose>
495 </xsl:template>
496
497 <xsl:template match="corpauthor">
498 <xsl:choose>
499 <xsl:when test="name(..)='bookinfo'">
500 <xsl:text>\newcommand\docbookcorpauthor{</xsl:text>
501 <xsl:apply-templates />
502 <xsl:text>}&#x0a;</xsl:text>
503 </xsl:when>
504 </xsl:choose>
505 </xsl:template>
506
507 <xsl:template match="address">
508 <xsl:choose>
509 <xsl:when test="name(..)='bookinfo'">
510 <xsl:text>\newcommand\docbookbookinfoaddress{</xsl:text>
511 <xsl:apply-templates />
512 <xsl:text>}&#x0a;</xsl:text>
513 </xsl:when>
514 </xsl:choose>
515 </xsl:template>
516
517 <xsl:template match="year">
518 <xsl:choose>
519 <xsl:when test="name(..)='copyright'">
520 <xsl:text>\newcommand\docbookbookinfocopyrightyear{</xsl:text>
521 <xsl:apply-templates />
522 <xsl:text>}&#x0a;</xsl:text>
523 </xsl:when>
524 </xsl:choose>
525 </xsl:template>
526
527 <xsl:template match="holder">
528 <xsl:choose>
529 <xsl:when test="name(..)='copyright'">
530 <xsl:text>\newcommand\docbookbookinfocopyrightholder{</xsl:text>
531 <xsl:apply-templates />
532 <xsl:text>}&#x0a;</xsl:text>
533 </xsl:when>
534 </xsl:choose>
535 </xsl:template>
536
537 <xsl:template match="firstname">
538 <xsl:choose>
539 <xsl:when test="name(..)='othercredit'">
540 <xsl:text>\newcommand\docbookbookinfoothercreditfirstname{</xsl:text>
541 <xsl:apply-templates />
542 <xsl:text>}&#x0a;</xsl:text>
543 </xsl:when>
544 </xsl:choose>
545 </xsl:template>
546
547 <xsl:template match="surname">
548 <xsl:choose>
549 <xsl:when test="name(..)='othercredit'">
550 <xsl:text>\newcommand\docbookbookinfoothercreditsurname{</xsl:text>
551 <xsl:apply-templates />
552 <xsl:text>}&#x0a;</xsl:text>
553 </xsl:when>
554 </xsl:choose>
555 </xsl:template>
556
557 <xsl:template match="contrib">
558 <xsl:choose>
559 <xsl:when test="name(..)='othercredit'">
560 <xsl:text>\newcommand\docbookbookinfoothercreditcontrib{</xsl:text>
561 <xsl:apply-templates />
562 <xsl:text>}&#x0a;</xsl:text>
563 </xsl:when>
564 </xsl:choose>
565 </xsl:template>
566
567 <xsl:template match="glossary">
568 <xsl:text>&#x0a;&#x0a;\backmatter&#x0a;\chapter{Glossary}&#x0a;</xsl:text>
569 <xsl:apply-templates />
570 </xsl:template>
571
572 <xsl:template match="para">
573 <xsl:if test="not(name(..)='footnote' or name(..)='note' or name(..)='warning' or name(..)='entry' or (name(../..)='varlistentry' and position()=1))">
574 <xsl:text>&#x0a;&#x0a;</xsl:text>
575 </xsl:if>
576 <xsl:apply-templates />
577 </xsl:template>
578
579 <xsl:template match="note">
580 <xsl:value-of select="concat('&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;\begin{center}\fbox{\begin{minipage}[c]{0.9\textwidth}\color{colNote}\textbf{', $g_nlsNote, ':} ')" />
581 <xsl:apply-templates />
582 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
583 </xsl:template>
584
585 <xsl:template match="warning">
586 <xsl:value-of select="concat('&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;\begin{center}\fbox{\begin{minipage}[c]{0.9\textwidth}\color{colWarning}\textbf{', $g_nlsWarning, ':} ')" />
587 <xsl:apply-templates />
588 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
589 </xsl:template>
590
591 <xsl:template match="screen">
592 <xsl:text>&#x0a;&#x0a;{\footnotesize\begin{alltt}&#x0a;</xsl:text>
593 <xsl:apply-templates />
594 <xsl:text>&#x0a;\end{alltt}}&#x0a;</xsl:text>
595 </xsl:template>
596
597 <xsl:template match="programlisting">
598 <xsl:text>&#x0a;&#x0a;{\small\begin{alltt}&#x0a;</xsl:text>
599 <xsl:apply-templates />
600 <xsl:text>&#x0a;\end{alltt}}&#x0a;</xsl:text>
601 </xsl:template>
602
603 <xsl:template match="footnote">
604 <xsl:text>\footnote{</xsl:text>
605 <xsl:apply-templates />
606 <xsl:text>}</xsl:text>
607 </xsl:template>
608
609 <xsl:template match="tgroup">
610 <xsl:choose>
611 <xsl:when test="@style='verywide'">
612 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{1.1\textwidth}[]</xsl:text>
613 </xsl:when>
614 <xsl:otherwise>
615 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{.9\textwidth}[]</xsl:text>
616 </xsl:otherwise>
617 </xsl:choose>
618 <xsl:text>{</xsl:text>
619 <xsl:choose>
620 <xsl:when test="@cols='1'">
621 <xsl:text>|L|</xsl:text>
622 </xsl:when>
623 <xsl:when test="@cols='2'">
624 <xsl:text>|L|L|</xsl:text>
625 </xsl:when>
626 <xsl:when test="@cols='3'">
627 <xsl:text>|L|L|L|</xsl:text>
628 </xsl:when>
629 <xsl:when test="@cols='4'">
630 <xsl:text>|L|L|L|L|</xsl:text>
631 </xsl:when>
632 <xsl:when test="@cols='5'">
633 <xsl:text>|L|L|L|L|L|</xsl:text>
634 </xsl:when>
635 <xsl:when test="@cols='6'">
636 <xsl:text>|L|L|L|L|L|L|</xsl:text>
637 </xsl:when>
638 <xsl:otherwise>
639 <xsl:message terminate="yes">Unsupported number of columns (<xsl:value-of select="@cols"/>), fix document or converter</xsl:message>
640 </xsl:otherwise>
641 </xsl:choose>
642 <xsl:text>}&#x0a;\hline&#x0a;</xsl:text>
643 <xsl:apply-templates />
644 <xsl:text>&#x0a;\end{tabulary}&#x0a;\end{center}}&#x0a;</xsl:text>
645 </xsl:template>
646
647 <xsl:template match="row">
648 <xsl:apply-templates />
649 <xsl:text>&#x0a;\\ \hline&#x0a;</xsl:text>
650 </xsl:template>
651
652 <xsl:template match="entry">
653 <xsl:if test="not(position()=1)">
654 <xsl:text> &amp; </xsl:text>
655 </xsl:if>
656 <xsl:apply-templates />
657 </xsl:template>
658
659 <xsl:template match="itemizedlist">
660 <xsl:call-template name="xsltprocNewlineOutputHack"/>
661 <xsl:text>&#x0a;\begin{itemize}&#x0a;</xsl:text>
662 <xsl:if test="@spacing = 'compact'">
663 <xsl:text> \setlength{\parskip}{0pt}&#x0a;</xsl:text>
664 <xsl:text> \setlength{\itemsep}{0pt}&#x0a;</xsl:text>
665 <xsl:text> \setlength{\topsep}{0pt}&#x0a;</xsl:text>
666 <xsl:text> \setlength{\parsep}{0pt}&#x0a;</xsl:text>
667 <xsl:text> \setlength{\partopsep}{0pt}&#x0a;</xsl:text>
668 </xsl:if>
669 <xsl:apply-templates />
670 <xsl:text>&#x0a;\end{itemize}&#x0a;</xsl:text>
671 </xsl:template>
672
673 <xsl:template match="orderedlist">
674 <xsl:call-template name="xsltprocNewlineOutputHack"/>
675 <xsl:text>&#x0a;\begin{enumerate}&#x0a;</xsl:text>
676 <xsl:if test="@spacing = 'compact'">
677 <xsl:text> \setlength{\parskip}{0pt}&#x0a;</xsl:text>
678 <xsl:text> \setlength{\itemsep}{0pt}&#x0a;</xsl:text>
679 <xsl:text> \setlength{\topsep}{0pt}&#x0a;</xsl:text>
680 <xsl:text> \setlength{\parsep}{0pt}&#x0a;</xsl:text>
681 <xsl:text> \setlength{\partopsep}{0pt}&#x0a;</xsl:text>
682 </xsl:if>
683 <xsl:apply-templates />
684 <xsl:text>&#x0a;\end{enumerate}&#x0a;</xsl:text>
685 </xsl:template>
686
687 <xsl:template match="variablelist">
688 <xsl:call-template name="xsltprocNewlineOutputHack"/>
689 <xsl:text>&#x0a;\begin{description}&#x0a;</xsl:text>
690 <xsl:if test="@spacing = 'compact'">
691 <xsl:text> \setlength{\parskip}{0pt}&#x0a;</xsl:text>
692 <xsl:text> \setlength{\itemsep}{0pt}&#x0a;</xsl:text>
693 <xsl:text> \setlength{\topsep}{0pt}&#x0a;</xsl:text>
694 <xsl:text> \setlength{\parsep}{0pt}&#x0a;</xsl:text>
695 <xsl:text> \setlength{\partopsep}{0pt}&#x0a;</xsl:text>
696 </xsl:if>
697 <xsl:apply-templates />
698 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
699 </xsl:template>
700
701 <xsl:template match="varlistentry">
702 <xsl:if test="not(./term) or not(./listitem) or count(./listitem) != 1">
703 <xsl:message terminate="yes">Expected at least one term and one listitem element in the varlistentry.</xsl:message>
704 </xsl:if>
705 <xsl:text>&#x0a;&#x0a;\item[{\parbox[t]{\linewidth}{\raggedright </xsl:text>
706 <xsl:apply-templates select="./term[1]"/>
707 <xsl:for-each select="./term[position() > 1]">
708 <xsl:text>\\&#x0a; </xsl:text>
709 <xsl:apply-templates select="."/>
710 </xsl:for-each>
711 <xsl:text>}}]\hfill\\</xsl:text>
712 <xsl:apply-templates select="listitem/*"/>
713 </xsl:template>
714
715 <xsl:template match="listitem">
716 <xsl:text>&#x0a;&#x0a;\item </xsl:text>
717 <xsl:apply-templates />
718 <xsl:text>&#x0a;</xsl:text>
719 </xsl:template>
720
721 <xsl:template match="glossterm">
722 <xsl:variable name="refid" select="(@id)" />
723 <xsl:if test="$refid">
724 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
725 </xsl:if>
726 <xsl:text>&#x0a;&#x0a;\item[</xsl:text>
727 <xsl:apply-templates />
728 <xsl:text>]</xsl:text>
729 </xsl:template>
730
731 <xsl:template match="glosslist | glossdiv">
732 <xsl:text>&#x0a;&#x0a;\begin{description}&#x0a;</xsl:text>
733 <xsl:apply-templates />
734 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
735 </xsl:template>
736
737 <xsl:template match="superscript">
738 <xsl:variable name="contents">
739 <xsl:apply-templates />
740 </xsl:variable>
741 <xsl:value-of select="concat('\texorpdfstring{\textsuperscript{', $contents, '}}{', $contents, '}')" />
742 </xsl:template>
743
744 <xsl:template match="emphasis">
745 <xsl:choose>
746 <xsl:when test="@role='bold'">
747 <xsl:text>\textbf{</xsl:text>
748 </xsl:when>
749 <xsl:otherwise>
750 <xsl:text>\textit{</xsl:text>
751 </xsl:otherwise>
752 </xsl:choose>
753 <xsl:apply-templates />
754 <xsl:text>}</xsl:text>
755 </xsl:template>
756
757 <xsl:template match="computeroutput | code">
758 <xsl:text>\texttt{</xsl:text>
759 <xsl:apply-templates />
760 <xsl:text>}</xsl:text>
761 </xsl:template>
762
763 <xsl:template match="literal | filename">
764 <xsl:text>\texttt{</xsl:text>
765 <xsl:apply-templates />
766 <xsl:text>}</xsl:text>
767 </xsl:template>
768
769 <xsl:template match="citetitle">
770 <xsl:text>\textit{</xsl:text>
771 <xsl:apply-templates />
772 <xsl:text>}</xsl:text>
773 </xsl:template>
774
775 <xsl:template match="lineannotation">
776 <xsl:text>\textit{</xsl:text>
777 <xsl:apply-templates />
778 <xsl:text>}</xsl:text>
779 </xsl:template>
780
781 <xsl:template match="ulink[@url!='' and not(text())]">
782 <xsl:text>\url{</xsl:text>
783 <xsl:value-of select="@url"/>
784 <xsl:text>}</xsl:text>
785 </xsl:template>
786
787 <xsl:template match="ulink[@url!='' and text()]">
788 <xsl:text>\href{</xsl:text>
789 <xsl:value-of select="@url"/>
790 <xsl:text>}{</xsl:text>
791 <xsl:apply-templates />
792 <xsl:text>}</xsl:text>
793 </xsl:template>
794
795 <xsl:template match="ulink[(@url='' or not(@url)) and text()]">
796 <xsl:text>\url{</xsl:text>
797 <xsl:apply-templates />
798 <xsl:text>}</xsl:text>
799 </xsl:template>
800
801 <xsl:template match="xref">
802 <xsl:choose>
803 <xsl:when test="@endterm">
804 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
805 </xsl:when>
806 <xsl:otherwise>
807 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
808 </xsl:otherwise>
809 </xsl:choose>
810 </xsl:template>
811
812 <xsl:template match="link">
813 <xsl:choose>
814 <xsl:when test="@endterm">
815 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
816 </xsl:when>
817 <xsl:when test="./text()">
818 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{')" />
819 <xsl:apply-templates select="./text()"/>
820 <xsl:value-of select="'}}'" />
821 </xsl:when>
822 <xsl:otherwise>
823 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
824 </xsl:otherwise>
825 </xsl:choose>
826 </xsl:template>
827
828 <xsl:template match="trademark">
829 <xsl:apply-templates />
830 <xsl:text>\textsuperscript{\textregistered}</xsl:text>
831 </xsl:template>
832
833 <!-- for some reason, DocBook insists of having image data nested this way always:
834 mediaobject -> imageobject -> imagedata
835 but only imagedata is interesting -->
836 <xsl:template match="imagedata">
837 <xsl:if test="@align='center'">
838 <xsl:text>\begin{center}</xsl:text>
839 </xsl:if>
840 <xsl:value-of select="concat('&#x0a;\includegraphics[width=', @width, ']{', @fileref, '}&#x0a;')" />
841 <xsl:apply-templates />
842 <xsl:if test="@align='center'">
843 <xsl:text>\end{center}</xsl:text>
844 </xsl:if>
845 </xsl:template>
846
847 <!--
848 Turn the refsynopsisdiv part of a manpage into a named & indented paragraph.
849 -->
850 <xsl:template match="refsynopsisdiv">
851 <xsl:if test="name(*[1]) != 'cmdsynopsis'"><xsl:message terminate="yes">Expected refsynopsisdiv to start with cmdsynopsis</xsl:message></xsl:if>
852 <xsl:if test="title"><xsl:message terminate="yes">No title element supported in refsynopsisdiv</xsl:message></xsl:if>
853 <xsl:call-template name="xsltprocNewlineOutputHack"/>
854 <xsl:text>&#x0a;\subsection*{Synopsis}&#x0a;</xsl:text>
855 <xsl:apply-templates />
856 </xsl:template>
857
858 <!--
859 The refsect1 is used for 'Description' and such. Do same as with refsynopsisdiv
860 and turn it into a named & indented paragraph.
861 -->
862 <xsl:template match="refsect1">
863 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
864 <xsl:message terminate="yes">Expected exactly one title as the first refsect1 element (remarks goes after title!).</xsl:message>
865 </xsl:if>
866 <xsl:apply-templates/>
867 </xsl:template>
868
869 <!--
870 The refsect2 element will be turned into a subparagraph if it has a title,
871 however, that didn't work out when it didn't have a title and started with
872 a cmdsynopsis instead (subcommand docs). So, we're doing some trickery
873 here (HACK ALERT) for the non-title case to feign a paragraph.
874 -->
875 <xsl:template match="refsect2">
876 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
877 <xsl:message terminate="yes">Expected exactly one title as the first refsect2 element (remarks goes after title!).</xsl:message>
878 </xsl:if>
879 <xsl:apply-templates/>
880 <xsl:text>&#x0a;</xsl:text>
881 </xsl:template>
882
883
884 <!--
885 Command Synopsis elements.
886
887 We treat each command element inside a cmdsynopsis as the start of
888 a new paragraph. The DocBook HTML converter does so too, but the
889 manpage one doesn't.
890
891 sbr and linebreaks made by latex should be indented from the base
892 command level. This is done by the \hangindent3em\hangafter1 bits.
893
894 We exploit the default paragraph indentation to get each command
895 indented from the left margin. This, unfortunately, doesn't work
896 if we're the first paragraph in a (sub*)section. \noindent cannot
897 counter this due to when latex enforces first paragraph stuff. Since
898 it's tedious to figure out when we're in the first paragraph and when
899 not, we just do \noindent\hspace{1em} everywhere.
900 -->
901 <xsl:template match="sbr">
902 <xsl:if test="not(ancestor::cmdsynopsis)">
903 <xsl:message terminate="yes">sbr only supported inside cmdsynopsis (because of hangindent)</xsl:message>
904 </xsl:if>
905 <xsl:text>\newline</xsl:text>
906 </xsl:template>
907
908 <xsl:template match="refentry|refnamediv|refentryinfo|refmeta|refsect3|refsect4|refsect5|synopfragment|synopfragmentref|cmdsynopsis/info">
909 <xsl:message terminate="yes"><xsl:value-of select="name()"/> is not supported</xsl:message>
910 </xsl:template>
911
912 <xsl:template match="cmdsynopsis">
913 <xsl:if test="preceding-sibling::cmdsynopsis">
914 <xsl:text>%cmdsynopsis</xsl:text>
915 </xsl:if>
916 <xsl:text>&#x0a;</xsl:text>
917 <xsl:text>\begin{flushleft}</xsl:text>
918 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
919 <!-- Overview fontsize trick -->
920 <xsl:text>{\footnotesize</xsl:text>
921 </xsl:if>
922 <xsl:text>\noindent\hspace{1em}</xsl:text>
923 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
924 <xsl:apply-templates />
925 <xsl:text>}</xsl:text>
926 <xsl:if test="following-sibling::*">
927 </xsl:if>
928
929 <!-- For refsect2 subcommand descriptions. -->
930 <xsl:if test="not(following-sibling::cmdsynopsis) and position() != last()">
931 <xsl:text>\linebreak</xsl:text>
932 </xsl:if>
933 <!-- Special overview trick for the current VBoxManage command overview. -->
934 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
935 <xsl:text>\par}</xsl:text>
936 </xsl:if>
937 <xsl:text>\end{flushleft}</xsl:text>
938 </xsl:template>
939
940 <xsl:template match="command">
941 <xsl:choose>
942 <xsl:when test="ancestor::cmdsynopsis">
943 <!-- Trigger a line break if this isn't the first command in a synopsis -->
944 <xsl:if test="preceding-sibling::command">
945 <xsl:text>}\par%command&#x0a;</xsl:text>
946 <xsl:text>\noindent\hspace{1em}</xsl:text>
947 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
948 </xsl:if>
949 <xsl:apply-templates />
950 </xsl:when>
951 <xsl:otherwise>
952 <xsl:text>\texttt{</xsl:text>
953 <xsl:apply-templates />
954 <xsl:text>}</xsl:text>
955 </xsl:otherwise>
956 </xsl:choose>
957 </xsl:template>
958
959 <xsl:template match="option">
960 <xsl:choose>
961 <xsl:when test="ancestor::cmdsynopsis">
962 <xsl:apply-templates />
963 </xsl:when>
964 <xsl:otherwise>
965 <xsl:text>\texttt{</xsl:text>
966 <xsl:apply-templates />
967 <xsl:text>}</xsl:text>
968 </xsl:otherwise>
969 </xsl:choose>
970 </xsl:template>
971
972 <!-- duplicated in docbook-refentry-to-C-help.xsl -->
973 <xsl:template match="arg|group">
974 <!-- separator char if we're not the first child -->
975 <xsl:if test="position() > 1">
976 <xsl:choose>
977 <xsl:when test="parent::group"><xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.or.sep.tex"/><xsl:text>}</xsl:text></xsl:when>
978 <xsl:when test="ancestor-or-self::*/@sepchar"><xsl:value-of select="ancestor-or-self::*/@sepchar"/></xsl:when>
979 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
980 </xsl:choose>
981 </xsl:if>
982
983 <!-- open wrapping -->
984 <xsl:choose>
985 <xsl:when test="not(@choice) or @choice = ''"> <xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.choice.def.open.str"/><xsl:text>}</xsl:text></xsl:when>
986 <xsl:when test="@choice = 'opt'"> <xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.choice.opt.open.str"/><xsl:text>}</xsl:text></xsl:when>
987 <xsl:when test="@choice = 'req'"> <xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.choice.req.open.str"/><xsl:text>}</xsl:text></xsl:when>
988 <xsl:when test="@choice = 'plain'"/>
989 <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise>
990 </xsl:choose>
991
992 <xsl:apply-templates />
993
994 <!-- repeat indication -->
995 <xsl:choose>
996 <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/>
997 <xsl:when test="@rep = 'repeat'">
998 <!-- add space padding if we're in a repeating group -->
999 <xsl:if test="self::group">
1000 <xsl:text> </xsl:text>
1001 </xsl:if>
1002 <xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.rep.repeat.str.tex"/><xsl:text>}</xsl:text>
1003 </xsl:when>
1004 <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise>
1005 </xsl:choose>
1006
1007 <!-- close wrapping -->
1008 <xsl:choose>
1009 <xsl:when test="not(@choice) or @choice = ''"> <xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.choice.def.close.str"/><xsl:text>}</xsl:text></xsl:when>
1010 <xsl:when test="@choice = 'opt'"> <xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.choice.opt.close.str"/><xsl:text>}</xsl:text></xsl:when>
1011 <xsl:when test="@choice = 'req'"> <xsl:text>\textrm{</xsl:text><xsl:value-of select="$arg.choice.req.close.str"/><xsl:text>}</xsl:text></xsl:when>
1012 </xsl:choose>
1013
1014 <!-- add space padding if we're the last element in a nested arg -->
1015 <xsl:if test="parent::arg and not(following-sibling)">
1016 <xsl:text> </xsl:text>
1017 </xsl:if>
1018 </xsl:template>
1019
1020 <xsl:template match="replaceable">
1021 <xsl:choose>
1022 <xsl:when test="(not(ancestor::cmdsynopsis) and not(ancestor::option) and not(ancestor::screen)) or ancestor::arg">
1023 <xsl:text>\texttt{\textit{</xsl:text>
1024 <xsl:apply-templates />
1025 <xsl:text>}}</xsl:text>
1026 </xsl:when>
1027 <xsl:otherwise>
1028 <xsl:text>\textit{&lt;</xsl:text>
1029 <xsl:apply-templates />
1030 <xsl:text>&gt;}</xsl:text>
1031 </xsl:otherwise>
1032 </xsl:choose>
1033 </xsl:template>
1034
1035
1036 <!--
1037 Generic element text magic.
1038 -->
1039 <xsl:template match="//text()">
1040
1041 <!-- Do the translation of \ into \textbackslash{} in two steps, to avoid
1042 running into replacing {} as well which would be very wrong. -->
1043 <xsl:variable name="subst1">
1044 <xsl:call-template name="str:subst">
1045 <xsl:with-param name="text" select="." />
1046 <xsl:with-param name="replace" select="'\'" />
1047 <xsl:with-param name="with" select="'\textbackslash'" />
1048 <xsl:with-param name="disable-output-escaping" select="no" />
1049 </xsl:call-template>
1050 </xsl:variable>
1051 <xsl:variable name="subst2">
1052 <xsl:call-template name="str:subst">
1053 <xsl:with-param name="text" select="$subst1" />
1054 <xsl:with-param name="replace" select="'{'" />
1055 <xsl:with-param name="with" select="'\{'" />
1056 <xsl:with-param name="disable-output-escaping" select="no" />
1057 </xsl:call-template>
1058 </xsl:variable>
1059 <xsl:variable name="subst3">
1060 <xsl:call-template name="str:subst">
1061 <xsl:with-param name="text" select="$subst2" />
1062 <xsl:with-param name="replace" select="'}'" />
1063 <xsl:with-param name="with" select="'\}'" />
1064 <xsl:with-param name="disable-output-escaping" select="no" />
1065 </xsl:call-template>
1066 </xsl:variable>
1067 <xsl:variable name="subst4">
1068 <xsl:call-template name="str:subst">
1069 <xsl:with-param name="text" select="$subst3" />
1070 <xsl:with-param name="replace" select="'\textbackslash'" />
1071 <xsl:with-param name="with" select="'\textbackslash{}'" />
1072 <xsl:with-param name="disable-output-escaping" select="no" />
1073 </xsl:call-template>
1074 </xsl:variable>
1075
1076 <xsl:choose>
1077 <xsl:when test="(name(..) = 'computeroutput') or (name(../..) = 'computeroutput')
1078 or (name(..) = 'code') or (name(../..) = 'code')
1079 or (name(..) = 'arg') or (name(../..) = 'arg')
1080 or (name(..) = 'option') or (name(../..) = 'option')
1081 or (name(..) = 'command') or (name(../..) = 'command')
1082 or (name(..) = 'cmdsynopsis') or (name(../..) = 'cmdsynopsis')
1083 or (name(..) = 'replaceable') or (name(../..) = 'replaceable')
1084 or (name(..) = 'entry') or (name(../..) = 'entry')
1085 ">
1086 <xsl:variable name="subst5">
1087 <xsl:call-template name="str:subst">
1088 <xsl:with-param name="text" select="translate(normalize-space(concat('&#x7f;',$subst4,'&#x7f;')),'&#x7f;','')" />
1089 <xsl:with-param name="replace" select="'--'" />
1090 <xsl:with-param name="with" select="'-{}-'" />
1091 <xsl:with-param name="disable-output-escaping" select="no" />
1092 </xsl:call-template>
1093 </xsl:variable>
1094 <xsl:variable name="subst6">
1095 <xsl:call-template name="str:subst">
1096 <xsl:with-param name="text" select="$subst5" />
1097 <xsl:with-param name="replace" select="'_'" />
1098 <xsl:with-param name="with" select="'\_'" />
1099 <xsl:with-param name="disable-output-escaping" select="no" />
1100 </xsl:call-template>
1101 </xsl:variable>
1102 <xsl:variable name="subst7">
1103 <xsl:call-template name="str:subst">
1104 <xsl:with-param name="text" select="$subst6" />
1105 <xsl:with-param name="replace" select="'$'" />
1106 <xsl:with-param name="with" select="'\$'" />
1107 <xsl:with-param name="disable-output-escaping" select="no" />
1108 </xsl:call-template>
1109 </xsl:variable>
1110 <xsl:variable name="subst8">
1111 <xsl:call-template name="str:subst">
1112 <xsl:with-param name="text" select="$subst7" />
1113 <xsl:with-param name="replace" select="'%'" />
1114 <xsl:with-param name="with" select="'\%'" />
1115 <xsl:with-param name="disable-output-escaping" select="no" />
1116 </xsl:call-template>
1117 </xsl:variable>
1118 <xsl:variable name="subst9">
1119 <xsl:call-template name="str:subst">
1120 <xsl:with-param name="text" select="$subst8" />
1121 <xsl:with-param name="replace" select="'#'" />
1122 <xsl:with-param name="with" select="'\#'" />
1123 <xsl:with-param name="disable-output-escaping" select="no" />
1124 </xsl:call-template>
1125 </xsl:variable>
1126 <xsl:variable name="subst10">
1127 <xsl:call-template name="str:subst">
1128 <xsl:with-param name="text" select="$subst9" />
1129 <xsl:with-param name="replace" select="'~'" />
1130 <xsl:with-param name="with" select="'\textasciitilde{}'" />
1131 <xsl:with-param name="disable-output-escaping" select="no" />
1132 </xsl:call-template>
1133 </xsl:variable>
1134 <xsl:variable name="subst11">
1135 <xsl:call-template name="str:subst">
1136 <xsl:with-param name="text" select="$subst10" />
1137 <xsl:with-param name="replace" select="'&amp;'" />
1138 <xsl:with-param name="with" select="'\&amp;'" />
1139 <xsl:with-param name="disable-output-escaping" select="no" />
1140 </xsl:call-template>
1141 </xsl:variable>
1142 <xsl:choose>
1143 <xsl:when test="parent::arg or parent::command">
1144 <xsl:variable name="subst12">
1145 <xsl:call-template name="str:subst">
1146 <xsl:with-param name="text" select="$subst10" />
1147 <xsl:with-param name="replace" select="' '" />
1148 <xsl:with-param name="with" select="'~'" />
1149 <xsl:with-param name="disable-output-escaping" select="no" />
1150 </xsl:call-template>
1151 </xsl:variable>
1152 <xsl:value-of select="$subst12" />
1153 </xsl:when>
1154 <xsl:otherwise>
1155 <xsl:value-of select="$subst11" />
1156 </xsl:otherwise>
1157 </xsl:choose>
1158 </xsl:when>
1159
1160 <xsl:when test="(name(..)='address') or (name(../..)='address')">
1161 <xsl:variable name="subst5">
1162 <xsl:call-template name="str:subst">
1163 <xsl:with-param name="text" select="$subst4" />
1164 <xsl:with-param name="replace" select="'&#x0a;'" />
1165 <xsl:with-param name="with" select="' \\'" />
1166 <xsl:with-param name="disable-output-escaping" select="no" />
1167 </xsl:call-template>
1168 </xsl:variable>
1169 <xsl:value-of select="$subst5" />
1170 </xsl:when>
1171
1172 <!-- <screen> and <programlisting>, which work with alltt environment. -->
1173 <xsl:otherwise>
1174 <xsl:variable name="subst5">
1175 <xsl:call-template name="str:subst">
1176 <xsl:with-param name="text" select="$subst4" />
1177 <xsl:with-param name="replace" select="'_'" />
1178 <xsl:with-param name="with" select="'\_'" />
1179 <xsl:with-param name="disable-output-escaping" select="no" />
1180 </xsl:call-template>
1181 </xsl:variable>
1182 <xsl:variable name="subst6">
1183 <xsl:call-template name="str:subst">
1184 <xsl:with-param name="text" select="$subst5" />
1185 <xsl:with-param name="replace" select="'$'" />
1186 <xsl:with-param name="with" select="'\$'" />
1187 <xsl:with-param name="disable-output-escaping" select="no" />
1188 </xsl:call-template>
1189 </xsl:variable>
1190 <xsl:variable name="subst7">
1191 <xsl:call-template name="str:subst">
1192 <xsl:with-param name="text" select="$subst6" />
1193 <xsl:with-param name="replace" select="'%'" />
1194 <xsl:with-param name="with" select="'\%'" />
1195 <xsl:with-param name="disable-output-escaping" select="no" />
1196 </xsl:call-template>
1197 </xsl:variable>
1198 <xsl:variable name="subst8">
1199 <xsl:call-template name="str:subst">
1200 <xsl:with-param name="text" select="$subst7" />
1201 <xsl:with-param name="replace" select="'#'" />
1202 <xsl:with-param name="with" select="'\#'" />
1203 <xsl:with-param name="disable-output-escaping" select="no" />
1204 </xsl:call-template>
1205 </xsl:variable>
1206 <xsl:variable name="subst9">
1207 <xsl:call-template name="str:subst">
1208 <xsl:with-param name="text" select="$subst8" />
1209 <xsl:with-param name="replace" select="'µ'" />
1210 <xsl:with-param name="with" select="'$\mu$'" />
1211 <xsl:with-param name="disable-output-escaping" select="no" />
1212 </xsl:call-template>
1213 </xsl:variable>
1214 <xsl:variable name="subst10">
1215 <xsl:call-template name="str:subst">
1216 <xsl:with-param name="text" select="$subst9" />
1217 <xsl:with-param name="replace" select="'®'" />
1218 <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
1219 <xsl:with-param name="disable-output-escaping" select="no" />
1220 </xsl:call-template>
1221 </xsl:variable>
1222 <xsl:variable name="quote">"</xsl:variable>
1223 <!-- preparation for pretty quotes: replace all double quotes _outside_ screen
1224 sections with "\QUOTE{}" strings, which the makefile will then replace
1225 with pretty quotes by invoking sed a few times. Unfortunately there are
1226 no regular expressions in XSLT so there's no other way. -->
1227 <xsl:variable name="subst11">
1228 <xsl:choose>
1229 <xsl:when test="(name(..)='screen') or (name(../..)='screen')
1230 or (name(..)='programlisting') or (name(../..)='programlisting')
1231 or (name(..)='literal') or (name(../..)='literal')
1232 ">
1233 <xsl:value-of select="$subst10" />
1234 </xsl:when>
1235 <xsl:otherwise>
1236 <xsl:call-template name="str:subst">
1237 <xsl:with-param name="text" select="$subst10" />
1238 <xsl:with-param name="replace" select="$quote" />
1239 <xsl:with-param name="with" select="'\QUOTE{}'" />
1240 <xsl:with-param name="disable-output-escaping" select="no" />
1241 </xsl:call-template>
1242 </xsl:otherwise>
1243 </xsl:choose>
1244 </xsl:variable>
1245 <xsl:variable name="subst12">
1246 <xsl:call-template name="str:subst">
1247 <xsl:with-param name="text" select="$subst11" />
1248 <xsl:with-param name="replace" select="'~'" />
1249 <xsl:with-param name="with" select="'\textasciitilde{}'" />
1250 <xsl:with-param name="disable-output-escaping" select="no" />
1251 </xsl:call-template>
1252 </xsl:variable>
1253 <xsl:variable name="subst13">
1254 <xsl:call-template name="str:subst">
1255 <xsl:with-param name="text" select="$subst12" />
1256 <xsl:with-param name="replace" select="'&amp;'" />
1257 <xsl:with-param name="with" select="'\&amp;'" />
1258 <xsl:with-param name="disable-output-escaping" select="no" />
1259 </xsl:call-template>
1260 </xsl:variable>
1261 <xsl:variable name="subst14">
1262 <xsl:call-template name="str:subst">
1263 <xsl:with-param name="text" select="$subst13" />
1264 <xsl:with-param name="replace" select="'→'" />
1265 <xsl:with-param name="with" select="'\ensuremath{\rightarrow}'" />
1266 <xsl:with-param name="disable-output-escaping" select="no" />
1267 </xsl:call-template>
1268 </xsl:variable>
1269 <xsl:variable name="subst15">
1270 <xsl:call-template name="str:subst">
1271 <xsl:with-param name="text" select="$subst14" />
1272 <xsl:with-param name="replace" select="'←'" />
1273 <xsl:with-param name="with" select="'\ensuremath{\leftarrow}'" />
1274 <xsl:with-param name="disable-output-escaping" select="no" />
1275 </xsl:call-template>
1276 </xsl:variable>
1277 <xsl:variable name="subst16">
1278 <xsl:call-template name="str:subst">
1279 <xsl:with-param name="text" select="$subst15" />
1280 <xsl:with-param name="replace" select="'↔'" />
1281 <xsl:with-param name="with" select="'\ensuremath{\leftrightarrow}'" />
1282 <xsl:with-param name="disable-output-escaping" select="no" />
1283 </xsl:call-template>
1284 </xsl:variable>
1285 <xsl:value-of select="$subst16" />
1286 </xsl:otherwise>
1287 </xsl:choose>
1288 </xsl:template>
1289
1290 <!--
1291 xsltprocNewlineOutputHack - emits a single new line.
1292
1293 Hack Alert! This template helps xsltproc split up the output text elements
1294 and avoid reallocating them into the MB range. Calls to this
1295 template is made occationally while generating larger output
1296 file. It's not necessary for small stuff like header.
1297
1298 The trick we're playing on xsltproc has to do with CDATA
1299 and/or the escape setting of the xsl:text element. It forces
1300 xsltproc to allocate a new output element, thus preventing
1301 things from growing out of proportions and slowing us down.
1302
1303 This was successfully employed to reduce a 18+ seconds run to
1304 around one second (possibly less due to kmk overhead).
1305 -->
1306 <xsl:template name="xsltprocNewlineOutputHack">
1307 <xsl:text disable-output-escaping="yes"><![CDATA[
1308]]></xsl:text>
1309 </xsl:template>
1310
1311</xsl:stylesheet>
1312
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette