VirtualBox

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

Last change on this file since 54558 was 49487, checked in by vboxsync, 11 years ago

doc/manual/docbook2latex.xsl: add support for othercredit tag and the relevant sub-tags

File size: 25.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\definecolor{darkgreen}{rgb}{0,0.6,0}
119
120</xsl:text>
121 <xsl:if test="$TARGETLANG='de_DE'">\usepackage[ngerman]{babel}&#10;\PrerenderUnicode{ü}</xsl:if>
122<!-- <xsl:if test="$TARGETLANG='fr_FR'">\usepackage[french]{babel}&#10;\FrenchItemizeSpacingfalse&#10;\renewcommand{\FrenchLabelItem}{\textbullet}</xsl:if>
123 this command is no longer understood by TexLive2008
124 -->
125 <xsl:text>
126
127% use Palatino as serif font:
128% \usepackage{mathpazo}
129\usepackage{charter}
130% use Helvetica as sans-serif font:
131\usepackage{helvet}
132
133% use Bera Mono (a variant of Bitstream Vera Mono) as typewriter font
134% (requires texlive-fontsextra)
135\usepackage[scaled]{beramono}
136% previously: use Courier as typewriter font:
137% \usepackage{courier}
138
139\definecolor{colNote}{rgb}{0,0,0}
140\definecolor{colWarning}{rgb}{0,0,0}
141\definecolor{colScreenFrame}{rgb}{0,0,0}
142\definecolor{colScreenText}{rgb}{0,0,0}
143
144% number headings down to this level
145\setcounter{secnumdepth}{3}
146% more space for the section numbers
147\makeatletter
148\renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.9em}}
149\renewcommand*\l@subsection{\@dottedtocline{2}{4.4em}{3.8em}}
150\renewcommand*\l@subsubsection{\@dottedtocline{3}{8.2em}{3.8em}}
151\renewcommand*\@pnumwidth{1.7em}
152\renewcommand*\@tocrmarg{5.0em}
153\makeatother
154
155% more tolerance at 2nd wrap stage:
156\tolerance = 1000
157% allow 3rd wrap stage:
158\emergencystretch = 10pt
159% no Schusterjungen:
160\clubpenalty = 10000
161% no Hurenkinder:
162\widowpenalty = 10000
163\displaywidowpenalty = 10000
164% max pdf compression:
165\pdfcompresslevel9
166
167% opening and closing quotes: the OQ and CQ macros define this (and the makefile employs some sed magic also)
168</xsl:text>
169 <xsl:choose>
170 <xsl:when test="$TARGETLANG='de_DE'">
171 <xsl:text>\newcommand\OQ{\texorpdfstring{\glqq}{"}}&#10;\newcommand\CQ{\texorpdfstring{\grqq}{"}}&#10;</xsl:text>
172 </xsl:when>
173 <xsl:when test="$TARGETLANG='fr_FR'">
174 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
175 </xsl:when>
176 <xsl:when test="$TARGETLANG='en_US'">
177 <xsl:text>\newcommand\OQ{\texorpdfstring{``}{"}}&#10;\newcommand\CQ{\texorpdfstring{''}{"}}&#10;</xsl:text>
178 </xsl:when>
179 <xsl:otherwise>
180 <xsl:message terminate="yes"><xsl:value-of select="concat('Invalid language ', $TARGETLANG)" /></xsl:message>
181 </xsl:otherwise>
182 </xsl:choose>
183
184 <xsl:apply-templates />
185
186 <xsl:text>
187\end{document}
188 </xsl:text>
189
190 </xsl:template>
191
192 <xsl:template match="bookinfo">
193 <xsl:apply-templates />
194 <xsl:text>&#x0a;\newcommand\docbookbookinfocopyright{\copyright{} \docbookbookinfocopyrightyear{} \docbookbookinfocopyrightholder{}}&#x0a;
195\author{ \docbooktitleedition \\ %
196\\ %
197</xsl:text>
198 <xsl:if test="//bookinfo/address">
199 <xsl:text>\docbookbookinfoaddress \\ %
200\\ %
201</xsl:text>
202 </xsl:if>
203 <xsl:text>\docbookbookinfocopyright \\ %
204}
205
206\title{\docbooktitle \\
207\docbooksubtitle}
208% \subtitle{\docbooksubtitle}
209\hypersetup{pdfauthor=\docbookcorpauthor}
210\hypersetup{pdftitle=\docbooktitle{} \docbooksubtitle{}}
211
212\hyphenation{da-ta-ba-ses}
213\hyphenation{deb-conf}
214\hyphenation{VirtualBox}
215
216\begin{document}
217% \maketitle
218%\begin{titlepage}
219\thispagestyle{empty}
220\begin{minipage}{\textwidth}
221\begin{center}
222\includegraphics[width=4cm]{images/vboxlogo.png}
223\end{center}%
224\vspace{10mm}
225
226{\fontsize{40pt}{40pt}\selectfont\rmfamily\bfseries%
227\begin{center}
228\docbooktitle
229\end{center}%
230\vspace{10mm}
231}
232
233{\fontsize{30pt}{30pt}\selectfont\rmfamily\bfseries%
234\begin{center}
235\docbooksubtitle
236\end{center}%
237\vspace{10mm}
238}
239
240{\fontsize{16pt}{20pt}\selectfont\rmfamily%
241\begin{center}
242</xsl:text>
243 <xsl:if test="//bookinfo/othercredit">
244 <xsl:text>\docbookbookinfoothercreditcontrib{}: \docbookbookinfoothercreditfirstname{} \docbookbookinfoothercreditsurname
245
246\vspace{8mm}
247</xsl:text>
248 </xsl:if>
249 <xsl:text>\docbooktitleedition
250
251\vspace{2mm}
252
253\docbookbookinfocopyright
254
255\vspace{2mm}
256
257\docbookbookinfoaddress
258\end{center}%
259}
260
261%\end{titlepage}
262\end{minipage}
263
264\tableofcontents
265 </xsl:text>
266 </xsl:template>
267
268 <xsl:template match="subtitle">
269 <xsl:choose>
270 <xsl:when test="name(..)='bookinfo'">
271 <xsl:text>\newcommand\docbooksubtitle{</xsl:text>
272 <xsl:apply-templates />
273 <xsl:text>}</xsl:text>
274 </xsl:when>
275 </xsl:choose>
276 </xsl:template>
277
278 <xsl:template match="title">
279 <xsl:choose>
280 <xsl:when test="name(..)='bookinfo'">
281 <xsl:text>\newcommand\docbooktitle{</xsl:text>
282 <xsl:apply-templates />
283 <xsl:text>}</xsl:text>
284 </xsl:when>
285 <xsl:when test="name(..)='chapter'">
286 <xsl:text>&#x0a;&#x0a;\chapter{</xsl:text>
287 <xsl:apply-templates />
288 <xsl:text>}</xsl:text>
289 </xsl:when>
290 <xsl:when test="name(..)='sect1'">
291 <xsl:text>&#x0a;&#x0a;\section{</xsl:text>
292 <xsl:apply-templates />
293 <xsl:text>}</xsl:text>
294 </xsl:when>
295 <xsl:when test="name(..)='sect2'">
296 <xsl:text>&#x0a;&#x0a;\subsection{</xsl:text>
297 <xsl:apply-templates />
298 <xsl:text>}</xsl:text>
299 </xsl:when>
300 <xsl:when test="name(..)='sect3'">
301 <xsl:text>&#x0a;&#x0a;\subsubsection{</xsl:text>
302 <xsl:apply-templates />
303 <xsl:text>}</xsl:text>
304 </xsl:when>
305 <xsl:when test="name(..)='sect4'">
306 <xsl:text>&#x0a;&#x0a;\paragraph{</xsl:text>
307 <xsl:apply-templates />
308 <xsl:text>}</xsl:text>
309 </xsl:when>
310 <xsl:when test="name(..)='sect5'">
311 <xsl:text>&#x0a;&#x0a;\subparagraph{</xsl:text>
312 <xsl:apply-templates />
313 <xsl:text>}</xsl:text>
314 </xsl:when>
315 <xsl:when test="name(..)='appendix'">
316 <xsl:text>&#x0a;&#x0a;\chapter{</xsl:text>
317 <xsl:apply-templates />
318 <xsl:text>}</xsl:text>
319 </xsl:when>
320 <xsl:when test="name(..)='glossdiv'">
321 <xsl:text>&#x0a;&#x0a;\section*{</xsl:text>
322 <xsl:apply-templates />
323 <xsl:text>}</xsl:text>
324 </xsl:when>
325 </xsl:choose>
326 <xsl:variable name="refid" select="../@id" />
327 <xsl:if test="$refid">
328 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
329 </xsl:if>
330 <xsl:text>&#x0a;</xsl:text>
331 </xsl:template>
332
333 <xsl:template match="edition">
334 <xsl:choose>
335 <xsl:when test="name(..)='bookinfo'">
336 <xsl:text>\newcommand\docbooktitleedition{</xsl:text>
337 <xsl:apply-templates />
338 <xsl:text>}&#x0a;</xsl:text>
339 </xsl:when>
340 </xsl:choose>
341 </xsl:template>
342
343 <xsl:template match="corpauthor">
344 <xsl:choose>
345 <xsl:when test="name(..)='bookinfo'">
346 <xsl:text>\newcommand\docbookcorpauthor{</xsl:text>
347 <xsl:apply-templates />
348 <xsl:text>}&#x0a;</xsl:text>
349 </xsl:when>
350 </xsl:choose>
351 </xsl:template>
352
353 <xsl:template match="address">
354 <xsl:choose>
355 <xsl:when test="name(..)='bookinfo'">
356 <xsl:text>\newcommand\docbookbookinfoaddress{</xsl:text>
357 <xsl:apply-templates />
358 <xsl:text>}&#x0a;</xsl:text>
359 </xsl:when>
360 </xsl:choose>
361 </xsl:template>
362
363 <xsl:template match="year">
364 <xsl:choose>
365 <xsl:when test="name(..)='copyright'">
366 <xsl:text>\newcommand\docbookbookinfocopyrightyear{</xsl:text>
367 <xsl:apply-templates />
368 <xsl:text>}&#x0a;</xsl:text>
369 </xsl:when>
370 </xsl:choose>
371 </xsl:template>
372
373 <xsl:template match="holder">
374 <xsl:choose>
375 <xsl:when test="name(..)='copyright'">
376 <xsl:text>\newcommand\docbookbookinfocopyrightholder{</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="firstname">
384 <xsl:choose>
385 <xsl:when test="name(..)='othercredit'">
386 <xsl:text>\newcommand\docbookbookinfoothercreditfirstname{</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="surname">
394 <xsl:choose>
395 <xsl:when test="name(..)='othercredit'">
396 <xsl:text>\newcommand\docbookbookinfoothercreditsurname{</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="contrib">
404 <xsl:choose>
405 <xsl:when test="name(..)='othercredit'">
406 <xsl:text>\newcommand\docbookbookinfoothercreditcontrib{</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="glossary">
414 <xsl:text>&#x0a;&#x0a;\backmatter&#x0a;\chapter{Glossary}&#x0a;</xsl:text>
415 <xsl:apply-templates />
416 </xsl:template>
417
418 <xsl:template match="para">
419 <xsl:if test="not(name(..)='footnote' or name(..)='note' or name(..)='warning')">
420 <xsl:text>&#x0a;&#x0a;</xsl:text>
421 </xsl:if>
422 <xsl:apply-templates />
423 </xsl:template>
424
425 <xsl:template match="note">
426 <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, ':} ')" />
427 <xsl:apply-templates />
428 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
429 </xsl:template>
430
431 <xsl:template match="warning">
432 <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, ':} ')" />
433 <xsl:apply-templates />
434 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
435 </xsl:template>
436
437 <xsl:template match="screen">
438 <xsl:text>&#x0a;&#x0a;\begin{Verbatim}[fontsize=\footnotesize]&#x0a;</xsl:text>
439 <xsl:apply-templates />
440 <xsl:text>&#x0a;\end{Verbatim}&#x0a;</xsl:text>
441 </xsl:template>
442
443 <xsl:template match="programlisting">
444 <xsl:text>&#x0a;&#x0a;{\small\begin{alltt}&#x0a;</xsl:text>
445 <xsl:apply-templates />
446 <xsl:text>&#x0a;\end{alltt}}&#x0a;</xsl:text>
447 </xsl:template>
448
449 <xsl:template match="footnote">
450 <xsl:text>\footnote{</xsl:text>
451 <xsl:apply-templates />
452 <xsl:text>}</xsl:text>
453 </xsl:template>
454
455 <xsl:template match="tgroup">
456 <xsl:choose>
457 <xsl:when test="@style='verywide'">
458 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{1.1\textwidth}[]{|L|L|L|}&#x0a;\hline&#x0a;</xsl:text>
459 </xsl:when>
460 <xsl:otherwise>
461 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{.9\textwidth}[]{|L|L|L|}&#x0a;\hline&#x0a;</xsl:text>
462 </xsl:otherwise>
463 </xsl:choose>
464 <xsl:apply-templates />
465 <xsl:text>&#x0a;\end{tabulary}&#x0a;\end{center}}&#x0a;</xsl:text>
466 </xsl:template>
467
468 <xsl:template match="row">
469 <xsl:apply-templates />
470 <xsl:text>&#x0a;\\ \hline&#x0a;</xsl:text>
471 </xsl:template>
472
473 <xsl:template match="entry">
474 <xsl:if test="not(position()=1)">
475 <xsl:text> &amp; </xsl:text>
476 </xsl:if>
477 <xsl:apply-templates />
478 </xsl:template>
479
480 <xsl:template match="itemizedlist">
481 <xsl:text>&#x0a;&#x0a;\begin{itemize}&#x0a;</xsl:text>
482 <xsl:apply-templates />
483 <xsl:text>&#x0a;\end{itemize}&#x0a;</xsl:text>
484 </xsl:template>
485
486 <xsl:template match="orderedlist">
487 <xsl:text>&#x0a;&#x0a;\begin{enumerate}&#x0a;</xsl:text>
488 <xsl:apply-templates />
489 <xsl:text>&#x0a;\end{enumerate}&#x0a;</xsl:text>
490 </xsl:template>
491
492 <xsl:template match="listitem">
493 <xsl:text>&#x0a;&#x0a;\item </xsl:text>
494 <xsl:apply-templates />
495 <xsl:text>&#x0a;</xsl:text>
496 </xsl:template>
497
498 <xsl:template match="glossterm">
499 <xsl:variable name="refid" select="(@id)" />
500 <xsl:if test="$refid">
501 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
502 </xsl:if>
503 <xsl:text>&#x0a;&#x0a;\item[</xsl:text>
504 <xsl:apply-templates />
505 <xsl:text>]</xsl:text>
506 </xsl:template>
507
508 <xsl:template match="glosslist | glossdiv">
509 <xsl:text>&#x0a;&#x0a;\begin{description}&#x0a;</xsl:text>
510 <xsl:apply-templates />
511 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
512 </xsl:template>
513
514 <xsl:template match="superscript">
515 <xsl:variable name="contents">
516 <xsl:apply-templates />
517 </xsl:variable>
518 <xsl:value-of select="concat('\texorpdfstring{\textsuperscript{', $contents, '}}{', $contents, '}')" />
519 </xsl:template>
520
521 <xsl:template match="emphasis">
522 <xsl:choose>
523 <xsl:when test="@role='bold'">
524 <xsl:text>\textbf{</xsl:text>
525 </xsl:when>
526 <xsl:otherwise>
527 <xsl:text>\textit{</xsl:text>
528 </xsl:otherwise>
529 </xsl:choose>
530 <xsl:apply-templates />
531 <xsl:text>}</xsl:text>
532 </xsl:template>
533
534 <xsl:template match="computeroutput | code">
535 <xsl:text>\texttt{</xsl:text>
536 <xsl:apply-templates />
537 <xsl:text>}</xsl:text>
538 </xsl:template>
539
540 <xsl:template match="ulink">
541 <xsl:text>\url{</xsl:text>
542 <xsl:apply-templates />
543 <xsl:text>}</xsl:text>
544 </xsl:template>
545
546 <xsl:template match="xref">
547 <xsl:choose>
548 <xsl:when test="@xreflabel">
549 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @xreflabel, '}}')" />
550 </xsl:when>
551 <xsl:when test="@apiref='yes'">
552 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{')" />
553 <xsl:apply-templates />
554 <xsl:value-of select="'}}'" />
555 </xsl:when>
556 <xsl:otherwise>
557 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
558 </xsl:otherwise>
559 </xsl:choose>
560 </xsl:template>
561
562 <!-- for some reason, DocBook insists of having image data nested this way always:
563 mediaobject -> imageobject -> imagedata
564 but only imagedata is interesting -->
565 <xsl:template match="imagedata">
566 <xsl:if test="@align='center'">
567 <xsl:text>\begin{center}</xsl:text>
568 </xsl:if>
569 <xsl:value-of select="concat('&#x0a;\includegraphics[width=', @width, ']{', @fileref, '}&#x0a;')" />
570 <xsl:apply-templates />
571 <xsl:if test="@align='center'">
572 <xsl:text>\end{center}</xsl:text>
573 </xsl:if>
574 </xsl:template>
575
576 <xsl:template match="//text()">
577 <xsl:variable name="subst1">
578 <xsl:call-template name="str:subst">
579 <xsl:with-param name="text" select="." />
580 <xsl:with-param name="replace" select="'\'" />
581 <xsl:with-param name="with" select="'\textbackslash{}'" />
582 <xsl:with-param name="disable-output-escaping" select="no" />
583 </xsl:call-template>
584 </xsl:variable>
585 <xsl:choose>
586 <xsl:when test="(name(..)='screen') or (name(../..)='screen')">
587 <xsl:value-of select="." />
588 </xsl:when>
589 <xsl:when test="(name(..)='computeroutput') or (name(../..)='computeroutput') or (name(..)='code') or (name(../..)='code')">
590 <xsl:variable name="subst2">
591 <xsl:call-template name="str:subst">
592 <xsl:with-param name="text" select="$subst1" />
593 <xsl:with-param name="replace" select="'--'" />
594 <xsl:with-param name="with" select="'-{}-'" />
595 <xsl:with-param name="disable-output-escaping" select="no" />
596 </xsl:call-template>
597 </xsl:variable>
598 <xsl:variable name="subst3">
599 <xsl:call-template name="str:subst">
600 <xsl:with-param name="text" select="$subst2" />
601 <xsl:with-param name="replace" select="'_'" />
602 <xsl:with-param name="with" select="'\_'" />
603 <xsl:with-param name="disable-output-escaping" select="no" />
604 </xsl:call-template>
605 </xsl:variable>
606 <xsl:variable name="subst4">
607 <xsl:call-template name="str:subst">
608 <xsl:with-param name="text" select="$subst3" />
609 <xsl:with-param name="replace" select="'$'" />
610 <xsl:with-param name="with" select="'\$'" />
611 <xsl:with-param name="disable-output-escaping" select="no" />
612 </xsl:call-template>
613 </xsl:variable>
614 <xsl:variable name="subst5">
615 <xsl:call-template name="str:subst">
616 <xsl:with-param name="text" select="$subst4" />
617 <xsl:with-param name="replace" select="'%'" />
618 <xsl:with-param name="with" select="'\%'" />
619 <xsl:with-param name="disable-output-escaping" select="no" />
620 </xsl:call-template>
621 </xsl:variable>
622 <xsl:variable name="subst6">
623 <xsl:call-template name="str:subst">
624 <xsl:with-param name="text" select="$subst5" />
625 <xsl:with-param name="replace" select="'#'" />
626 <xsl:with-param name="with" select="'\#'" />
627 <xsl:with-param name="disable-output-escaping" select="no" />
628 </xsl:call-template>
629 </xsl:variable>
630 <xsl:variable name="subst7">
631 <xsl:call-template name="str:subst">
632 <xsl:with-param name="text" select="$subst6" />
633 <xsl:with-param name="replace" select="'~'" />
634 <xsl:with-param name="with" select="'\textasciitilde '" />
635 <xsl:with-param name="disable-output-escaping" select="no" />
636 </xsl:call-template>
637 </xsl:variable>
638 <xsl:variable name="subst8">
639 <xsl:call-template name="str:subst">
640 <xsl:with-param name="text" select="$subst7" />
641 <xsl:with-param name="replace" select="'&amp;'" />
642 <xsl:with-param name="with" select="'\&amp;'" />
643 <xsl:with-param name="disable-output-escaping" select="no" />
644 </xsl:call-template>
645 </xsl:variable>
646 <xsl:value-of select="$subst8" />
647 </xsl:when>
648 <xsl:when test="(name(..)='address') or (name(../..)='address')">
649 <xsl:variable name="subst2">
650 <xsl:call-template name="str:subst">
651 <xsl:with-param name="text" select="$subst1" />
652 <xsl:with-param name="replace" select="'&#x0a;'" />
653 <xsl:with-param name="with" select="' \\'" />
654 <xsl:with-param name="disable-output-escaping" select="no" />
655 </xsl:call-template>
656 </xsl:variable>
657 <xsl:value-of select="$subst2" />
658 </xsl:when>
659 <xsl:otherwise>
660 <xsl:variable name="subst2">
661 <xsl:call-template name="str:subst">
662 <xsl:with-param name="text" select="$subst1" />
663 <xsl:with-param name="replace" select="'_'" />
664 <xsl:with-param name="with" select="'\_'" />
665 <xsl:with-param name="disable-output-escaping" select="no" />
666 </xsl:call-template>
667 </xsl:variable>
668 <xsl:variable name="subst3">
669 <xsl:call-template name="str:subst">
670 <xsl:with-param name="text" select="$subst2" />
671 <xsl:with-param name="replace" select="'$'" />
672 <xsl:with-param name="with" select="'\$'" />
673 <xsl:with-param name="disable-output-escaping" select="no" />
674 </xsl:call-template>
675 </xsl:variable>
676 <xsl:variable name="subst4">
677 <xsl:call-template name="str:subst">
678 <xsl:with-param name="text" select="$subst3" />
679 <xsl:with-param name="replace" select="'%'" />
680 <xsl:with-param name="with" select="'\%'" />
681 <xsl:with-param name="disable-output-escaping" select="no" />
682 </xsl:call-template>
683 </xsl:variable>
684 <xsl:variable name="subst5">
685 <xsl:call-template name="str:subst">
686 <xsl:with-param name="text" select="$subst4" />
687 <xsl:with-param name="replace" select="'#'" />
688 <xsl:with-param name="with" select="'\#'" />
689 <xsl:with-param name="disable-output-escaping" select="no" />
690 </xsl:call-template>
691 </xsl:variable>
692 <xsl:variable name="subst6">
693 <xsl:call-template name="str:subst">
694 <xsl:with-param name="text" select="$subst5" />
695 <xsl:with-param name="replace" select="'µ'" />
696 <xsl:with-param name="with" select="'$\mu$'" />
697 <xsl:with-param name="disable-output-escaping" select="no" />
698 </xsl:call-template>
699 </xsl:variable>
700 <xsl:variable name="subst7">
701 <xsl:call-template name="str:subst">
702 <xsl:with-param name="text" select="$subst6" />
703 <xsl:with-param name="replace" select="'®'" />
704 <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
705 <xsl:with-param name="disable-output-escaping" select="no" />
706 </xsl:call-template>
707 </xsl:variable>
708 <xsl:variable name="quote">"</xsl:variable>
709 <!-- preparation for pretty quotes: replace all double quotes _outside_ screen
710 sections with "\QUOTE{}" strings, which the makefile will then replace
711 with pretty quotes by invoking sed a few times. Unfortunately there are
712 no regular expressions in XSLT so there's no other way. -->
713 <xsl:variable name="subst8">
714 <xsl:call-template name="str:subst">
715 <xsl:with-param name="text" select="$subst7" />
716 <xsl:with-param name="replace" select="$quote" />
717 <xsl:with-param name="with" select="'\QUOTE{}'" />
718 <xsl:with-param name="disable-output-escaping" select="no" />
719 </xsl:call-template>
720 </xsl:variable>
721 <xsl:variable name="subst9">
722 <xsl:call-template name="str:subst">
723 <xsl:with-param name="text" select="$subst8" />
724 <xsl:with-param name="replace" select="'~'" />
725 <xsl:with-param name="with" select="'\textasciitilde '" />
726 <xsl:with-param name="disable-output-escaping" select="no" />
727 </xsl:call-template>
728 </xsl:variable>
729 <xsl:variable name="subst10">
730 <xsl:call-template name="str:subst">
731 <xsl:with-param name="text" select="$subst9" />
732 <xsl:with-param name="replace" select="'&amp;'" />
733 <xsl:with-param name="with" select="'\&amp;'" />
734 <xsl:with-param name="disable-output-escaping" select="no" />
735 </xsl:call-template>
736 </xsl:variable>
737 <xsl:value-of select="$subst10" />
738 </xsl:otherwise>
739 </xsl:choose>
740 </xsl:template>
741</xsl:stylesheet>
742
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