VirtualBox

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

Last change on this file since 56172 was 56172, checked in by vboxsync, 10 years ago

refsect2 adjustment

File size: 32.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
41 <xsl:variable name="g_nlsChapter">
42 <xsl:choose>
43 <xsl:when test="$TARGETLANG='de_DE'">Kapitel</xsl:when>
44 <xsl:when test="$TARGETLANG='fr_FR'">chapitre</xsl:when>
45 <xsl:when test="$TARGETLANG='en_US'">chapter</xsl:when>
46 <xsl:otherwise>
47 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
48 </xsl:otherwise>
49 </xsl:choose>
50 </xsl:variable>
51
52 <xsl:variable name="g_nlsPage">
53 <xsl:choose>
54 <xsl:when test="$TARGETLANG='de_DE'">auf Seite</xsl:when>
55 <xsl:when test="$TARGETLANG='fr_FR'">page</xsl:when>
56 <xsl:when test="$TARGETLANG='en_US'">page</xsl:when>
57 <xsl:otherwise>
58 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
62
63 <xsl:variable name="g_nlsNote">
64 <xsl:choose>
65 <xsl:when test="$TARGETLANG='de_DE'">Hinweis</xsl:when>
66 <xsl:when test="$TARGETLANG='fr_FR'">Note</xsl:when>
67 <xsl:when test="$TARGETLANG='en_US'">Note</xsl:when>
68 <xsl:otherwise>
69 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
70 </xsl:otherwise>
71 </xsl:choose>
72 </xsl:variable>
73
74 <xsl:variable name="g_nlsWarning">
75 <xsl:choose>
76 <xsl:when test="$TARGETLANG='de_DE'">Warnung</xsl:when>
77 <xsl:when test="$TARGETLANG='fr_FR'">Avertissement</xsl:when>
78 <xsl:when test="$TARGETLANG='en_US'">Warning</xsl:when>
79 <xsl:otherwise>
80 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
81 </xsl:otherwise>
82 </xsl:choose>
83 </xsl:variable>
84
85 <xsl:output method="text"/>
86
87 <xsl:strip-space elements="*"/>
88 <xsl:preserve-space elements="para"/>
89
90 <xsl:template match="/book">
91 <xsl:text>
92\documentclass[oneside,a4paper,10pt,DIV10]{scrbook}
93\usepackage{geometry}
94\geometry{top=3cm,bottom=4cm}
95\usepackage{ucs}
96\usepackage[utf8x]{inputenc}
97\usepackage[T1]{fontenc}
98\usepackage{tabulary}
99\usepackage[pdftex,
100 a4paper,
101 colorlinks=true,
102 linkcolor=blue,
103 urlcolor=darkgreen,
104 bookmarksnumbered,
105 bookmarksopen=true,
106 bookmarksopenlevel=0,
107 hyperfootnotes=false,
108 plainpages=false,
109 pdfpagelabels
110 ]{hyperref}
111
112\usepackage{nameref}
113\usepackage{graphicx}
114\usepackage{fancybox}
115\usepackage{fancyvrb}
116\usepackage{alltt}
117\usepackage{color}
118\usepackage{scrextend}
119\definecolor{darkgreen}{rgb}{0,0.6,0}
120
121</xsl:text>
122 <xsl:if test="$TARGETLANG='de_DE'">\usepackage[ngerman]{babel}&#10;\PrerenderUnicode{ü}</xsl:if>
123<!-- <xsl:if test="$TARGETLANG='fr_FR'">\usepackage[french]{babel}&#10;\FrenchItemizeSpacingfalse&#10;\renewcommand{\FrenchLabelItem}{\textbullet}</xsl:if>
124 this command is no longer understood by TexLive2008
125 -->
126 <xsl:text>
127
128% use Palatino as serif font:
129% \usepackage{mathpazo}
130\usepackage{charter}
131% use Helvetica as sans-serif font:
132\usepackage{helvet}
133
134% use Bera Mono (a variant of Bitstream Vera Mono) as typewriter font
135% (requires texlive-fontsextra)
136\usepackage[scaled]{beramono}
137% previously: use Courier as typewriter font:
138% \usepackage{courier}
139
140\definecolor{colNote}{rgb}{0,0,0}
141\definecolor{colWarning}{rgb}{0,0,0}
142\definecolor{colScreenFrame}{rgb}{0,0,0}
143\definecolor{colScreenText}{rgb}{0,0,0}
144
145% number headings down to this level
146\setcounter{secnumdepth}{3}
147% more space for the section numbers
148\makeatletter
149\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.9em}}
150\renewcommand*\l@subsection{\@dottedtocline{2}{4.4em}{3.8em}}
151\renewcommand*\l@subsubsection{\@dottedtocline{3}{8.2em}{3.8em}}
152\renewcommand*\@pnumwidth{1.7em}
153\renewcommand*\@tocrmarg{5.0em}
154\makeatother
155
156% more tolerance at 2nd wrap stage:
157\tolerance = 1000
158% allow 3rd wrap stage:
159\emergencystretch = 10pt
160% no Schusterjungen:
161\clubpenalty = 10000
162% no Hurenkinder:
163\widowpenalty = 10000
164\displaywidowpenalty = 10000
165% max pdf compression:
166\pdfcompresslevel9
167
168% opening and closing quotes: the OQ and CQ macros define this (and the makefile employs some sed magic also)
169</xsl:text>
170 <xsl:choose>
171 <xsl:when test="$TARGETLANG='de_DE'">
172 <xsl:text>\newcommand\OQ{\texorpdfstring{\glqq}{"}}&#10;\newcommand\CQ{\texorpdfstring{\grqq}{"}}&#10;</xsl:text>
173 </xsl:when>
174 <xsl:when test="$TARGETLANG='fr_FR'">
175 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
176 </xsl:when>
177 <xsl:when test="$TARGETLANG='en_US'">
178 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
179 </xsl:when>
180 <xsl:otherwise>
181 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
182 </xsl:otherwise>
183 </xsl:choose>
184
185 <xsl:apply-templates />
186
187 <xsl:text>
188\end{document}
189 </xsl:text>
190
191 </xsl:template>
192
193 <xsl:template match="bookinfo">
194 <xsl:apply-templates />
195 <xsl:text>&#x0a;\newcommand\docbookbookinfocopyright{\copyright{} \docbookbookinfocopyrightyear{} \docbookbookinfocopyrightholder{}}&#x0a;
196\author{ \docbooktitleedition \\ %
197\\ %
198</xsl:text>
199 <xsl:if test="//bookinfo/address">
200 <xsl:text>\docbookbookinfoaddress \\ %
201\\ %
202</xsl:text>
203 </xsl:if>
204 <xsl:text>\docbookbookinfocopyright \\ %
205}
206
207\title{\docbooktitle \\
208\docbooksubtitle}
209% \subtitle{\docbooksubtitle}
210\hypersetup{pdfauthor=\docbookcorpauthor}
211\hypersetup{pdftitle=\docbooktitle{} \docbooksubtitle{}}
212
213\hyphenation{da-ta-ba-ses}
214\hyphenation{deb-conf}
215\hyphenation{VirtualBox}
216
217\begin{document}
218% \maketitle
219%\begin{titlepage}
220\thispagestyle{empty}
221\begin{minipage}{\textwidth}
222\begin{center}
223\includegraphics[width=4cm]{images/vboxlogo.png}
224\end{center}%
225\vspace{10mm}
226
227{\fontsize{40pt}{40pt}\selectfont\rmfamily\bfseries%
228\begin{center}
229\docbooktitle
230\end{center}%
231\vspace{10mm}
232}
233
234{\fontsize{30pt}{30pt}\selectfont\rmfamily\bfseries%
235\begin{center}
236\docbooksubtitle
237\end{center}%
238\vspace{10mm}
239}
240
241{\fontsize{16pt}{20pt}\selectfont\rmfamily%
242\begin{center}
243</xsl:text>
244 <xsl:if test="//bookinfo/othercredit">
245 <xsl:text>\docbookbookinfoothercreditcontrib{}: \docbookbookinfoothercreditfirstname{} \docbookbookinfoothercreditsurname
246
247\vspace{8mm}
248</xsl:text>
249 </xsl:if>
250 <xsl:text>\docbooktitleedition
251
252\vspace{2mm}
253
254\docbookbookinfocopyright
255
256\vspace{2mm}
257
258\docbookbookinfoaddress
259\end{center}%
260}
261
262%\end{titlepage}
263\end{minipage}
264
265\tableofcontents
266 </xsl:text>
267 </xsl:template>
268
269 <xsl:template match="subtitle">
270 <xsl:choose>
271 <xsl:when test="name(..)='bookinfo'">
272 <xsl:text>\newcommand\docbooksubtitle{</xsl:text>
273 <xsl:apply-templates />
274 <xsl:text>}</xsl:text>
275 </xsl:when>
276 </xsl:choose>
277 </xsl:template>
278
279 <xsl:template match="title">
280 <xsl:choose>
281 <xsl:when test="name(..)='bookinfo'">
282 <xsl:text>\newcommand\docbooktitle{</xsl:text>
283 <xsl:apply-templates />
284 <xsl:text>}</xsl:text>
285 </xsl:when>
286 <xsl:when test="name(..)='chapter'">
287 <xsl:call-template name="xsltprocNewlineOutputHack"/>
288 <xsl:text>&#x0a;\chapter{</xsl:text>
289 <xsl:apply-templates />
290 <xsl:text>}</xsl:text>
291 </xsl:when>
292 <xsl:when test="name(..)='sect1'">
293 <xsl:call-template name="xsltprocNewlineOutputHack"/>
294 <xsl:text>&#x0a;\section{</xsl:text>
295 <xsl:apply-templates />
296 <xsl:text>}</xsl:text>
297 </xsl:when>
298 <xsl:when test="name(..)='sect2'">
299 <xsl:call-template name="xsltprocNewlineOutputHack"/>
300 <xsl:text>&#x0a;\subsection{</xsl:text>
301 <xsl:apply-templates />
302 <xsl:text>}</xsl:text>
303 </xsl:when>
304 <xsl:when test="name(..)='sect3'">
305 <xsl:call-template name="xsltprocNewlineOutputHack"/>
306 <xsl:text>&#x0a;\subsubsection{</xsl:text>
307 <xsl:apply-templates />
308 <xsl:text>}</xsl:text>
309 </xsl:when>
310 <xsl:when test="name(..)='sect4'">
311 <xsl:call-template name="xsltprocNewlineOutputHack"/>
312 <xsl:text>&#x0a;\paragraph{</xsl:text>
313 <xsl:apply-templates />
314 <xsl:text>}</xsl:text>
315 </xsl:when>
316 <xsl:when test="name(..)='sect5'">
317 <xsl:call-template name="xsltprocNewlineOutputHack"/>
318 <xsl:text>&#x0a;\subparagraph{</xsl:text>
319 <xsl:apply-templates />
320 <xsl:text>}</xsl:text>
321 </xsl:when>
322 <xsl:when test="name(..)='refsect1'">
323 <xsl:call-template name="xsltprocNewlineOutputHack"/>
324 <xsl:text>&#x0a;\paragraph{</xsl:text>
325 <xsl:apply-templates />
326 <xsl:text>}&#x0a;\begin{addmargin}{1em}&#x0a;</xsl:text>
327 </xsl:when>
328 <xsl:when test="name(..)='refsect2'">
329 <xsl:call-template name="xsltprocNewlineOutputHack"/>
330 <xsl:text>&#x0a;\subparagraph{</xsl:text>
331 <xsl:apply-templates />
332 <xsl:text>}</xsl:text>
333 </xsl:when>
334 <xsl:when test="name(..)='appendix'">
335 <xsl:call-template name="xsltprocNewlineOutputHack"/>
336 <xsl:text>&#x0a;\chapter{</xsl:text>
337 <xsl:apply-templates />
338 <xsl:text>}</xsl:text>
339 </xsl:when>
340 <xsl:when test="name(..)='glossdiv'">
341 <xsl:call-template name="xsltprocNewlineOutputHack"/>
342 <xsl:text>&#x0a;\section*{</xsl:text>
343 <xsl:apply-templates />
344 <xsl:text>}</xsl:text>
345 </xsl:when>
346 </xsl:choose>
347 <xsl:variable name="refid" select="../@id" />
348 <xsl:if test="$refid">
349 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
350 </xsl:if>
351 <xsl:text>&#x0a;</xsl:text>
352 </xsl:template>
353
354 <xsl:template match="refsect1">
355 <xsl:if test="not(title)"><xsl:message terminate="yes">Expected title element in refsect1.</xsl:message></xsl:if>
356 <xsl:apply-templates/>
357 <xsl:text>&#x0a;\end{addmargin}&#x0a;</xsl:text>
358 </xsl:template>
359
360 <xsl:template match="refsect2">
361 <xsl:if test="(name(*[1]) != 'title' and name(*[1]) != 'cmdsynopsis') or not(title) = not(cmdsynopsis)">
362 <xsl:message terminate="yes">Expected title or cmdsynopsis element as the first child of refsect2.</xsl:message>
363 </xsl:if>
364 <xsl:call-template name="xsltprocNewlineOutputHack"/>
365 <xsl:if test="cmdsynopsis">
366 <xsl:text>\vspace{1.2em}&#x0a;</xsl:text>
367 </xsl:if>
368 <xsl:text>\noindent</xsl:text>
369 <xsl:apply-templates/>
370 <xsl:text>&#x0a;</xsl:text>
371 </xsl:template>
372
373 <xsl:template match="edition">
374 <xsl:choose>
375 <xsl:when test="name(..)='bookinfo'">
376 <xsl:text>\newcommand\docbooktitleedition{</xsl:text>
377 <xsl:apply-templates />
378 <xsl:text>}&#x0a;</xsl:text>
379 </xsl:when>
380 </xsl:choose>
381 </xsl:template>
382
383 <xsl:template match="corpauthor">
384 <xsl:choose>
385 <xsl:when test="name(..)='bookinfo'">
386 <xsl:text>\newcommand\docbookcorpauthor{</xsl:text>
387 <xsl:apply-templates />
388 <xsl:text>}&#x0a;</xsl:text>
389 </xsl:when>
390 </xsl:choose>
391 </xsl:template>
392
393 <xsl:template match="address">
394 <xsl:choose>
395 <xsl:when test="name(..)='bookinfo'">
396 <xsl:text>\newcommand\docbookbookinfoaddress{</xsl:text>
397 <xsl:apply-templates />
398 <xsl:text>}&#x0a;</xsl:text>
399 </xsl:when>
400 </xsl:choose>
401 </xsl:template>
402
403 <xsl:template match="year">
404 <xsl:choose>
405 <xsl:when test="name(..)='copyright'">
406 <xsl:text>\newcommand\docbookbookinfocopyrightyear{</xsl:text>
407 <xsl:apply-templates />
408 <xsl:text>}&#x0a;</xsl:text>
409 </xsl:when>
410 </xsl:choose>
411 </xsl:template>
412
413 <xsl:template match="holder">
414 <xsl:choose>
415 <xsl:when test="name(..)='copyright'">
416 <xsl:text>\newcommand\docbookbookinfocopyrightholder{</xsl:text>
417 <xsl:apply-templates />
418 <xsl:text>}&#x0a;</xsl:text>
419 </xsl:when>
420 </xsl:choose>
421 </xsl:template>
422
423 <xsl:template match="firstname">
424 <xsl:choose>
425 <xsl:when test="name(..)='othercredit'">
426 <xsl:text>\newcommand\docbookbookinfoothercreditfirstname{</xsl:text>
427 <xsl:apply-templates />
428 <xsl:text>}&#x0a;</xsl:text>
429 </xsl:when>
430 </xsl:choose>
431 </xsl:template>
432
433 <xsl:template match="surname">
434 <xsl:choose>
435 <xsl:when test="name(..)='othercredit'">
436 <xsl:text>\newcommand\docbookbookinfoothercreditsurname{</xsl:text>
437 <xsl:apply-templates />
438 <xsl:text>}&#x0a;</xsl:text>
439 </xsl:when>
440 </xsl:choose>
441 </xsl:template>
442
443 <xsl:template match="contrib">
444 <xsl:choose>
445 <xsl:when test="name(..)='othercredit'">
446 <xsl:text>\newcommand\docbookbookinfoothercreditcontrib{</xsl:text>
447 <xsl:apply-templates />
448 <xsl:text>}&#x0a;</xsl:text>
449 </xsl:when>
450 </xsl:choose>
451 </xsl:template>
452
453 <xsl:template match="glossary">
454 <xsl:text>&#x0a;&#x0a;\backmatter&#x0a;\chapter{Glossary}&#x0a;</xsl:text>
455 <xsl:apply-templates />
456 </xsl:template>
457
458 <xsl:template match="para">
459 <xsl:if test="not(name(..)='footnote' or name(..)='note' or name(..)='warning' or (name(../..)='varlistentry' and position()=1))">
460 <xsl:text>&#x0a;&#x0a;</xsl:text>
461 </xsl:if>
462 <xsl:apply-templates />
463 </xsl:template>
464
465 <xsl:template match="note">
466 <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, ':} ')" />
467 <xsl:apply-templates />
468 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
469 </xsl:template>
470
471 <xsl:template match="warning">
472 <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, ':} ')" />
473 <xsl:apply-templates />
474 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
475 </xsl:template>
476
477 <xsl:template match="screen">
478 <xsl:text>&#x0a;&#x0a;\begin{Verbatim}[fontsize=\footnotesize]&#x0a;</xsl:text>
479 <xsl:apply-templates />
480 <xsl:text>&#x0a;\end{Verbatim}&#x0a;</xsl:text>
481 </xsl:template>
482
483 <xsl:template match="programlisting">
484 <xsl:text>&#x0a;&#x0a;{\small\begin{alltt}&#x0a;</xsl:text>
485 <xsl:apply-templates />
486 <xsl:text>&#x0a;\end{alltt}}&#x0a;</xsl:text>
487 </xsl:template>
488
489 <xsl:template match="footnote">
490 <xsl:text>\footnote{</xsl:text>
491 <xsl:apply-templates />
492 <xsl:text>}</xsl:text>
493 </xsl:template>
494
495 <xsl:template match="tgroup">
496 <xsl:choose>
497 <xsl:when test="@style='verywide'">
498 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{1.1\textwidth}[]{|L|L|L|}&#x0a;\hline&#x0a;</xsl:text>
499 </xsl:when>
500 <xsl:otherwise>
501 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{.9\textwidth}[]{|L|L|L|}&#x0a;\hline&#x0a;</xsl:text>
502 </xsl:otherwise>
503 </xsl:choose>
504 <xsl:apply-templates />
505 <xsl:text>&#x0a;\end{tabulary}&#x0a;\end{center}}&#x0a;</xsl:text>
506 </xsl:template>
507
508 <xsl:template match="row">
509 <xsl:apply-templates />
510 <xsl:text>&#x0a;\\ \hline&#x0a;</xsl:text>
511 </xsl:template>
512
513 <xsl:template match="entry">
514 <xsl:if test="not(position()=1)">
515 <xsl:text> &amp; </xsl:text>
516 </xsl:if>
517 <xsl:apply-templates />
518 </xsl:template>
519
520 <xsl:template match="itemizedlist">
521 <xsl:call-template name="xsltprocNewlineOutputHack"/>
522 <xsl:text>&#x0a;\begin{itemize}&#x0a;</xsl:text>
523 <xsl:apply-templates />
524 <xsl:text>&#x0a;\end{itemize}&#x0a;</xsl:text>
525 </xsl:template>
526
527 <xsl:template match="orderedlist">
528 <xsl:call-template name="xsltprocNewlineOutputHack"/>
529 <xsl:text>&#x0a;\begin{enumerate}&#x0a;</xsl:text>
530 <xsl:apply-templates />
531 <xsl:text>&#x0a;\end{enumerate}&#x0a;</xsl:text>
532 </xsl:template>
533
534 <xsl:template match="variablelist">
535 <xsl:call-template name="xsltprocNewlineOutputHack"/>
536 <xsl:text>&#x0a;\begin{description}&#x0a;</xsl:text>
537 <xsl:apply-templates />
538 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
539 </xsl:template>
540
541 <xsl:template match="varlistentry">
542 <xsl:if test="not(./term) or not(./listitem) or count(*) != 2">
543 <xsl:message terminate="yes">Expected exactly one term and one listitem element in the varlistentry.</xsl:message>
544 </xsl:if>
545 <xsl:text>&#x0a;&#x0a;\item[</xsl:text>
546 <xsl:apply-templates select="term"/>
547 <xsl:text>] \hfill \\&#x0a;</xsl:text>
548 <xsl:apply-templates select="listitem/*"/>
549 </xsl:template>
550
551 <xsl:template match="listitem">
552 <xsl:text>&#x0a;&#x0a;\item </xsl:text>
553 <xsl:apply-templates />
554 <xsl:text>&#x0a;</xsl:text>
555 </xsl:template>
556
557 <xsl:template match="glossterm">
558 <xsl:variable name="refid" select="(@id)" />
559 <xsl:if test="$refid">
560 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
561 </xsl:if>
562 <xsl:text>&#x0a;&#x0a;\item[</xsl:text>
563 <xsl:apply-templates />
564 <xsl:text>]</xsl:text>
565 </xsl:template>
566
567 <xsl:template match="glosslist | glossdiv">
568 <xsl:text>&#x0a;&#x0a;\begin{description}&#x0a;</xsl:text>
569 <xsl:apply-templates />
570 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
571 </xsl:template>
572
573 <xsl:template match="superscript">
574 <xsl:variable name="contents">
575 <xsl:apply-templates />
576 </xsl:variable>
577 <xsl:value-of select="concat('\texorpdfstring{\textsuperscript{', $contents, '}}{', $contents, '}')" />
578 </xsl:template>
579
580 <xsl:template match="emphasis">
581 <xsl:choose>
582 <xsl:when test="@role='bold'">
583 <xsl:text>\textbf{</xsl:text>
584 </xsl:when>
585 <xsl:otherwise>
586 <xsl:text>\textit{</xsl:text>
587 </xsl:otherwise>
588 </xsl:choose>
589 <xsl:apply-templates />
590 <xsl:text>}</xsl:text>
591 </xsl:template>
592
593 <xsl:template match="computeroutput | code">
594 <xsl:text>\texttt{</xsl:text>
595 <xsl:apply-templates />
596 <xsl:text>}</xsl:text>
597 </xsl:template>
598
599 <xsl:template match="ulink">
600 <xsl:text>\url{</xsl:text>
601 <xsl:apply-templates />
602 <xsl:text>}</xsl:text>
603 </xsl:template>
604
605 <xsl:template match="xref">
606 <xsl:choose>
607 <xsl:when test="@xreflabel">
608 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @xreflabel, '}}')" />
609 </xsl:when>
610 <xsl:when test="@apiref='yes'">
611 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{')" />
612 <xsl:apply-templates />
613 <xsl:value-of select="'}}'" />
614 </xsl:when>
615 <xsl:otherwise>
616 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
617 </xsl:otherwise>
618 </xsl:choose>
619 </xsl:template>
620
621 <!-- for some reason, DocBook insists of having image data nested this way always:
622 mediaobject -> imageobject -> imagedata
623 but only imagedata is interesting -->
624 <xsl:template match="imagedata">
625 <xsl:if test="@align='center'">
626 <xsl:text>\begin{center}</xsl:text>
627 </xsl:if>
628 <xsl:value-of select="concat('&#x0a;\includegraphics[width=', @width, ']{', @fileref, '}&#x0a;')" />
629 <xsl:apply-templates />
630 <xsl:if test="@align='center'">
631 <xsl:text>\end{center}</xsl:text>
632 </xsl:if>
633 </xsl:template>
634
635 <!--
636 refentry releated stuff and isn't handled elsewhere...
637 -->
638 <xsl:template match="refsynopsisdiv">
639 <xsl:call-template name="xsltprocNewlineOutputHack"/>
640 <xsl:text>&#x0a;\paragraph{Synopsis} \hfill \\&#x0a;\begin{addmargin}{1em}&#x0a;</xsl:text>
641 <xsl:apply-templates />
642 <xsl:text>\end{addmargin}&#x0a;</xsl:text>
643 </xsl:template>
644
645 <xsl:template match="refentry|refnamediv|refentryinfo|refmeta|refsect3|refsect4|refsect5">
646 <xsl:message terminate="yes"><xsl:value-of select="name()"/> is not supported</xsl:message>
647 </xsl:template>
648
649 <xsl:template match="cmdsynopsis">
650 <xsl:text>&#x0a;\noindent\texttt{</xsl:text>
651 <xsl:apply-templates />
652 <xsl:text>}\linebreak</xsl:text>
653 </xsl:template>
654
655 <xsl:template match="replaceable">
656 <xsl:choose>
657 <xsl:when test="not(ancestor::cmdsynopsis)">
658 <xsl:text>\texttt{\textit{</xsl:text>
659 <xsl:apply-templates />
660 <xsl:text>}}</xsl:text>
661 </xsl:when>
662 <xsl:otherwise>
663 <xsl:text>\textit{</xsl:text>
664 <xsl:apply-templates />
665 <xsl:text>}</xsl:text>
666 </xsl:otherwise>
667 </xsl:choose>
668 </xsl:template>
669
670 <xsl:template match="command|option">
671 <xsl:choose>
672 <xsl:when test="not(ancestor::cmdsynopsis)">
673 <xsl:text>\texttt{</xsl:text>
674 <xsl:apply-templates />
675 <xsl:text>}</xsl:text>
676 </xsl:when>
677 <xsl:otherwise>
678 <xsl:apply-templates />
679 </xsl:otherwise>
680 </xsl:choose>
681 </xsl:template>
682
683 <xsl:template match="arg|group">
684 <!-- separator char if we're not the first child -->
685 <xsl:if test="position() > 1">
686 <xsl:choose>
687 <xsl:when test="ancestor-or-self::*/@sepchar"><xsl:value-of select="ancestor-or-self::*/@sepchar"/></xsl:when>
688 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
689 </xsl:choose>
690 </xsl:if>
691 <!-- open wrapping -->
692 <xsl:choose>
693 <xsl:when test="@choice = 'opt' or @choice = ''"> <xsl:text>[</xsl:text></xsl:when>
694 <xsl:when test="@choice = 'req'"> <xsl:text>{</xsl:text></xsl:when>
695 <xsl:when test="@choice = 'plain'"/>
696 <xsl:otherwise><xsl:message terminate="yes">Invalid arg choice</xsl:message></xsl:otherwise>
697 </xsl:choose>
698 <!-- render the arg (TODO: may need to do more work here) -->
699 <xsl:apply-templates />
700 <!-- repeat wrapping -->
701 <xsl:choose>
702 <xsl:when test="@rep = 'norepeat' or @rep = ''"/>
703 <xsl:when test="@rep = 'repeat'"> <xsl:text>...</xsl:text></xsl:when>
704 <xsl:otherwise><xsl:message terminate="yes">Invalid rep choice</xsl:message></xsl:otherwise>
705 </xsl:choose>
706 <!-- close wrapping -->
707 <xsl:choose>
708 <xsl:when test="@choice = 'opt' or @choice = ''"> <xsl:text>]</xsl:text></xsl:when>
709 <xsl:when test="@choice = 'req'"> <xsl:text>}</xsl:text></xsl:when>
710 </xsl:choose>
711 </xsl:template>
712
713
714 <!-- Text magic. -->
715 <xsl:template match="//text()">
716 <xsl:variable name="subst1">
717 <xsl:call-template name="str:subst">
718 <xsl:with-param name="text" select="." />
719 <xsl:with-param name="replace" select="'\'" />
720 <xsl:with-param name="with" select="'\textbackslash{}'" />
721 <xsl:with-param name="disable-output-escaping" select="no" />
722 </xsl:call-template>
723 </xsl:variable>
724 <xsl:choose>
725 <xsl:when test="(name(..)='screen') or (name(../..)='screen')">
726 <xsl:value-of select="." />
727 </xsl:when>
728 <xsl:when test="(name(..) = 'computeroutput') or (name(../..) = 'computeroutput')
729 or (name(..) = 'code') or (name(../..) = 'code')
730 or (name(..) = 'arg') or (name(../..) = 'arg')
731 or (name(..) = 'option') or (name(../..) = 'option')
732 or (name(..) = 'command') or (name(../..) = 'command')
733 or (name(..) = 'cmdsynopsis') or (name(../..) = 'cmdsynopsis')
734 or (name(..) = 'replaceable') or (name(../..) = 'replaceable')
735 ">
736 <xsl:variable name="subst2">
737 <xsl:call-template name="str:subst">
738 <xsl:with-param name="text" select="$subst1" />
739 <xsl:with-param name="replace" select="'--'" />
740 <xsl:with-param name="with" select="'-{}-'" />
741 <xsl:with-param name="disable-output-escaping" select="no" />
742 </xsl:call-template>
743 </xsl:variable>
744 <xsl:variable name="subst3">
745 <xsl:call-template name="str:subst">
746 <xsl:with-param name="text" select="$subst2" />
747 <xsl:with-param name="replace" select="'_'" />
748 <xsl:with-param name="with" select="'\_'" />
749 <xsl:with-param name="disable-output-escaping" select="no" />
750 </xsl:call-template>
751 </xsl:variable>
752 <xsl:variable name="subst4">
753 <xsl:call-template name="str:subst">
754 <xsl:with-param name="text" select="$subst3" />
755 <xsl:with-param name="replace" select="'$'" />
756 <xsl:with-param name="with" select="'\$'" />
757 <xsl:with-param name="disable-output-escaping" select="no" />
758 </xsl:call-template>
759 </xsl:variable>
760 <xsl:variable name="subst5">
761 <xsl:call-template name="str:subst">
762 <xsl:with-param name="text" select="$subst4" />
763 <xsl:with-param name="replace" select="'%'" />
764 <xsl:with-param name="with" select="'\%'" />
765 <xsl:with-param name="disable-output-escaping" select="no" />
766 </xsl:call-template>
767 </xsl:variable>
768 <xsl:variable name="subst6">
769 <xsl:call-template name="str:subst">
770 <xsl:with-param name="text" select="$subst5" />
771 <xsl:with-param name="replace" select="'#'" />
772 <xsl:with-param name="with" select="'\#'" />
773 <xsl:with-param name="disable-output-escaping" select="no" />
774 </xsl:call-template>
775 </xsl:variable>
776 <xsl:variable name="subst7">
777 <xsl:call-template name="str:subst">
778 <xsl:with-param name="text" select="$subst6" />
779 <xsl:with-param name="replace" select="'~'" />
780 <xsl:with-param name="with" select="'\textasciitilde '" />
781 <xsl:with-param name="disable-output-escaping" select="no" />
782 </xsl:call-template>
783 </xsl:variable>
784 <xsl:variable name="subst8">
785 <xsl:call-template name="str:subst">
786 <xsl:with-param name="text" select="$subst7" />
787 <xsl:with-param name="replace" select="'&amp;'" />
788 <xsl:with-param name="with" select="'\&amp;'" />
789 <xsl:with-param name="disable-output-escaping" select="no" />
790 </xsl:call-template>
791 </xsl:variable>
792 <xsl:value-of select="$subst8" />
793 </xsl:when>
794 <xsl:when test="(name(..)='address') or (name(../..)='address')">
795 <xsl:variable name="subst2">
796 <xsl:call-template name="str:subst">
797 <xsl:with-param name="text" select="$subst1" />
798 <xsl:with-param name="replace" select="'&#x0a;'" />
799 <xsl:with-param name="with" select="' \\'" />
800 <xsl:with-param name="disable-output-escaping" select="no" />
801 </xsl:call-template>
802 </xsl:variable>
803 <xsl:value-of select="$subst2" />
804 </xsl:when>
805 <xsl:otherwise>
806 <xsl:variable name="subst2">
807 <xsl:call-template name="str:subst">
808 <xsl:with-param name="text" select="$subst1" />
809 <xsl:with-param name="replace" select="'_'" />
810 <xsl:with-param name="with" select="'\_'" />
811 <xsl:with-param name="disable-output-escaping" select="no" />
812 </xsl:call-template>
813 </xsl:variable>
814 <xsl:variable name="subst3">
815 <xsl:call-template name="str:subst">
816 <xsl:with-param name="text" select="$subst2" />
817 <xsl:with-param name="replace" select="'$'" />
818 <xsl:with-param name="with" select="'\$'" />
819 <xsl:with-param name="disable-output-escaping" select="no" />
820 </xsl:call-template>
821 </xsl:variable>
822 <xsl:variable name="subst4">
823 <xsl:call-template name="str:subst">
824 <xsl:with-param name="text" select="$subst3" />
825 <xsl:with-param name="replace" select="'%'" />
826 <xsl:with-param name="with" select="'\%'" />
827 <xsl:with-param name="disable-output-escaping" select="no" />
828 </xsl:call-template>
829 </xsl:variable>
830 <xsl:variable name="subst5">
831 <xsl:call-template name="str:subst">
832 <xsl:with-param name="text" select="$subst4" />
833 <xsl:with-param name="replace" select="'#'" />
834 <xsl:with-param name="with" select="'\#'" />
835 <xsl:with-param name="disable-output-escaping" select="no" />
836 </xsl:call-template>
837 </xsl:variable>
838 <xsl:variable name="subst6">
839 <xsl:call-template name="str:subst">
840 <xsl:with-param name="text" select="$subst5" />
841 <xsl:with-param name="replace" select="'µ'" />
842 <xsl:with-param name="with" select="'$\mu$'" />
843 <xsl:with-param name="disable-output-escaping" select="no" />
844 </xsl:call-template>
845 </xsl:variable>
846 <xsl:variable name="subst7">
847 <xsl:call-template name="str:subst">
848 <xsl:with-param name="text" select="$subst6" />
849 <xsl:with-param name="replace" select="'®'" />
850 <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
851 <xsl:with-param name="disable-output-escaping" select="no" />
852 </xsl:call-template>
853 </xsl:variable>
854 <xsl:variable name="quote">"</xsl:variable>
855 <!-- preparation for pretty quotes: replace all double quotes _outside_ screen
856 sections with "\QUOTE{}" strings, which the makefile will then replace
857 with pretty quotes by invoking sed a few times. Unfortunately there are
858 no regular expressions in XSLT so there's no other way. -->
859 <xsl:variable name="subst8">
860 <xsl:call-template name="str:subst">
861 <xsl:with-param name="text" select="$subst7" />
862 <xsl:with-param name="replace" select="$quote" />
863 <xsl:with-param name="with" select="'\QUOTE{}'" />
864 <xsl:with-param name="disable-output-escaping" select="no" />
865 </xsl:call-template>
866 </xsl:variable>
867 <xsl:variable name="subst9">
868 <xsl:call-template name="str:subst">
869 <xsl:with-param name="text" select="$subst8" />
870 <xsl:with-param name="replace" select="'~'" />
871 <xsl:with-param name="with" select="'\textasciitilde '" />
872 <xsl:with-param name="disable-output-escaping" select="no" />
873 </xsl:call-template>
874 </xsl:variable>
875 <xsl:variable name="subst10">
876 <xsl:call-template name="str:subst">
877 <xsl:with-param name="text" select="$subst9" />
878 <xsl:with-param name="replace" select="'&amp;'" />
879 <xsl:with-param name="with" select="'\&amp;'" />
880 <xsl:with-param name="disable-output-escaping" select="no" />
881 </xsl:call-template>
882 </xsl:variable>
883 <xsl:value-of select="$subst10" />
884 </xsl:otherwise>
885 </xsl:choose>
886 </xsl:template>
887
888 <!--
889 xsltprocNewlineOutputHack - emits a single new line.
890
891 Hack Alert! This template helps xsltproc split up the output text elements
892 and avoid reallocating them into the MB range. Calls to this
893 template is made occationally while generating larger output
894 file. It's not necessary for small stuff like header.
895
896 The trick we're playing on xsltproc has to do with CDATA
897 and/or the escape setting of the xsl:text element. It forces
898 xsltproc to allocate a new output element, thus preventing
899 things from growing out of proportions and slowing us down.
900
901 This was successfully employed to reduce a 18+ seconds run to
902 around one second (possibly less due to kmk overhead).
903 -->
904 <xsl:template name="xsltprocNewlineOutputHack">
905 <xsl:text disable-output-escaping="yes"><![CDATA[
906]]></xsl:text>
907 </xsl:template>
908
909</xsl:stylesheet>
910
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