VirtualBox

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

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

doc/manual/docbook2latex.xsl: Eliminate utf8x package, instead replace the 3 missing code points directly.

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