VirtualBox

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

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

docbook2latex.xsl: Implemented sbr, marked a few more cmdsynopsis related elements as unsupported.

File size: 32.7 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="sbr">
646 <xsl:text>\linebreak</xsl:text>
647 </xsl:template>
648 <xsl:template match="refentry|refnamediv|refentryinfo|refmeta|refsect3|refsect4|refsect5|synopfragment|synopfragmentref|cmdsynopsis/info">
649 <xsl:message terminate="yes"><xsl:value-of select="name()"/> is not supported</xsl:message>
650 </xsl:template>
651
652 <xsl:template match="cmdsynopsis">
653 <xsl:text>&#x0a;\noindent\texttt{</xsl:text>
654 <xsl:apply-templates />
655 <xsl:text>}\linebreak</xsl:text>
656 </xsl:template>
657
658 <xsl:template match="replaceable">
659 <xsl:choose>
660 <xsl:when test="not(ancestor::cmdsynopsis)">
661 <xsl:text>\texttt{\textit{</xsl:text>
662 <xsl:apply-templates />
663 <xsl:text>}}</xsl:text>
664 </xsl:when>
665 <xsl:otherwise>
666 <xsl:text>\textit{</xsl:text>
667 <xsl:apply-templates />
668 <xsl:text>}</xsl:text>
669 </xsl:otherwise>
670 </xsl:choose>
671 </xsl:template>
672
673 <xsl:template match="command|option">
674 <xsl:choose>
675 <xsl:when test="not(ancestor::cmdsynopsis)">
676 <xsl:text>\texttt{</xsl:text>
677 <xsl:apply-templates />
678 <xsl:text>}</xsl:text>
679 </xsl:when>
680 <xsl:otherwise>
681 <xsl:apply-templates />
682 </xsl:otherwise>
683 </xsl:choose>
684 </xsl:template>
685
686 <xsl:template match="arg|group">
687 <!-- separator char if we're not the first child -->
688 <xsl:if test="position() > 1">
689 <xsl:choose>
690 <xsl:when test="ancestor-or-self::*/@sepchar"><xsl:value-of select="ancestor-or-self::*/@sepchar"/></xsl:when>
691 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
692 </xsl:choose>
693 </xsl:if>
694 <!-- open wrapping -->
695 <xsl:choose>
696 <xsl:when test="@choice = 'opt' or @choice = ''"> <xsl:text>[</xsl:text></xsl:when>
697 <xsl:when test="@choice = 'req'"> <xsl:text>{</xsl:text></xsl:when>
698 <xsl:when test="@choice = 'plain'"/>
699 <xsl:otherwise><xsl:message terminate="yes">Invalid arg choice</xsl:message></xsl:otherwise>
700 </xsl:choose>
701 <!-- render the arg (TODO: may need to do more work here) -->
702 <xsl:apply-templates />
703 <!-- repeat wrapping -->
704 <xsl:choose>
705 <xsl:when test="@rep = 'norepeat' or @rep = ''"/>
706 <xsl:when test="@rep = 'repeat'"> <xsl:text>...</xsl:text></xsl:when>
707 <xsl:otherwise><xsl:message terminate="yes">Invalid rep choice</xsl:message></xsl:otherwise>
708 </xsl:choose>
709 <!-- close wrapping -->
710 <xsl:choose>
711 <xsl:when test="@choice = 'opt' or @choice = ''"> <xsl:text>]</xsl:text></xsl:when>
712 <xsl:when test="@choice = 'req'"> <xsl:text>}</xsl:text></xsl:when>
713 </xsl:choose>
714 </xsl:template>
715
716
717 <!-- Text magic. -->
718 <xsl:template match="//text()">
719 <xsl:variable name="subst1">
720 <xsl:call-template name="str:subst">
721 <xsl:with-param name="text" select="." />
722 <xsl:with-param name="replace" select="'\'" />
723 <xsl:with-param name="with" select="'\textbackslash{}'" />
724 <xsl:with-param name="disable-output-escaping" select="no" />
725 </xsl:call-template>
726 </xsl:variable>
727 <xsl:choose>
728 <xsl:when test="(name(..)='screen') or (name(../..)='screen')">
729 <xsl:value-of select="." />
730 </xsl:when>
731 <xsl:when test="(name(..) = 'computeroutput') or (name(../..) = 'computeroutput')
732 or (name(..) = 'code') or (name(../..) = 'code')
733 or (name(..) = 'arg') or (name(../..) = 'arg')
734 or (name(..) = 'option') or (name(../..) = 'option')
735 or (name(..) = 'command') or (name(../..) = 'command')
736 or (name(..) = 'cmdsynopsis') or (name(../..) = 'cmdsynopsis')
737 or (name(..) = 'replaceable') or (name(../..) = 'replaceable')
738 ">
739 <xsl:variable name="subst2">
740 <xsl:call-template name="str:subst">
741 <xsl:with-param name="text" select="$subst1" />
742 <xsl:with-param name="replace" select="'--'" />
743 <xsl:with-param name="with" select="'-{}-'" />
744 <xsl:with-param name="disable-output-escaping" select="no" />
745 </xsl:call-template>
746 </xsl:variable>
747 <xsl:variable name="subst3">
748 <xsl:call-template name="str:subst">
749 <xsl:with-param name="text" select="$subst2" />
750 <xsl:with-param name="replace" select="'_'" />
751 <xsl:with-param name="with" select="'\_'" />
752 <xsl:with-param name="disable-output-escaping" select="no" />
753 </xsl:call-template>
754 </xsl:variable>
755 <xsl:variable name="subst4">
756 <xsl:call-template name="str:subst">
757 <xsl:with-param name="text" select="$subst3" />
758 <xsl:with-param name="replace" select="'$'" />
759 <xsl:with-param name="with" select="'\$'" />
760 <xsl:with-param name="disable-output-escaping" select="no" />
761 </xsl:call-template>
762 </xsl:variable>
763 <xsl:variable name="subst5">
764 <xsl:call-template name="str:subst">
765 <xsl:with-param name="text" select="$subst4" />
766 <xsl:with-param name="replace" select="'%'" />
767 <xsl:with-param name="with" select="'\%'" />
768 <xsl:with-param name="disable-output-escaping" select="no" />
769 </xsl:call-template>
770 </xsl:variable>
771 <xsl:variable name="subst6">
772 <xsl:call-template name="str:subst">
773 <xsl:with-param name="text" select="$subst5" />
774 <xsl:with-param name="replace" select="'#'" />
775 <xsl:with-param name="with" select="'\#'" />
776 <xsl:with-param name="disable-output-escaping" select="no" />
777 </xsl:call-template>
778 </xsl:variable>
779 <xsl:variable name="subst7">
780 <xsl:call-template name="str:subst">
781 <xsl:with-param name="text" select="$subst6" />
782 <xsl:with-param name="replace" select="'~'" />
783 <xsl:with-param name="with" select="'\textasciitilde '" />
784 <xsl:with-param name="disable-output-escaping" select="no" />
785 </xsl:call-template>
786 </xsl:variable>
787 <xsl:variable name="subst8">
788 <xsl:call-template name="str:subst">
789 <xsl:with-param name="text" select="$subst7" />
790 <xsl:with-param name="replace" select="'&amp;'" />
791 <xsl:with-param name="with" select="'\&amp;'" />
792 <xsl:with-param name="disable-output-escaping" select="no" />
793 </xsl:call-template>
794 </xsl:variable>
795 <xsl:value-of select="$subst8" />
796 </xsl:when>
797 <xsl:when test="(name(..)='address') or (name(../..)='address')">
798 <xsl:variable name="subst2">
799 <xsl:call-template name="str:subst">
800 <xsl:with-param name="text" select="$subst1" />
801 <xsl:with-param name="replace" select="'&#x0a;'" />
802 <xsl:with-param name="with" select="' \\'" />
803 <xsl:with-param name="disable-output-escaping" select="no" />
804 </xsl:call-template>
805 </xsl:variable>
806 <xsl:value-of select="$subst2" />
807 </xsl:when>
808 <xsl:otherwise>
809 <xsl:variable name="subst2">
810 <xsl:call-template name="str:subst">
811 <xsl:with-param name="text" select="$subst1" />
812 <xsl:with-param name="replace" select="'_'" />
813 <xsl:with-param name="with" select="'\_'" />
814 <xsl:with-param name="disable-output-escaping" select="no" />
815 </xsl:call-template>
816 </xsl:variable>
817 <xsl:variable name="subst3">
818 <xsl:call-template name="str:subst">
819 <xsl:with-param name="text" select="$subst2" />
820 <xsl:with-param name="replace" select="'$'" />
821 <xsl:with-param name="with" select="'\$'" />
822 <xsl:with-param name="disable-output-escaping" select="no" />
823 </xsl:call-template>
824 </xsl:variable>
825 <xsl:variable name="subst4">
826 <xsl:call-template name="str:subst">
827 <xsl:with-param name="text" select="$subst3" />
828 <xsl:with-param name="replace" select="'%'" />
829 <xsl:with-param name="with" select="'\%'" />
830 <xsl:with-param name="disable-output-escaping" select="no" />
831 </xsl:call-template>
832 </xsl:variable>
833 <xsl:variable name="subst5">
834 <xsl:call-template name="str:subst">
835 <xsl:with-param name="text" select="$subst4" />
836 <xsl:with-param name="replace" select="'#'" />
837 <xsl:with-param name="with" select="'\#'" />
838 <xsl:with-param name="disable-output-escaping" select="no" />
839 </xsl:call-template>
840 </xsl:variable>
841 <xsl:variable name="subst6">
842 <xsl:call-template name="str:subst">
843 <xsl:with-param name="text" select="$subst5" />
844 <xsl:with-param name="replace" select="'µ'" />
845 <xsl:with-param name="with" select="'$\mu$'" />
846 <xsl:with-param name="disable-output-escaping" select="no" />
847 </xsl:call-template>
848 </xsl:variable>
849 <xsl:variable name="subst7">
850 <xsl:call-template name="str:subst">
851 <xsl:with-param name="text" select="$subst6" />
852 <xsl:with-param name="replace" select="'®'" />
853 <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
854 <xsl:with-param name="disable-output-escaping" select="no" />
855 </xsl:call-template>
856 </xsl:variable>
857 <xsl:variable name="quote">"</xsl:variable>
858 <!-- preparation for pretty quotes: replace all double quotes _outside_ screen
859 sections with "\QUOTE{}" strings, which the makefile will then replace
860 with pretty quotes by invoking sed a few times. Unfortunately there are
861 no regular expressions in XSLT so there's no other way. -->
862 <xsl:variable name="subst8">
863 <xsl:call-template name="str:subst">
864 <xsl:with-param name="text" select="$subst7" />
865 <xsl:with-param name="replace" select="$quote" />
866 <xsl:with-param name="with" select="'\QUOTE{}'" />
867 <xsl:with-param name="disable-output-escaping" select="no" />
868 </xsl:call-template>
869 </xsl:variable>
870 <xsl:variable name="subst9">
871 <xsl:call-template name="str:subst">
872 <xsl:with-param name="text" select="$subst8" />
873 <xsl:with-param name="replace" select="'~'" />
874 <xsl:with-param name="with" select="'\textasciitilde '" />
875 <xsl:with-param name="disable-output-escaping" select="no" />
876 </xsl:call-template>
877 </xsl:variable>
878 <xsl:variable name="subst10">
879 <xsl:call-template name="str:subst">
880 <xsl:with-param name="text" select="$subst9" />
881 <xsl:with-param name="replace" select="'&amp;'" />
882 <xsl:with-param name="with" select="'\&amp;'" />
883 <xsl:with-param name="disable-output-escaping" select="no" />
884 </xsl:call-template>
885 </xsl:variable>
886 <xsl:value-of select="$subst10" />
887 </xsl:otherwise>
888 </xsl:choose>
889 </xsl:template>
890
891 <!--
892 xsltprocNewlineOutputHack - emits a single new line.
893
894 Hack Alert! This template helps xsltproc split up the output text elements
895 and avoid reallocating them into the MB range. Calls to this
896 template is made occationally while generating larger output
897 file. It's not necessary for small stuff like header.
898
899 The trick we're playing on xsltproc has to do with CDATA
900 and/or the escape setting of the xsl:text element. It forces
901 xsltproc to allocate a new output element, thus preventing
902 things from growing out of proportions and slowing us down.
903
904 This was successfully employed to reduce a 18+ seconds run to
905 around one second (possibly less due to kmk overhead).
906 -->
907 <xsl:template name="xsltprocNewlineOutputHack">
908 <xsl:text disable-output-escaping="yes"><![CDATA[
909]]></xsl:text>
910 </xsl:template>
911
912</xsl:stylesheet>
913
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