VirtualBox

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

Last change on this file since 63656 was 59523, checked in by vboxsync, 9 years ago

Devices/PC/DevPit-i8254.cpp: update PC speaker passthrough, make it more configurable and improve logging
doc/manual: update for PC speaker passthrough, plus a tweak for the table layouts (doubling the minimum column width as it frequently happens that it makes them too narrow)

File size: 39.8 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 Copyright (C) 2006-2012 Oracle Corporation
22
23 This file is part of VirtualBox Open Source Edition (OSE), as
24 available from http://www.virtualbox.org. This file is free software;
25 you can redistribute it and/or modify it under the terms of the GNU
26 General Public License (GPL) as published by the Free Software
27 Foundation, in version 2 as it comes in the "COPYING" file of the
28 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
29 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
30 -->
31
32<xsl:stylesheet
33 version="1.0"
34 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
35 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
36 xmlns:str="http://xsltsl.org/string"
37>
38
39 <xsl:import href="string.xsl"/>
40 <xsl:import href="common-formatcfg.xsl"/>
41
42 <xsl:variable name="g_nlsChapter">
43 <xsl:choose>
44 <xsl:when test="$TARGETLANG='de_DE'">Kapitel</xsl:when>
45 <xsl:when test="$TARGETLANG='fr_FR'">chapitre</xsl:when>
46 <xsl:when test="$TARGETLANG='en_US'">chapter</xsl:when>
47 <xsl:otherwise>
48 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
49 </xsl:otherwise>
50 </xsl:choose>
51 </xsl:variable>
52
53 <xsl:variable name="g_nlsPage">
54 <xsl:choose>
55 <xsl:when test="$TARGETLANG='de_DE'">auf Seite</xsl:when>
56 <xsl:when test="$TARGETLANG='fr_FR'">page</xsl:when>
57 <xsl:when test="$TARGETLANG='en_US'">page</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_nlsNote">
65 <xsl:choose>
66 <xsl:when test="$TARGETLANG='de_DE'">Hinweis</xsl:when>
67 <xsl:when test="$TARGETLANG='fr_FR'">Note</xsl:when>
68 <xsl:when test="$TARGETLANG='en_US'">Note</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_nlsWarning">
76 <xsl:choose>
77 <xsl:when test="$TARGETLANG='de_DE'">Warnung</xsl:when>
78 <xsl:when test="$TARGETLANG='fr_FR'">Avertissement</xsl:when>
79 <xsl:when test="$TARGETLANG='en_US'">Warning</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:output method="text"/>
87
88 <xsl:strip-space elements="*"/>
89 <xsl:preserve-space elements="para"/>
90
91 <xsl:template match="/book">
92 <xsl:text>
93\documentclass[oneside,a4paper,10pt,DIV10]{scrbook}
94\usepackage{geometry}
95\geometry{top=3cm,bottom=4cm}
96\usepackage{ucs}
97\usepackage[utf8x]{inputenc}
98\usepackage[T1]{fontenc}
99\usepackage{tabulary}
100\usepackage[pdftex,
101 a4paper,
102 colorlinks=true,
103 linkcolor=blue,
104 urlcolor=darkgreen,
105 bookmarksnumbered,
106 bookmarksopen=true,
107 bookmarksopenlevel=0,
108 hyperfootnotes=false,
109 plainpages=false,
110 pdfpagelabels
111 ]{hyperref}
112
113\usepackage{nameref}
114\usepackage{graphicx}
115\usepackage{hyperref}
116\usepackage{fancybox}
117\usepackage{fancyvrb}
118\usepackage{alltt}
119\usepackage{color}
120\usepackage{scrextend}
121\definecolor{darkgreen}{rgb}{0,0.6,0}
122\tymin=21pt
123
124</xsl:text>
125 <xsl:if test="$TARGETLANG='de_DE'">\usepackage[ngerman]{babel}&#10;\PrerenderUnicode{ü}</xsl:if>
126<!-- <xsl:if test="$TARGETLANG='fr_FR'">\usepackage[french]{babel}&#10;\FrenchItemizeSpacingfalse&#10;\renewcommand{\FrenchLabelItem}{\textbullet}</xsl:if>
127 this command is no longer understood by TexLive2008
128 -->
129 <xsl:text>
130
131% use Palatino as serif font:
132% \usepackage{mathpazo}
133\usepackage{charter}
134% use Helvetica as sans-serif font:
135\usepackage{helvet}
136
137% use Bera Mono (a variant of Bitstream Vera Mono) as typewriter font
138% (requires texlive-fontsextra)
139\usepackage[scaled]{beramono}
140% previously: use Courier as typewriter font:
141% \usepackage{courier}
142
143\definecolor{colNote}{rgb}{0,0,0}
144\definecolor{colWarning}{rgb}{0,0,0}
145\definecolor{colScreenFrame}{rgb}{0,0,0}
146\definecolor{colScreenText}{rgb}{0,0,0}
147
148% number headings down to this level
149\setcounter{secnumdepth}{3}
150% more space for the section numbers
151\makeatletter
152\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.9em}}
153\renewcommand*\l@subsection{\@dottedtocline{2}{4.4em}{3.8em}}
154\renewcommand*\l@subsubsection{\@dottedtocline{3}{8.2em}{3.8em}}
155\renewcommand*\@pnumwidth{1.7em}
156\renewcommand*\@tocrmarg{5.0em}
157\makeatother
158
159% more tolerance at 2nd wrap stage:
160\tolerance = 1000
161% allow 3rd wrap stage:
162\emergencystretch = 10pt
163% no Schusterjungen:
164\clubpenalty = 10000
165% no Hurenkinder:
166\widowpenalty = 10000
167\displaywidowpenalty = 10000
168% max pdf compression:
169\pdfcompresslevel9
170
171% opening and closing quotes: the OQ and CQ macros define this (and the makefile employs some sed magic also)
172</xsl:text>
173 <xsl:choose>
174 <xsl:when test="$TARGETLANG='de_DE'">
175 <xsl:text>\newcommand\OQ{\texorpdfstring{\glqq}{"}}&#10;\newcommand\CQ{\texorpdfstring{\grqq}{"}}&#10;</xsl:text>
176 </xsl:when>
177 <xsl:when test="$TARGETLANG='fr_FR'">
178 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
179 </xsl:when>
180 <xsl:when test="$TARGETLANG='en_US'">
181 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
182 </xsl:when>
183 <xsl:otherwise>
184 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
185 </xsl:otherwise>
186 </xsl:choose>
187
188 <xsl:apply-templates />
189
190 <xsl:text>
191\end{document}
192 </xsl:text>
193
194 </xsl:template>
195
196 <xsl:template match="bookinfo">
197 <xsl:apply-templates />
198 <xsl:text>&#x0a;\newcommand\docbookbookinfocopyright{\copyright{} \docbookbookinfocopyrightyear{} \docbookbookinfocopyrightholder{}}&#x0a;
199\author{ \docbooktitleedition \\ %
200\\ %
201</xsl:text>
202 <xsl:if test="//bookinfo/address">
203 <xsl:text>\docbookbookinfoaddress \\ %
204\\ %
205</xsl:text>
206 </xsl:if>
207 <xsl:text>\docbookbookinfocopyright \\ %
208}
209
210\title{\docbooktitle \\
211\docbooksubtitle}
212% \subtitle{\docbooksubtitle}
213\hypersetup{pdfauthor=\docbookcorpauthor}
214\hypersetup{pdftitle=\docbooktitle{} \docbooksubtitle{}}
215
216\hyphenation{da-ta-ba-ses}
217\hyphenation{deb-conf}
218\hyphenation{VirtualBox}
219
220\begin{document}
221% \maketitle
222%\begin{titlepage}
223\thispagestyle{empty}
224\begin{minipage}{\textwidth}
225\begin{center}
226\includegraphics[width=4cm]{images/vboxlogo.png}
227\end{center}%
228\vspace{10mm}
229
230{\fontsize{40pt}{40pt}\selectfont\rmfamily\bfseries%
231\begin{center}
232\docbooktitle
233\end{center}%
234\vspace{10mm}
235}
236
237{\fontsize{30pt}{30pt}\selectfont\rmfamily\bfseries%
238\begin{center}
239\docbooksubtitle
240\end{center}%
241\vspace{10mm}
242}
243
244{\fontsize{16pt}{20pt}\selectfont\rmfamily%
245\begin{center}
246</xsl:text>
247 <xsl:if test="//bookinfo/othercredit">
248 <xsl:text>\docbookbookinfoothercreditcontrib{}: \docbookbookinfoothercreditfirstname{} \docbookbookinfoothercreditsurname
249
250\vspace{8mm}
251</xsl:text>
252 </xsl:if>
253 <xsl:text>\docbooktitleedition
254
255\vspace{2mm}
256
257\docbookbookinfocopyright
258
259\vspace{2mm}
260
261\docbookbookinfoaddress
262\end{center}%
263}
264
265%\end{titlepage}
266\end{minipage}
267
268\tableofcontents
269 </xsl:text>
270 </xsl:template>
271
272 <xsl:template match="subtitle">
273 <xsl:choose>
274 <xsl:when test="name(..)='bookinfo'">
275 <xsl:text>\newcommand\docbooksubtitle{</xsl:text>
276 <xsl:apply-templates />
277 <xsl:text>}</xsl:text>
278 </xsl:when>
279 </xsl:choose>
280 </xsl:template>
281
282 <!--
283 Inserts \hypertarget{@id} that can be referenced via the /A "nameddest=@id"
284 command line or #nameddest=@id URL parameter.
285
286 TODO: The placement of the target could be improved on. The raisebox
287 stuff is a crude hack to make it a little more acceptable. -->
288 <xsl:template name="title-wrapper">
289 <xsl:param name="texcmd" select="concat('\',name(..))"/>
290 <xsl:param name="refid" select="../@id"/>
291
292 <xsl:call-template name="xsltprocNewlineOutputHack"/>
293 <xsl:choose>
294 <xsl:when test="$refid">
295 <xsl:text>&#x0a;</xsl:text>
296 <xsl:value-of select="$texcmd"/>
297 <xsl:if test="not(contains($texcmd, '*'))">
298 <xsl:text>[</xsl:text> <!-- for toc -->
299 <xsl:apply-templates />
300 <xsl:text>]</xsl:text>
301 </xsl:if>
302 <xsl:text>{</xsl:text> <!-- for doc -->
303 <xsl:text>\raisebox{\ht\strutbox}{\hypertarget{</xsl:text>
304 <xsl:value-of select="$refid"/>
305 <xsl:text>}{}}</xsl:text>
306 <xsl:apply-templates />
307 <xsl:text>}</xsl:text>
308 </xsl:when>
309 <xsl:otherwise>
310 <xsl:text>&#x0a;</xsl:text><xsl:value-of select="$texcmd"/><xsl:text>{</xsl:text>
311 <xsl:apply-templates />
312 <xsl:text>}</xsl:text>
313 </xsl:otherwise>
314 </xsl:choose>
315 </xsl:template>
316
317 <xsl:template match="title">
318 <xsl:variable name="refid" select="../@id" />
319 <xsl:choose>
320 <xsl:when test="name(..)='bookinfo'">
321 <xsl:text>\newcommand\docbooktitle{</xsl:text>
322 <xsl:apply-templates />
323 <xsl:text>}</xsl:text>
324 </xsl:when>
325 <xsl:when test="name(..)='chapter'">
326 <xsl:call-template name="title-wrapper"/>
327 </xsl:when>
328 <xsl:when test="name(..)='sect1'">
329 <xsl:call-template name="title-wrapper">
330 <xsl:with-param name="texcmd">\section</xsl:with-param>
331 </xsl:call-template>
332 </xsl:when>
333 <xsl:when test="parent::sect2[@role='not-in-toc'] or parent::refsect1 or (parent::section and count(ancestor::section) = 2)">
334 <xsl:call-template name="title-wrapper">
335 <xsl:with-param name="texcmd">\subsection*</xsl:with-param>
336 </xsl:call-template>
337 </xsl:when>
338 <xsl:when test="name(..)='sect2'">
339 <xsl:call-template name="title-wrapper">
340 <xsl:with-param name="texcmd">\subsection</xsl:with-param>
341 </xsl:call-template>
342 </xsl:when>
343 <xsl:when test="parent::sect3[@role='not-in-toc'] or parent::refsect2 or (parent::section and count(ancestor::section) = 3)">
344 <xsl:call-template name="title-wrapper">
345 <xsl:with-param name="texcmd">\subsubsection*</xsl:with-param>
346 </xsl:call-template>
347 </xsl:when>
348 <xsl:when test="name(..)='sect3'">
349 <xsl:call-template name="title-wrapper">
350 <xsl:with-param name="texcmd">\subsubsection</xsl:with-param>
351 </xsl:call-template>
352 </xsl:when>
353 <xsl:when test="parent::sect4[@role='not-in-toc'] or parent::refsect3 or (parent::section and count(ancestor::section) = 4)">
354 <xsl:call-template name="title-wrapper">
355 <xsl:with-param name="texcmd">\paragraph*</xsl:with-param>
356 </xsl:call-template>
357 </xsl:when>
358 <xsl:when test="name(..)='sect4'">
359 <xsl:call-template name="title-wrapper">
360 <xsl:with-param name="texcmd">\paragraph</xsl:with-param>
361 </xsl:call-template>
362 </xsl:when>
363 <xsl:when test="parent::sect5[@role='not-in-toc'] or parent::refsect4 or (parent::section and count(ancestor::section) = 5)">
364 <xsl:call-template name="title-wrapper">
365 <xsl:with-param name="texcmd">\subparagraph*</xsl:with-param>
366 </xsl:call-template>
367 </xsl:when>
368 <xsl:when test="name(..)='sect5'">
369 <xsl:call-template name="title-wrapper">
370 <xsl:with-param name="texcmd">\subparagraph</xsl:with-param>
371 </xsl:call-template>
372 </xsl:when>
373 <xsl:when test="name(..)='appendix'">
374 <xsl:call-template name="title-wrapper">
375 <xsl:with-param name="texcmd">\chapter</xsl:with-param>
376 </xsl:call-template>
377 </xsl:when>
378 <xsl:when test="name(..)='glossdiv'">
379 <xsl:call-template name="title-wrapper">
380 <xsl:with-param name="texcmd">\section*</xsl:with-param>
381 </xsl:call-template>
382 </xsl:when>
383 </xsl:choose>
384 <xsl:if test="$refid">
385 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
386 </xsl:if>
387 <xsl:text>&#x0a;</xsl:text>
388 </xsl:template>
389
390 <xsl:template match="edition">
391 <xsl:choose>
392 <xsl:when test="name(..)='bookinfo'">
393 <xsl:text>\newcommand\docbooktitleedition{</xsl:text>
394 <xsl:apply-templates />
395 <xsl:text>}&#x0a;</xsl:text>
396 </xsl:when>
397 </xsl:choose>
398 </xsl:template>
399
400 <xsl:template match="corpauthor">
401 <xsl:choose>
402 <xsl:when test="name(..)='bookinfo'">
403 <xsl:text>\newcommand\docbookcorpauthor{</xsl:text>
404 <xsl:apply-templates />
405 <xsl:text>}&#x0a;</xsl:text>
406 </xsl:when>
407 </xsl:choose>
408 </xsl:template>
409
410 <xsl:template match="address">
411 <xsl:choose>
412 <xsl:when test="name(..)='bookinfo'">
413 <xsl:text>\newcommand\docbookbookinfoaddress{</xsl:text>
414 <xsl:apply-templates />
415 <xsl:text>}&#x0a;</xsl:text>
416 </xsl:when>
417 </xsl:choose>
418 </xsl:template>
419
420 <xsl:template match="year">
421 <xsl:choose>
422 <xsl:when test="name(..)='copyright'">
423 <xsl:text>\newcommand\docbookbookinfocopyrightyear{</xsl:text>
424 <xsl:apply-templates />
425 <xsl:text>}&#x0a;</xsl:text>
426 </xsl:when>
427 </xsl:choose>
428 </xsl:template>
429
430 <xsl:template match="holder">
431 <xsl:choose>
432 <xsl:when test="name(..)='copyright'">
433 <xsl:text>\newcommand\docbookbookinfocopyrightholder{</xsl:text>
434 <xsl:apply-templates />
435 <xsl:text>}&#x0a;</xsl:text>
436 </xsl:when>
437 </xsl:choose>
438 </xsl:template>
439
440 <xsl:template match="firstname">
441 <xsl:choose>
442 <xsl:when test="name(..)='othercredit'">
443 <xsl:text>\newcommand\docbookbookinfoothercreditfirstname{</xsl:text>
444 <xsl:apply-templates />
445 <xsl:text>}&#x0a;</xsl:text>
446 </xsl:when>
447 </xsl:choose>
448 </xsl:template>
449
450 <xsl:template match="surname">
451 <xsl:choose>
452 <xsl:when test="name(..)='othercredit'">
453 <xsl:text>\newcommand\docbookbookinfoothercreditsurname{</xsl:text>
454 <xsl:apply-templates />
455 <xsl:text>}&#x0a;</xsl:text>
456 </xsl:when>
457 </xsl:choose>
458 </xsl:template>
459
460 <xsl:template match="contrib">
461 <xsl:choose>
462 <xsl:when test="name(..)='othercredit'">
463 <xsl:text>\newcommand\docbookbookinfoothercreditcontrib{</xsl:text>
464 <xsl:apply-templates />
465 <xsl:text>}&#x0a;</xsl:text>
466 </xsl:when>
467 </xsl:choose>
468 </xsl:template>
469
470 <xsl:template match="glossary">
471 <xsl:text>&#x0a;&#x0a;\backmatter&#x0a;\chapter{Glossary}&#x0a;</xsl:text>
472 <xsl:apply-templates />
473 </xsl:template>
474
475 <xsl:template match="para">
476 <xsl:if test="not(name(..)='footnote' or name(..)='note' or name(..)='warning' or (name(../..)='varlistentry' and position()=1))">
477 <xsl:text>&#x0a;&#x0a;</xsl:text>
478 </xsl:if>
479 <xsl:apply-templates />
480 </xsl:template>
481
482 <xsl:template match="note">
483 <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, ':} ')" />
484 <xsl:apply-templates />
485 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
486 </xsl:template>
487
488 <xsl:template match="warning">
489 <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, ':} ')" />
490 <xsl:apply-templates />
491 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
492 </xsl:template>
493
494 <xsl:template match="screen">
495 <xsl:text>&#x0a;&#x0a;\begin{Verbatim}[fontsize=\footnotesize]&#x0a;</xsl:text>
496 <xsl:apply-templates />
497 <xsl:text>&#x0a;\end{Verbatim}&#x0a;</xsl:text>
498 </xsl:template>
499
500 <xsl:template match="programlisting">
501 <xsl:text>&#x0a;&#x0a;{\small\begin{alltt}&#x0a;</xsl:text>
502 <xsl:apply-templates />
503 <xsl:text>&#x0a;\end{alltt}}&#x0a;</xsl:text>
504 </xsl:template>
505
506 <xsl:template match="footnote">
507 <xsl:text>\footnote{</xsl:text>
508 <xsl:apply-templates />
509 <xsl:text>}</xsl:text>
510 </xsl:template>
511
512 <xsl:template match="tgroup">
513 <xsl:choose>
514 <xsl:when test="@style='verywide'">
515 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{1.1\textwidth}[]</xsl:text>
516 </xsl:when>
517 <xsl:otherwise>
518 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{.9\textwidth}[]</xsl:text>
519 </xsl:otherwise>
520 </xsl:choose>
521 <xsl:text>{</xsl:text>
522 <xsl:choose>
523 <xsl:when test="@cols='1'">
524 <xsl:text>|L|</xsl:text>
525 </xsl:when>
526 <xsl:when test="@cols='2'">
527 <xsl:text>|L|L|</xsl:text>
528 </xsl:when>
529 <xsl:when test="@cols='3'">
530 <xsl:text>|L|L|L|</xsl:text>
531 </xsl:when>
532 <xsl:when test="@cols='4'">
533 <xsl:text>|L|L|L|L|</xsl:text>
534 </xsl:when>
535 <xsl:when test="@cols='5'">
536 <xsl:text>|L|L|L|L|L|</xsl:text>
537 </xsl:when>
538 <xsl:when test="@cols='6'">
539 <xsl:text>|L|L|L|L|L|L|</xsl:text>
540 </xsl:when>
541 <xsl:otherwise>
542 <xsl:message terminate="yes">Unsupported number of columns (<xsl:value-of select="@cols"/>), fix document or converter</xsl:message>
543 </xsl:otherwise>
544 </xsl:choose>
545 <xsl:text>}&#x0a;\hline&#x0a;</xsl:text>
546 <xsl:apply-templates />
547 <xsl:text>&#x0a;\end{tabulary}&#x0a;\end{center}}&#x0a;</xsl:text>
548 </xsl:template>
549
550 <xsl:template match="row">
551 <xsl:apply-templates />
552 <xsl:text>&#x0a;\\ \hline&#x0a;</xsl:text>
553 </xsl:template>
554
555 <xsl:template match="entry">
556 <xsl:if test="not(position()=1)">
557 <xsl:text> &amp; </xsl:text>
558 </xsl:if>
559 <xsl:apply-templates />
560 </xsl:template>
561
562 <xsl:template match="itemizedlist">
563 <xsl:call-template name="xsltprocNewlineOutputHack"/>
564 <xsl:text>&#x0a;\begin{itemize}&#x0a;</xsl:text>
565 <xsl:apply-templates />
566 <xsl:text>&#x0a;\end{itemize}&#x0a;</xsl:text>
567 </xsl:template>
568
569 <xsl:template match="orderedlist">
570 <xsl:call-template name="xsltprocNewlineOutputHack"/>
571 <xsl:text>&#x0a;\begin{enumerate}&#x0a;</xsl:text>
572 <xsl:apply-templates />
573 <xsl:text>&#x0a;\end{enumerate}&#x0a;</xsl:text>
574 </xsl:template>
575
576 <xsl:template match="variablelist">
577 <xsl:call-template name="xsltprocNewlineOutputHack"/>
578 <xsl:text>&#x0a;\begin{description}&#x0a;</xsl:text>
579 <xsl:apply-templates />
580 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
581 </xsl:template>
582
583 <xsl:template match="varlistentry">
584 <xsl:if test="not(./term) or not(./listitem) or count(*) != 2">
585 <xsl:message terminate="yes">Expected exactly one term and one listitem element in the varlistentry.</xsl:message>
586 </xsl:if>
587 <xsl:text>&#x0a;&#x0a;\item[</xsl:text>
588 <xsl:apply-templates select="term"/>
589 <xsl:text>] \hfill \\&#x0a;</xsl:text>
590 <xsl:apply-templates select="listitem/*"/>
591 </xsl:template>
592
593 <xsl:template match="listitem">
594 <xsl:text>&#x0a;&#x0a;\item </xsl:text>
595 <xsl:apply-templates />
596 <xsl:text>&#x0a;</xsl:text>
597 </xsl:template>
598
599 <xsl:template match="glossterm">
600 <xsl:variable name="refid" select="(@id)" />
601 <xsl:if test="$refid">
602 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
603 </xsl:if>
604 <xsl:text>&#x0a;&#x0a;\item[</xsl:text>
605 <xsl:apply-templates />
606 <xsl:text>]</xsl:text>
607 </xsl:template>
608
609 <xsl:template match="glosslist | glossdiv">
610 <xsl:text>&#x0a;&#x0a;\begin{description}&#x0a;</xsl:text>
611 <xsl:apply-templates />
612 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
613 </xsl:template>
614
615 <xsl:template match="superscript">
616 <xsl:variable name="contents">
617 <xsl:apply-templates />
618 </xsl:variable>
619 <xsl:value-of select="concat('\texorpdfstring{\textsuperscript{', $contents, '}}{', $contents, '}')" />
620 </xsl:template>
621
622 <xsl:template match="emphasis">
623 <xsl:choose>
624 <xsl:when test="@role='bold'">
625 <xsl:text>\textbf{</xsl:text>
626 </xsl:when>
627 <xsl:otherwise>
628 <xsl:text>\textit{</xsl:text>
629 </xsl:otherwise>
630 </xsl:choose>
631 <xsl:apply-templates />
632 <xsl:text>}</xsl:text>
633 </xsl:template>
634
635 <xsl:template match="computeroutput | code">
636 <xsl:text>\texttt{</xsl:text>
637 <xsl:apply-templates />
638 <xsl:text>}</xsl:text>
639 </xsl:template>
640
641 <xsl:template match="ulink">
642 <xsl:text>\url{</xsl:text>
643 <xsl:apply-templates />
644 <xsl:text>}</xsl:text>
645 </xsl:template>
646
647 <xsl:template match="xref">
648 <xsl:choose>
649 <xsl:when test="@endterm">
650 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
651 </xsl:when>
652 <xsl:otherwise>
653 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
654 </xsl:otherwise>
655 </xsl:choose>
656 </xsl:template>
657
658 <xsl:template match="link">
659 <xsl:choose>
660 <xsl:when test="@endterm">
661 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
662 </xsl:when>
663 <xsl:when test="./text()">
664 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{')" />
665 <xsl:apply-templates select="./text()"/>
666 <xsl:value-of select="'}}'" />
667 </xsl:when>
668 <xsl:otherwise>
669 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
670 </xsl:otherwise>
671 </xsl:choose>
672 </xsl:template>
673
674 <!-- for some reason, DocBook insists of having image data nested this way always:
675 mediaobject -> imageobject -> imagedata
676 but only imagedata is interesting -->
677 <xsl:template match="imagedata">
678 <xsl:if test="@align='center'">
679 <xsl:text>\begin{center}</xsl:text>
680 </xsl:if>
681 <xsl:value-of select="concat('&#x0a;\includegraphics[width=', @width, ']{', @fileref, '}&#x0a;')" />
682 <xsl:apply-templates />
683 <xsl:if test="@align='center'">
684 <xsl:text>\end{center}</xsl:text>
685 </xsl:if>
686 </xsl:template>
687
688 <!--
689 Turn the refsynopsisdiv part of a manpage into a named & indented paragraph.
690 -->
691 <xsl:template match="refsynopsisdiv">
692 <xsl:if test="name(*[1]) != 'cmdsynopsis'"><xsl:message terminate="yes">Expected refsynopsisdiv to start with cmdsynopsis</xsl:message></xsl:if>
693 <xsl:if test="title"><xsl:message terminate="yes">No title element supported in refsynopsisdiv</xsl:message></xsl:if>
694 <xsl:call-template name="xsltprocNewlineOutputHack"/>
695 <xsl:text>&#x0a;\subsection*{Synopsis}</xsl:text>
696 <xsl:if test="name(*[1]) != 'cmdsynopsis'"> <!-- just in case -->
697 <xsl:text>\hfill \\&#x0a;</xsl:text>
698 </xsl:if>
699 <xsl:text>&#x0a;</xsl:text>
700 <xsl:apply-templates />
701 </xsl:template>
702
703 <!--
704 The refsect1 is used for 'Description' and such. Do same as with refsynopsisdiv
705 and turn it into a named & indented paragraph.
706 -->
707 <xsl:template match="refsect1">
708 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
709 <xsl:message terminate="yes">Expected exactly one title as the first refsect1 element (remarks goes after title!).</xsl:message>
710 </xsl:if>
711 <xsl:apply-templates/>
712 </xsl:template>
713
714 <!--
715 The refsect2 element will be turned into a subparagraph if it has a title,
716 however, that didn't work out when it didn't have a title and started with
717 a cmdsynopsis instead (subcommand docs). So, we're doing some trickery
718 here (HACK ALERT) for the non-title case to feign a paragraph.
719 -->
720 <xsl:template match="refsect2">
721 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
722 <xsl:message terminate="yes">Expected exactly one title as the first refsect2 element (remarks goes after title!).</xsl:message>
723 </xsl:if>
724 <xsl:apply-templates/>
725 <xsl:text>&#x0a;</xsl:text>
726 </xsl:template>
727
728
729 <!--
730 Command Synopsis elements.
731
732 We treat each command element inside a cmdsynopsis as the start of
733 a new paragraph. The DocBook HTML converter does so too, but the
734 manpage one doesn't.
735
736 sbr and linebreaks made by latex should be indented from the base
737 command level. This is done by the \hangindent3em\hangafter1 bits.
738
739 We exploit the default paragraph indentation to get each command
740 indented from the left margin. This, unfortunately, doesn't work
741 if we're the first paragraph in a (sub*)section. \noindent cannot
742 counter this due to when latex enforces first paragraph stuff. Since
743 it's tedious to figure out when we're in the first paragraph and when
744 not, we just do \noindent\hspace{1em} everywhere.
745 -->
746 <xsl:template match="sbr">
747 <xsl:if test="not(ancestor::cmdsynopsis)">
748 <xsl:message terminate="yes">sbr only supported inside cmdsynopsis (because of hangindent)</xsl:message>
749 </xsl:if>
750 <xsl:text>\linebreak</xsl:text>
751 </xsl:template>
752
753 <xsl:template match="refentry|refnamediv|refentryinfo|refmeta|refsect3|refsect4|refsect5|synopfragment|synopfragmentref|cmdsynopsis/info">
754 <xsl:message terminate="yes"><xsl:value-of select="name()"/> is not supported</xsl:message>
755 </xsl:template>
756
757 <xsl:template match="cmdsynopsis">
758 <xsl:if test="preceding-sibling::cmdsynopsis">
759 <xsl:text>\par%cmdsynopsis</xsl:text>
760 </xsl:if>
761 <xsl:text>&#x0a;</xsl:text>
762 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
763 <!-- Overview fontsize trick -->
764 <xsl:text>{\footnotesize</xsl:text>
765 </xsl:if>
766 <xsl:text>\noindent\hspace{1em}</xsl:text>
767 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
768 <xsl:apply-templates />
769 <xsl:text>}</xsl:text>
770 <xsl:if test="following-sibling::*">
771 </xsl:if>
772
773 <!-- For refsect2 subcommand descriptions. -->
774 <xsl:if test="not(following-sibling::cmdsynopsis) and position() != last()">
775 <xsl:text>\linebreak</xsl:text>
776 </xsl:if>
777 <!-- Special overview trick for the current VBoxManage command overview. -->
778 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
779 <xsl:text>}\vspace{1em}</xsl:text>
780 </xsl:if>
781 </xsl:template>
782
783 <xsl:template match="command">
784 <xsl:choose>
785 <xsl:when test="ancestor::cmdsynopsis">
786 <!-- Trigger a line break if this isn't the first command in a the synopsis -->
787 <xsl:if test="preceding-sibling::command">
788 <xsl:text>}\par%command&#x0a;</xsl:text>
789 <xsl:text>\noindent\hspace{1em}</xsl:text>
790 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
791 </xsl:if>
792 <xsl:apply-templates />
793 </xsl:when>
794 <xsl:otherwise>
795 <xsl:text>\texttt{</xsl:text>
796 <xsl:apply-templates />
797 <xsl:text>}</xsl:text>
798 </xsl:otherwise>
799 </xsl:choose>
800 </xsl:template>
801
802 <xsl:template match="option">
803 <xsl:choose>
804 <xsl:when test="ancestor::cmdsynopsis">
805 <xsl:apply-templates />
806 </xsl:when>
807 <xsl:otherwise>
808 <xsl:text>\texttt{</xsl:text>
809 <xsl:apply-templates />
810 <xsl:text>}</xsl:text>
811 </xsl:otherwise>
812 </xsl:choose>
813 </xsl:template>
814
815 <!-- duplicated in docbook2latex.xsl -->
816 <xsl:template match="arg|group">
817 <!-- separator char if we're not the first child -->
818 <xsl:if test="position() > 1">
819 <xsl:choose>
820 <xsl:when test="parent::group"><xsl:value-of select="$arg.or.sep"/></xsl:when>
821 <xsl:when test="ancestor-or-self::*/@sepchar"><xsl:value-of select="ancestor-or-self::*/@sepchar"/></xsl:when>
822 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
823 </xsl:choose>
824 </xsl:if>
825 <!-- open wrapping -->
826 <xsl:choose>
827 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.open.str"/></xsl:when>
828 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/></xsl:when>
829 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.open.str"/></xsl:when>
830 <xsl:when test="@choice = 'plain'"/>
831 <xsl:otherwise><xsl:message terminate="yes">Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise>
832 </xsl:choose>
833
834 <!-- render the arg (TODO: may need to do more work here) -->
835 <xsl:apply-templates />
836
837 <!-- repeat wrapping -->
838 <xsl:choose>
839 <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/>
840 <xsl:when test="@rep = 'repeat'"> <xsl:value-of select="$arg.rep.repeat.str"/></xsl:when>
841 <xsl:otherwise><xsl:message terminate="yes">Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise>
842 </xsl:choose>
843 <!-- close wrapping -->
844 <xsl:choose>
845 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.close.str"/></xsl:when>
846 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.close.str"/></xsl:when>
847 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.close.str"/></xsl:when>
848 </xsl:choose>
849 </xsl:template>
850
851 <xsl:template match="replaceable">
852 <xsl:choose>
853 <xsl:when test="not(ancestor::cmdsynopsis) or ancestor::arg">
854 <xsl:text>\texttt{\textit{</xsl:text>
855 <xsl:apply-templates />
856 <xsl:text>}}</xsl:text>
857 </xsl:when>
858 <xsl:otherwise>
859 <xsl:text>\textit{&lt;</xsl:text>
860 <xsl:apply-templates />
861 <xsl:text>&gt;}</xsl:text>
862 </xsl:otherwise>
863 </xsl:choose>
864 </xsl:template>
865
866
867 <!--
868 Generic element text magic.
869 -->
870 <xsl:template match="//text()">
871
872 <xsl:variable name="subst1">
873 <xsl:call-template name="str:subst">
874 <xsl:with-param name="text" select="." />
875 <xsl:with-param name="replace" select="'\'" />
876 <xsl:with-param name="with" select="'\textbackslash{}'" />
877 <xsl:with-param name="disable-output-escaping" select="no" />
878 </xsl:call-template>
879 </xsl:variable>
880
881 <xsl:choose>
882 <xsl:when test="(name(..)='screen') or (name(../..)='screen')">
883 <xsl:value-of select="." />
884 </xsl:when>
885
886 <xsl:when test="(name(..) = 'computeroutput') or (name(../..) = 'computeroutput')
887 or (name(..) = 'code') or (name(../..) = 'code')
888 or (name(..) = 'arg') or (name(../..) = 'arg')
889 or (name(..) = 'option') or (name(../..) = 'option')
890 or (name(..) = 'command') or (name(../..) = 'command')
891 or (name(..) = 'cmdsynopsis') or (name(../..) = 'cmdsynopsis')
892 or (name(..) = 'replaceable') or (name(../..) = 'replaceable')
893 ">
894 <xsl:variable name="subst2">
895 <xsl:call-template name="str:subst">
896 <xsl:with-param name="text" select="$subst1" />
897 <xsl:with-param name="replace" select="'--'" />
898 <xsl:with-param name="with" select="'-{}-'" />
899 <xsl:with-param name="disable-output-escaping" select="no" />
900 </xsl:call-template>
901 </xsl:variable>
902 <xsl:variable name="subst3">
903 <xsl:call-template name="str:subst">
904 <xsl:with-param name="text" select="$subst2" />
905 <xsl:with-param name="replace" select="'_'" />
906 <xsl:with-param name="with" select="'\_'" />
907 <xsl:with-param name="disable-output-escaping" select="no" />
908 </xsl:call-template>
909 </xsl:variable>
910 <xsl:variable name="subst4">
911 <xsl:call-template name="str:subst">
912 <xsl:with-param name="text" select="$subst3" />
913 <xsl:with-param name="replace" select="'$'" />
914 <xsl:with-param name="with" select="'\$'" />
915 <xsl:with-param name="disable-output-escaping" select="no" />
916 </xsl:call-template>
917 </xsl:variable>
918 <xsl:variable name="subst5">
919 <xsl:call-template name="str:subst">
920 <xsl:with-param name="text" select="$subst4" />
921 <xsl:with-param name="replace" select="'%'" />
922 <xsl:with-param name="with" select="'\%'" />
923 <xsl:with-param name="disable-output-escaping" select="no" />
924 </xsl:call-template>
925 </xsl:variable>
926 <xsl:variable name="subst6">
927 <xsl:call-template name="str:subst">
928 <xsl:with-param name="text" select="$subst5" />
929 <xsl:with-param name="replace" select="'#'" />
930 <xsl:with-param name="with" select="'\#'" />
931 <xsl:with-param name="disable-output-escaping" select="no" />
932 </xsl:call-template>
933 </xsl:variable>
934 <xsl:variable name="subst7">
935 <xsl:call-template name="str:subst">
936 <xsl:with-param name="text" select="$subst6" />
937 <xsl:with-param name="replace" select="'~'" />
938 <xsl:with-param name="with" select="'\textasciitilde '" />
939 <xsl:with-param name="disable-output-escaping" select="no" />
940 </xsl:call-template>
941 </xsl:variable>
942 <xsl:variable name="subst8">
943 <xsl:call-template name="str:subst">
944 <xsl:with-param name="text" select="$subst7" />
945 <xsl:with-param name="replace" select="'&amp;'" />
946 <xsl:with-param name="with" select="'\&amp;'" />
947 <xsl:with-param name="disable-output-escaping" select="no" />
948 </xsl:call-template>
949 </xsl:variable>
950 <xsl:choose>
951 <xsl:when test="parent::arg or parent::command">
952 <xsl:variable name="subst9">
953 <xsl:call-template name="str:subst">
954 <xsl:with-param name="text" select="$subst8" />
955 <xsl:with-param name="replace" select="' '" />
956 <xsl:with-param name="with" select="'~'" />
957 <xsl:with-param name="disable-output-escaping" select="no" />
958 </xsl:call-template>
959 </xsl:variable>
960 <xsl:value-of select="$subst9" />
961 </xsl:when>
962 <xsl:otherwise>
963 <xsl:value-of select="$subst8" />
964 </xsl:otherwise>
965 </xsl:choose>
966 </xsl:when>
967
968 <xsl:when test="(name(..)='address') or (name(../..)='address')">
969 <xsl:variable name="subst2">
970 <xsl:call-template name="str:subst">
971 <xsl:with-param name="text" select="$subst1" />
972 <xsl:with-param name="replace" select="'&#x0a;'" />
973 <xsl:with-param name="with" select="' \\'" />
974 <xsl:with-param name="disable-output-escaping" select="no" />
975 </xsl:call-template>
976 </xsl:variable>
977 <xsl:value-of select="$subst2" />
978 </xsl:when>
979
980 <xsl:otherwise>
981 <xsl:variable name="subst2">
982 <xsl:call-template name="str:subst">
983 <xsl:with-param name="text" select="$subst1" />
984 <xsl:with-param name="replace" select="'_'" />
985 <xsl:with-param name="with" select="'\_'" />
986 <xsl:with-param name="disable-output-escaping" select="no" />
987 </xsl:call-template>
988 </xsl:variable>
989 <xsl:variable name="subst3">
990 <xsl:call-template name="str:subst">
991 <xsl:with-param name="text" select="$subst2" />
992 <xsl:with-param name="replace" select="'$'" />
993 <xsl:with-param name="with" select="'\$'" />
994 <xsl:with-param name="disable-output-escaping" select="no" />
995 </xsl:call-template>
996 </xsl:variable>
997 <xsl:variable name="subst4">
998 <xsl:call-template name="str:subst">
999 <xsl:with-param name="text" select="$subst3" />
1000 <xsl:with-param name="replace" select="'%'" />
1001 <xsl:with-param name="with" select="'\%'" />
1002 <xsl:with-param name="disable-output-escaping" select="no" />
1003 </xsl:call-template>
1004 </xsl:variable>
1005 <xsl:variable name="subst5">
1006 <xsl:call-template name="str:subst">
1007 <xsl:with-param name="text" select="$subst4" />
1008 <xsl:with-param name="replace" select="'#'" />
1009 <xsl:with-param name="with" select="'\#'" />
1010 <xsl:with-param name="disable-output-escaping" select="no" />
1011 </xsl:call-template>
1012 </xsl:variable>
1013 <xsl:variable name="subst6">
1014 <xsl:call-template name="str:subst">
1015 <xsl:with-param name="text" select="$subst5" />
1016 <xsl:with-param name="replace" select="'µ'" />
1017 <xsl:with-param name="with" select="'$\mu$'" />
1018 <xsl:with-param name="disable-output-escaping" select="no" />
1019 </xsl:call-template>
1020 </xsl:variable>
1021 <xsl:variable name="subst7">
1022 <xsl:call-template name="str:subst">
1023 <xsl:with-param name="text" select="$subst6" />
1024 <xsl:with-param name="replace" select="'®'" />
1025 <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
1026 <xsl:with-param name="disable-output-escaping" select="no" />
1027 </xsl:call-template>
1028 </xsl:variable>
1029 <xsl:variable name="quote">"</xsl:variable>
1030 <!-- preparation for pretty quotes: replace all double quotes _outside_ screen
1031 sections with "\QUOTE{}" strings, which the makefile will then replace
1032 with pretty quotes by invoking sed a few times. Unfortunately there are
1033 no regular expressions in XSLT so there's no other way. -->
1034 <xsl:variable name="subst8">
1035 <xsl:call-template name="str:subst">
1036 <xsl:with-param name="text" select="$subst7" />
1037 <xsl:with-param name="replace" select="$quote" />
1038 <xsl:with-param name="with" select="'\QUOTE{}'" />
1039 <xsl:with-param name="disable-output-escaping" select="no" />
1040 </xsl:call-template>
1041 </xsl:variable>
1042 <xsl:variable name="subst9">
1043 <xsl:call-template name="str:subst">
1044 <xsl:with-param name="text" select="$subst8" />
1045 <xsl:with-param name="replace" select="'~'" />
1046 <xsl:with-param name="with" select="'\textasciitilde '" />
1047 <xsl:with-param name="disable-output-escaping" select="no" />
1048 </xsl:call-template>
1049 </xsl:variable>
1050 <xsl:variable name="subst10">
1051 <xsl:call-template name="str:subst">
1052 <xsl:with-param name="text" select="$subst9" />
1053 <xsl:with-param name="replace" select="'&amp;'" />
1054 <xsl:with-param name="with" select="'\&amp;'" />
1055 <xsl:with-param name="disable-output-escaping" select="no" />
1056 </xsl:call-template>
1057 </xsl:variable>
1058 <xsl:value-of select="$subst10" />
1059 </xsl:otherwise>
1060 </xsl:choose>
1061 </xsl:template>
1062
1063 <!--
1064 xsltprocNewlineOutputHack - emits a single new line.
1065
1066 Hack Alert! This template helps xsltproc split up the output text elements
1067 and avoid reallocating them into the MB range. Calls to this
1068 template is made occationally while generating larger output
1069 file. It's not necessary for small stuff like header.
1070
1071 The trick we're playing on xsltproc has to do with CDATA
1072 and/or the escape setting of the xsl:text element. It forces
1073 xsltproc to allocate a new output element, thus preventing
1074 things from growing out of proportions and slowing us down.
1075
1076 This was successfully employed to reduce a 18+ seconds run to
1077 around one second (possibly less due to kmk overhead).
1078 -->
1079 <xsl:template name="xsltprocNewlineOutputHack">
1080 <xsl:text disable-output-escaping="yes"><![CDATA[
1081]]></xsl:text>
1082 </xsl:template>
1083
1084</xsl:stylesheet>
1085
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