VirtualBox

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

Last change on this file since 56498 was 56483, checked in by vboxsync, 9 years ago

syntax diagram tweaking.

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