VirtualBox

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

Last change on this file since 57447 was 56565, checked in by vboxsync, 9 years ago

Implemented itemizedlist; fixed lost space between arg and replaceable; underlined refsect1 and refsect2 titles.

File size: 39.0 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="@endterm">
624 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
625 </xsl:when>
626 <xsl:otherwise>
627 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
628 </xsl:otherwise>
629 </xsl:choose>
630 </xsl:template>
631
632 <xsl:template match="link">
633 <xsl:choose>
634 <xsl:when test="@endterm">
635 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
636 </xsl:when>
637 <xsl:when test="./text()">
638 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{')" />
639 <xsl:apply-templates select="./text()"/>
640 <xsl:value-of select="'}}'" />
641 </xsl:when>
642 <xsl:otherwise>
643 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
644 </xsl:otherwise>
645 </xsl:choose>
646 </xsl:template>
647
648 <!-- for some reason, DocBook insists of having image data nested this way always:
649 mediaobject -> imageobject -> imagedata
650 but only imagedata is interesting -->
651 <xsl:template match="imagedata">
652 <xsl:if test="@align='center'">
653 <xsl:text>\begin{center}</xsl:text>
654 </xsl:if>
655 <xsl:value-of select="concat('&#x0a;\includegraphics[width=', @width, ']{', @fileref, '}&#x0a;')" />
656 <xsl:apply-templates />
657 <xsl:if test="@align='center'">
658 <xsl:text>\end{center}</xsl:text>
659 </xsl:if>
660 </xsl:template>
661
662 <!--
663 Turn the refsynopsisdiv part of a manpage into a named & indented paragraph.
664 -->
665 <xsl:template match="refsynopsisdiv">
666 <xsl:if test="name(*[1]) != 'cmdsynopsis'"><xsl:message terminate="yes">Expected refsynopsisdiv to start with cmdsynopsis</xsl:message></xsl:if>
667 <xsl:if test="title"><xsl:message terminate="yes">No title element supported in refsynopsisdiv</xsl:message></xsl:if>
668 <xsl:call-template name="xsltprocNewlineOutputHack"/>
669 <xsl:text>&#x0a;\subsection*{Synopsis}</xsl:text>
670 <xsl:if test="name(*[1]) != 'cmdsynopsis'"> <!-- just in case -->
671 <xsl:text>\hfill \\&#x0a;</xsl:text>
672 </xsl:if>
673 <xsl:text>&#x0a;</xsl:text>
674 <xsl:apply-templates />
675 </xsl:template>
676
677 <!--
678 The refsect1 is used for 'Description' and such. Do same as with refsynopsisdiv
679 and turn it into a named & indented paragraph.
680 -->
681 <xsl:template match="refsect1">
682 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
683 <xsl:message terminate="yes">Expected exactly one title as the first refsect1 element (remarks goes after title!).</xsl:message>
684 </xsl:if>
685 <xsl:apply-templates/>
686 </xsl:template>
687
688 <!--
689 The refsect2 element will be turned into a subparagraph if it has a title,
690 however, that didn't work out when it didn't have a title and started with
691 a cmdsynopsis instead (subcommand docs). So, we're doing some trickery
692 here (HACK ALERT) for the non-title case to feign a paragraph.
693 -->
694 <xsl:template match="refsect2">
695 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
696 <xsl:message terminate="yes">Expected exactly one title as the first refsect2 element (remarks goes after title!).</xsl:message>
697 </xsl:if>
698 <xsl:apply-templates/>
699 <xsl:text>&#x0a;</xsl:text>
700 </xsl:template>
701
702
703 <!--
704 Command Synopsis elements.
705
706 We treat each command element inside a cmdsynopsis as the start of
707 a new paragraph. The DocBook HTML converter does so too, but the
708 manpage one doesn't.
709
710 sbr and linebreaks made by latex should be indented from the base
711 command level. This is done by the \hangindent3em\hangafter1 bits.
712
713 We exploit the default paragraph indentation to get each command
714 indented from the left margin. This, unfortunately, doesn't work
715 if we're the first paragraph in a (sub*)section. \noindent cannot
716 counter this due to when latex enforces first paragraph stuff. Since
717 it's tedious to figure out when we're in the first paragraph and when
718 not, we just do \noindent\hspace{1em} everywhere.
719 -->
720 <xsl:template match="sbr">
721 <xsl:if test="not(ancestor::cmdsynopsis)">
722 <xsl:message terminate="yes">sbr only supported inside cmdsynopsis (because of hangindent)</xsl:message>
723 </xsl:if>
724 <xsl:text>\linebreak</xsl:text>
725 </xsl:template>
726
727 <xsl:template match="refentry|refnamediv|refentryinfo|refmeta|refsect3|refsect4|refsect5|synopfragment|synopfragmentref|cmdsynopsis/info">
728 <xsl:message terminate="yes"><xsl:value-of select="name()"/> is not supported</xsl:message>
729 </xsl:template>
730
731 <xsl:template match="cmdsynopsis">
732 <xsl:if test="preceding-sibling::cmdsynopsis">
733 <xsl:text>\par%cmdsynopsis</xsl:text>
734 </xsl:if>
735 <xsl:text>&#x0a;</xsl:text>
736 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
737 <!-- Overview fontsize trick -->
738 <xsl:text>{\footnotesize</xsl:text>
739 </xsl:if>
740 <xsl:text>\noindent\hspace{1em}</xsl:text>
741 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
742 <xsl:apply-templates />
743 <xsl:text>}</xsl:text>
744 <xsl:if test="following-sibling::*">
745 </xsl:if>
746
747 <!-- For refsect2 subcommand descriptions. -->
748 <xsl:if test="not(following-sibling::cmdsynopsis) and position() != last()">
749 <xsl:text>\linebreak</xsl:text>
750 </xsl:if>
751 <!-- Special overview trick for the current VBoxManage command overview. -->
752 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
753 <xsl:text>}\vspace{1em}</xsl:text>
754 </xsl:if>
755 </xsl:template>
756
757 <xsl:template match="command">
758 <xsl:choose>
759 <xsl:when test="ancestor::cmdsynopsis">
760 <!-- Trigger a line break if this isn't the first command in a the synopsis -->
761 <xsl:if test="preceding-sibling::command">
762 <xsl:text>}\par%command&#x0a;</xsl:text>
763 <xsl:text>\noindent\hspace{1em}</xsl:text>
764 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
765 </xsl:if>
766 <xsl:apply-templates />
767 </xsl:when>
768 <xsl:otherwise>
769 <xsl:text>\texttt{</xsl:text>
770 <xsl:apply-templates />
771 <xsl:text>}</xsl:text>
772 </xsl:otherwise>
773 </xsl:choose>
774 </xsl:template>
775
776 <xsl:template match="option">
777 <xsl:choose>
778 <xsl:when test="ancestor::cmdsynopsis">
779 <xsl:apply-templates />
780 </xsl:when>
781 <xsl:otherwise>
782 <xsl:text>\texttt{</xsl:text>
783 <xsl:apply-templates />
784 <xsl:text>}</xsl:text>
785 </xsl:otherwise>
786 </xsl:choose>
787 </xsl:template>
788
789 <!-- duplicated in docbook2latex.xsl -->
790 <xsl:template match="arg|group">
791 <!-- separator char if we're not the first child -->
792 <xsl:if test="position() > 1">
793 <xsl:choose>
794 <xsl:when test="parent::group"><xsl:value-of select="$arg.or.sep"/></xsl:when>
795 <xsl:when test="ancestor-or-self::*/@sepchar"><xsl:value-of select="ancestor-or-self::*/@sepchar"/></xsl:when>
796 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
797 </xsl:choose>
798 </xsl:if>
799 <!-- open wrapping -->
800 <xsl:choose>
801 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.open.str"/></xsl:when>
802 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/></xsl:when>
803 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.open.str"/></xsl:when>
804 <xsl:when test="@choice = 'plain'"/>
805 <xsl:otherwise><xsl:message terminate="yes">Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise>
806 </xsl:choose>
807
808 <!-- render the arg (TODO: may need to do more work here) -->
809 <xsl:apply-templates />
810
811 <!-- repeat wrapping -->
812 <xsl:choose>
813 <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/>
814 <xsl:when test="@rep = 'repeat'"> <xsl:value-of select="$arg.rep.repeat.str"/></xsl:when>
815 <xsl:otherwise><xsl:message terminate="yes">Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise>
816 </xsl:choose>
817 <!-- close wrapping -->
818 <xsl:choose>
819 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.close.str"/></xsl:when>
820 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.close.str"/></xsl:when>
821 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.close.str"/></xsl:when>
822 </xsl:choose>
823 </xsl:template>
824
825 <xsl:template match="replaceable">
826 <xsl:choose>
827 <xsl:when test="not(ancestor::cmdsynopsis) or ancestor::arg">
828 <xsl:text>\texttt{\textit{</xsl:text>
829 <xsl:apply-templates />
830 <xsl:text>}}</xsl:text>
831 </xsl:when>
832 <xsl:otherwise>
833 <xsl:text>\textit{&lt;</xsl:text>
834 <xsl:apply-templates />
835 <xsl:text>&gt;}</xsl:text>
836 </xsl:otherwise>
837 </xsl:choose>
838 </xsl:template>
839
840
841 <!--
842 Generic element text magic.
843 -->
844 <xsl:template match="//text()">
845
846 <xsl:variable name="subst1">
847 <xsl:call-template name="str:subst">
848 <xsl:with-param name="text" select="." />
849 <xsl:with-param name="replace" select="'\'" />
850 <xsl:with-param name="with" select="'\textbackslash{}'" />
851 <xsl:with-param name="disable-output-escaping" select="no" />
852 </xsl:call-template>
853 </xsl:variable>
854
855 <xsl:choose>
856 <xsl:when test="(name(..)='screen') or (name(../..)='screen')">
857 <xsl:value-of select="." />
858 </xsl:when>
859
860 <xsl:when test="(name(..) = 'computeroutput') or (name(../..) = 'computeroutput')
861 or (name(..) = 'code') or (name(../..) = 'code')
862 or (name(..) = 'arg') or (name(../..) = 'arg')
863 or (name(..) = 'option') or (name(../..) = 'option')
864 or (name(..) = 'command') or (name(../..) = 'command')
865 or (name(..) = 'cmdsynopsis') or (name(../..) = 'cmdsynopsis')
866 or (name(..) = 'replaceable') or (name(../..) = 'replaceable')
867 ">
868 <xsl:variable name="subst2">
869 <xsl:call-template name="str:subst">
870 <xsl:with-param name="text" select="$subst1" />
871 <xsl:with-param name="replace" select="'--'" />
872 <xsl:with-param name="with" select="'-{}-'" />
873 <xsl:with-param name="disable-output-escaping" select="no" />
874 </xsl:call-template>
875 </xsl:variable>
876 <xsl:variable name="subst3">
877 <xsl:call-template name="str:subst">
878 <xsl:with-param name="text" select="$subst2" />
879 <xsl:with-param name="replace" select="'_'" />
880 <xsl:with-param name="with" select="'\_'" />
881 <xsl:with-param name="disable-output-escaping" select="no" />
882 </xsl:call-template>
883 </xsl:variable>
884 <xsl:variable name="subst4">
885 <xsl:call-template name="str:subst">
886 <xsl:with-param name="text" select="$subst3" />
887 <xsl:with-param name="replace" select="'$'" />
888 <xsl:with-param name="with" select="'\$'" />
889 <xsl:with-param name="disable-output-escaping" select="no" />
890 </xsl:call-template>
891 </xsl:variable>
892 <xsl:variable name="subst5">
893 <xsl:call-template name="str:subst">
894 <xsl:with-param name="text" select="$subst4" />
895 <xsl:with-param name="replace" select="'%'" />
896 <xsl:with-param name="with" select="'\%'" />
897 <xsl:with-param name="disable-output-escaping" select="no" />
898 </xsl:call-template>
899 </xsl:variable>
900 <xsl:variable name="subst6">
901 <xsl:call-template name="str:subst">
902 <xsl:with-param name="text" select="$subst5" />
903 <xsl:with-param name="replace" select="'#'" />
904 <xsl:with-param name="with" select="'\#'" />
905 <xsl:with-param name="disable-output-escaping" select="no" />
906 </xsl:call-template>
907 </xsl:variable>
908 <xsl:variable name="subst7">
909 <xsl:call-template name="str:subst">
910 <xsl:with-param name="text" select="$subst6" />
911 <xsl:with-param name="replace" select="'~'" />
912 <xsl:with-param name="with" select="'\textasciitilde '" />
913 <xsl:with-param name="disable-output-escaping" select="no" />
914 </xsl:call-template>
915 </xsl:variable>
916 <xsl:variable name="subst8">
917 <xsl:call-template name="str:subst">
918 <xsl:with-param name="text" select="$subst7" />
919 <xsl:with-param name="replace" select="'&amp;'" />
920 <xsl:with-param name="with" select="'\&amp;'" />
921 <xsl:with-param name="disable-output-escaping" select="no" />
922 </xsl:call-template>
923 </xsl:variable>
924 <xsl:choose>
925 <xsl:when test="parent::arg or parent::command">
926 <xsl:variable name="subst9">
927 <xsl:call-template name="str:subst">
928 <xsl:with-param name="text" select="$subst8" />
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:value-of select="$subst9" />
935 </xsl:when>
936 <xsl:otherwise>
937 <xsl:value-of select="$subst8" />
938 </xsl:otherwise>
939 </xsl:choose>
940 </xsl:when>
941
942 <xsl:when test="(name(..)='address') or (name(../..)='address')">
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="'&#x0a;'" />
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:value-of select="$subst2" />
952 </xsl:when>
953
954 <xsl:otherwise>
955 <xsl:variable name="subst2">
956 <xsl:call-template name="str:subst">
957 <xsl:with-param name="text" select="$subst1" />
958 <xsl:with-param name="replace" select="'_'" />
959 <xsl:with-param name="with" select="'\_'" />
960 <xsl:with-param name="disable-output-escaping" select="no" />
961 </xsl:call-template>
962 </xsl:variable>
963 <xsl:variable name="subst3">
964 <xsl:call-template name="str:subst">
965 <xsl:with-param name="text" select="$subst2" />
966 <xsl:with-param name="replace" select="'$'" />
967 <xsl:with-param name="with" select="'\$'" />
968 <xsl:with-param name="disable-output-escaping" select="no" />
969 </xsl:call-template>
970 </xsl:variable>
971 <xsl:variable name="subst4">
972 <xsl:call-template name="str:subst">
973 <xsl:with-param name="text" select="$subst3" />
974 <xsl:with-param name="replace" select="'%'" />
975 <xsl:with-param name="with" select="'\%'" />
976 <xsl:with-param name="disable-output-escaping" select="no" />
977 </xsl:call-template>
978 </xsl:variable>
979 <xsl:variable name="subst5">
980 <xsl:call-template name="str:subst">
981 <xsl:with-param name="text" select="$subst4" />
982 <xsl:with-param name="replace" select="'#'" />
983 <xsl:with-param name="with" select="'\#'" />
984 <xsl:with-param name="disable-output-escaping" select="no" />
985 </xsl:call-template>
986 </xsl:variable>
987 <xsl:variable name="subst6">
988 <xsl:call-template name="str:subst">
989 <xsl:with-param name="text" select="$subst5" />
990 <xsl:with-param name="replace" select="'µ'" />
991 <xsl:with-param name="with" select="'$\mu$'" />
992 <xsl:with-param name="disable-output-escaping" select="no" />
993 </xsl:call-template>
994 </xsl:variable>
995 <xsl:variable name="subst7">
996 <xsl:call-template name="str:subst">
997 <xsl:with-param name="text" select="$subst6" />
998 <xsl:with-param name="replace" select="'®'" />
999 <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
1000 <xsl:with-param name="disable-output-escaping" select="no" />
1001 </xsl:call-template>
1002 </xsl:variable>
1003 <xsl:variable name="quote">"</xsl:variable>
1004 <!-- preparation for pretty quotes: replace all double quotes _outside_ screen
1005 sections with "\QUOTE{}" strings, which the makefile will then replace
1006 with pretty quotes by invoking sed a few times. Unfortunately there are
1007 no regular expressions in XSLT so there's no other way. -->
1008 <xsl:variable name="subst8">
1009 <xsl:call-template name="str:subst">
1010 <xsl:with-param name="text" select="$subst7" />
1011 <xsl:with-param name="replace" select="$quote" />
1012 <xsl:with-param name="with" select="'\QUOTE{}'" />
1013 <xsl:with-param name="disable-output-escaping" select="no" />
1014 </xsl:call-template>
1015 </xsl:variable>
1016 <xsl:variable name="subst9">
1017 <xsl:call-template name="str:subst">
1018 <xsl:with-param name="text" select="$subst8" />
1019 <xsl:with-param name="replace" select="'~'" />
1020 <xsl:with-param name="with" select="'\textasciitilde '" />
1021 <xsl:with-param name="disable-output-escaping" select="no" />
1022 </xsl:call-template>
1023 </xsl:variable>
1024 <xsl:variable name="subst10">
1025 <xsl:call-template name="str:subst">
1026 <xsl:with-param name="text" select="$subst9" />
1027 <xsl:with-param name="replace" select="'&amp;'" />
1028 <xsl:with-param name="with" select="'\&amp;'" />
1029 <xsl:with-param name="disable-output-escaping" select="no" />
1030 </xsl:call-template>
1031 </xsl:variable>
1032 <xsl:value-of select="$subst10" />
1033 </xsl:otherwise>
1034 </xsl:choose>
1035 </xsl:template>
1036
1037 <!--
1038 xsltprocNewlineOutputHack - emits a single new line.
1039
1040 Hack Alert! This template helps xsltproc split up the output text elements
1041 and avoid reallocating them into the MB range. Calls to this
1042 template is made occationally while generating larger output
1043 file. It's not necessary for small stuff like header.
1044
1045 The trick we're playing on xsltproc has to do with CDATA
1046 and/or the escape setting of the xsl:text element. It forces
1047 xsltproc to allocate a new output element, thus preventing
1048 things from growing out of proportions and slowing us down.
1049
1050 This was successfully employed to reduce a 18+ seconds run to
1051 around one second (possibly less due to kmk overhead).
1052 -->
1053 <xsl:template name="xsltprocNewlineOutputHack">
1054 <xsl:text disable-output-escaping="yes"><![CDATA[
1055]]></xsl:text>
1056 </xsl:template>
1057
1058</xsl:stylesheet>
1059
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