VirtualBox

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

Last change on this file since 78503 was 78503, checked in by vboxsync, 6 years ago

manual/docbook2latex.xsl: Use sloppypar to keep long words from pushing thru the right margin.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 44.1 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{alltt}
118\usepackage{color}
119\usepackage{scrextend}
120\definecolor{darkgreen}{rgb}{0,0.6,0}
121\tymin=21pt
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{sloppypar}
191\end{document}
192 </xsl:text>
193
194 </xsl:template>
195
196 <xsl:template match="bookinfo">
197 <xsl:apply-templates />
198 <xsl:text>&#x0a;\newcommand\docbookbookinfocopyright{\copyright{} \docbookbookinfocopyrightyear{} \docbookbookinfocopyrightholder{}}&#x0a;
199\author{ \docbooktitleedition \\ %
200\\ %
201</xsl:text>
202 <xsl:if test="//bookinfo/address">
203 <xsl:text>\docbookbookinfoaddress \\ %
204\\ %
205</xsl:text>
206 </xsl:if>
207 <xsl:text>\docbookbookinfocopyright \\ %
208}
209
210\title{\docbooktitle \\
211\docbooksubtitle}
212% \subtitle{\docbooksubtitle}
213\hypersetup{pdfauthor=\docbookcorpauthor}
214\hypersetup{pdftitle=\docbooktitle{} \docbooksubtitle{}}
215
216\hyphenation{da-ta-ba-ses}
217\hyphenation{deb-conf}
218\hyphenation{VirtualBox}
219
220\begin{document}
221% bird/2018-05-14: Use sloppypar so we don't push path names and other long words
222% thru the right margin. TODO: Find better solution? microtype?
223\begin{sloppypar}
224% \maketitle
225%\begin{titlepage}
226\thispagestyle{empty}
227\begin{minipage}{\textwidth}
228\begin{center}
229\includegraphics[width=4cm]{images/vboxlogo.png}
230\end{center}%
231\vspace{10mm}
232
233{\fontsize{40pt}{40pt}\selectfont\rmfamily\bfseries%
234\begin{center}
235\docbooktitle
236\end{center}%
237\vspace{10mm}
238}
239
240{\fontsize{30pt}{30pt}\selectfont\rmfamily\bfseries%
241\begin{center}
242\docbooksubtitle
243\end{center}%
244\vspace{10mm}
245}
246
247{\fontsize{16pt}{20pt}\selectfont\rmfamily%
248\begin{center}
249</xsl:text>
250 <xsl:if test="//bookinfo/othercredit">
251 <xsl:text>\docbookbookinfoothercreditcontrib{}: \docbookbookinfoothercreditfirstname{} \docbookbookinfoothercreditsurname
252
253\vspace{8mm}
254</xsl:text>
255 </xsl:if>
256 <xsl:text>\docbooktitleedition
257
258\vspace{2mm}
259
260\docbookbookinfocopyright
261
262\vspace{2mm}
263
264\docbookbookinfoaddress
265\end{center}%
266}
267
268%\end{titlepage}
269\end{minipage}
270
271\tableofcontents
272 </xsl:text>
273 </xsl:template>
274
275 <xsl:template match="subtitle">
276 <xsl:choose>
277 <xsl:when test="name(..)='bookinfo'">
278 <xsl:text>\newcommand\docbooksubtitle{</xsl:text>
279 <xsl:apply-templates />
280 <xsl:text>}</xsl:text>
281 </xsl:when>
282 </xsl:choose>
283 </xsl:template>
284
285 <!--
286 Inserts \hypertarget{@id} that can be referenced via the /A "nameddest=@id"
287 command line or #nameddest=@id URL parameter.
288
289 TODO: The placement of the target could be improved on. The raisebox
290 stuff is a crude hack to make it a little more acceptable. -->
291 <xsl:template name="title-wrapper">
292 <xsl:param name="texcmd" select="concat('\',name(..))"/>
293 <xsl:param name="refid" select="../@id"/>
294 <xsl:param name="role" select="../@role"/>
295
296 <xsl:call-template name="xsltprocNewlineOutputHack"/>
297 <xsl:if test="$texcmd='\chapter' and $role='frontmatter'">
298 <xsl:text>\frontmatter&#x0a;</xsl:text>
299 </xsl:if>
300 <xsl:if test="$texcmd='\chapter' and ../preceding-sibling::*[1][@role='frontmatter']">
301 <xsl:text>\mainmatter&#x0a;</xsl:text>
302 </xsl:if>
303 <xsl:choose>
304 <xsl:when test="$refid">
305 <xsl:text>&#x0a;</xsl:text>
306 <xsl:value-of select="$texcmd"/>
307 <xsl:if test="not(contains($texcmd, '*'))">
308 <xsl:text>[</xsl:text> <!-- for toc -->
309 <xsl:apply-templates />
310 <xsl:text>]</xsl:text>
311 </xsl:if>
312 <xsl:text>{</xsl:text> <!-- for doc -->
313 <xsl:text>\raisebox{\ht\strutbox}{\hypertarget{</xsl:text>
314 <xsl:value-of select="$refid"/>
315 <xsl:text>}{}}</xsl:text>
316 <xsl:apply-templates />
317 <xsl:text>}</xsl:text>
318 </xsl:when>
319 <xsl:otherwise>
320 <xsl:text>&#x0a;</xsl:text><xsl:value-of select="$texcmd"/><xsl:text>{</xsl:text>
321 <xsl:apply-templates />
322 <xsl:text>}</xsl:text>
323 </xsl:otherwise>
324 </xsl:choose>
325 </xsl:template>
326
327 <xsl:template match="title">
328 <xsl:variable name="refid" select="../@id" />
329 <xsl:choose>
330 <xsl:when test="name(..)='bookinfo'">
331 <xsl:text>\newcommand\docbooktitle{</xsl:text>
332 <xsl:apply-templates />
333 <xsl:text>}</xsl:text>
334 </xsl:when>
335 <xsl:when test="name(..)='chapter'">
336 <xsl:call-template name="title-wrapper"/>
337 </xsl:when>
338 <xsl:when test="name(..)='preface'">
339 <xsl:call-template name="title-wrapper">
340 <xsl:with-param name="texcmd">\chapter</xsl:with-param>
341 </xsl:call-template>
342 </xsl:when>
343 <xsl:when test="name(..)='sect1' and ../../@role='frontmatter'">
344 <xsl:call-template name="title-wrapper">
345 <xsl:with-param name="texcmd">\section*</xsl:with-param>
346 </xsl:call-template>
347 </xsl:when>
348 <xsl:when test="name(..)='sect1'">
349 <xsl:call-template name="title-wrapper">
350 <xsl:with-param name="texcmd">\section</xsl:with-param>
351 </xsl:call-template>
352 </xsl:when>
353 <xsl:when test="parent::sect2[@role='not-in-toc'] or parent::refsect1 or (parent::section and count(ancestor::section) = 2)">
354 <xsl:call-template name="title-wrapper">
355 <xsl:with-param name="texcmd">\subsection*</xsl:with-param>
356 </xsl:call-template>
357 </xsl:when>
358 <xsl:when test="name(..)='sect2'">
359 <xsl:call-template name="title-wrapper">
360 <xsl:with-param name="texcmd">\subsection</xsl:with-param>
361 </xsl:call-template>
362 </xsl:when>
363 <xsl:when test="parent::sect3[@role='not-in-toc'] or parent::refsect2 or (parent::section and count(ancestor::section) = 3)">
364 <xsl:call-template name="title-wrapper">
365 <xsl:with-param name="texcmd">\subsubsection*</xsl:with-param>
366 </xsl:call-template>
367 </xsl:when>
368 <xsl:when test="name(..)='sect3'">
369 <xsl:call-template name="title-wrapper">
370 <xsl:with-param name="texcmd">\subsubsection</xsl:with-param>
371 </xsl:call-template>
372 </xsl:when>
373 <xsl:when test="parent::sect4[@role='not-in-toc'] or parent::refsect3 or (parent::section and count(ancestor::section) = 4)">
374 <xsl:call-template name="title-wrapper">
375 <xsl:with-param name="texcmd">\paragraph*</xsl:with-param>
376 </xsl:call-template>
377 </xsl:when>
378 <xsl:when test="name(..)='sect4'">
379 <xsl:call-template name="title-wrapper">
380 <xsl:with-param name="texcmd">\paragraph</xsl:with-param>
381 </xsl:call-template>
382 </xsl:when>
383 <xsl:when test="parent::sect5[@role='not-in-toc'] or parent::refsect4 or (parent::section and count(ancestor::section) = 5)">
384 <xsl:call-template name="title-wrapper">
385 <xsl:with-param name="texcmd">\subparagraph*</xsl:with-param>
386 </xsl:call-template>
387 </xsl:when>
388 <xsl:when test="name(..)='sect5'">
389 <xsl:call-template name="title-wrapper">
390 <xsl:with-param name="texcmd">\subparagraph</xsl:with-param>
391 </xsl:call-template>
392 </xsl:when>
393 <xsl:when test="name(..)='appendix'">
394 <xsl:call-template name="title-wrapper">
395 <xsl:with-param name="texcmd">\chapter</xsl:with-param>
396 </xsl:call-template>
397 </xsl:when>
398 <xsl:when test="name(..)='glossdiv'">
399 <xsl:call-template name="title-wrapper">
400 <xsl:with-param name="texcmd">\section*</xsl:with-param>
401 </xsl:call-template>
402 </xsl:when>
403 </xsl:choose>
404 <xsl:if test="$refid">
405 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
406 </xsl:if>
407 <xsl:text>&#x0a;</xsl:text>
408 </xsl:template>
409
410 <xsl:template match="edition">
411 <xsl:choose>
412 <xsl:when test="name(..)='bookinfo'">
413 <xsl:text>\newcommand\docbooktitleedition{</xsl:text>
414 <xsl:apply-templates />
415 <xsl:text>}&#x0a;</xsl:text>
416 </xsl:when>
417 </xsl:choose>
418 </xsl:template>
419
420 <xsl:template match="corpauthor">
421 <xsl:choose>
422 <xsl:when test="name(..)='bookinfo'">
423 <xsl:text>\newcommand\docbookcorpauthor{</xsl:text>
424 <xsl:apply-templates />
425 <xsl:text>}&#x0a;</xsl:text>
426 </xsl:when>
427 </xsl:choose>
428 </xsl:template>
429
430 <xsl:template match="address">
431 <xsl:choose>
432 <xsl:when test="name(..)='bookinfo'">
433 <xsl:text>\newcommand\docbookbookinfoaddress{</xsl:text>
434 <xsl:apply-templates />
435 <xsl:text>}&#x0a;</xsl:text>
436 </xsl:when>
437 </xsl:choose>
438 </xsl:template>
439
440 <xsl:template match="year">
441 <xsl:choose>
442 <xsl:when test="name(..)='copyright'">
443 <xsl:text>\newcommand\docbookbookinfocopyrightyear{</xsl:text>
444 <xsl:apply-templates />
445 <xsl:text>}&#x0a;</xsl:text>
446 </xsl:when>
447 </xsl:choose>
448 </xsl:template>
449
450 <xsl:template match="holder">
451 <xsl:choose>
452 <xsl:when test="name(..)='copyright'">
453 <xsl:text>\newcommand\docbookbookinfocopyrightholder{</xsl:text>
454 <xsl:apply-templates />
455 <xsl:text>}&#x0a;</xsl:text>
456 </xsl:when>
457 </xsl:choose>
458 </xsl:template>
459
460 <xsl:template match="firstname">
461 <xsl:choose>
462 <xsl:when test="name(..)='othercredit'">
463 <xsl:text>\newcommand\docbookbookinfoothercreditfirstname{</xsl:text>
464 <xsl:apply-templates />
465 <xsl:text>}&#x0a;</xsl:text>
466 </xsl:when>
467 </xsl:choose>
468 </xsl:template>
469
470 <xsl:template match="surname">
471 <xsl:choose>
472 <xsl:when test="name(..)='othercredit'">
473 <xsl:text>\newcommand\docbookbookinfoothercreditsurname{</xsl:text>
474 <xsl:apply-templates />
475 <xsl:text>}&#x0a;</xsl:text>
476 </xsl:when>
477 </xsl:choose>
478 </xsl:template>
479
480 <xsl:template match="contrib">
481 <xsl:choose>
482 <xsl:when test="name(..)='othercredit'">
483 <xsl:text>\newcommand\docbookbookinfoothercreditcontrib{</xsl:text>
484 <xsl:apply-templates />
485 <xsl:text>}&#x0a;</xsl:text>
486 </xsl:when>
487 </xsl:choose>
488 </xsl:template>
489
490 <xsl:template match="glossary">
491 <xsl:text>&#x0a;&#x0a;\backmatter&#x0a;\chapter{Glossary}&#x0a;</xsl:text>
492 <xsl:apply-templates />
493 </xsl:template>
494
495 <xsl:template match="para">
496 <xsl:if test="not(name(..)='footnote' or name(..)='note' or name(..)='warning' or (name(../..)='varlistentry' and position()=1))">
497 <xsl:text>&#x0a;&#x0a;</xsl:text>
498 </xsl:if>
499 <xsl:apply-templates />
500 </xsl:template>
501
502 <xsl:template match="note">
503 <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, ':} ')" />
504 <xsl:apply-templates />
505 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
506 </xsl:template>
507
508 <xsl:template match="warning">
509 <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, ':} ')" />
510 <xsl:apply-templates />
511 <xsl:text>\end{minipage}}\end{center}&#x0a;&#x0a;\vspace{.2cm}&#x0a;&#x0a;</xsl:text>
512 </xsl:template>
513
514 <xsl:template match="screen">
515 <xsl:text>&#x0a;&#x0a;{\footnotesize\begin{alltt}&#x0a;</xsl:text>
516 <xsl:apply-templates />
517 <xsl:text>&#x0a;\end{alltt}}&#x0a;</xsl:text>
518 </xsl:template>
519
520 <xsl:template match="programlisting">
521 <xsl:text>&#x0a;&#x0a;{\small\begin{alltt}&#x0a;</xsl:text>
522 <xsl:apply-templates />
523 <xsl:text>&#x0a;\end{alltt}}&#x0a;</xsl:text>
524 </xsl:template>
525
526 <xsl:template match="footnote">
527 <xsl:text>\footnote{</xsl:text>
528 <xsl:apply-templates />
529 <xsl:text>}</xsl:text>
530 </xsl:template>
531
532 <xsl:template match="tgroup">
533 <xsl:choose>
534 <xsl:when test="@style='verywide'">
535 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{1.1\textwidth}[]</xsl:text>
536 </xsl:when>
537 <xsl:otherwise>
538 <xsl:text>&#x0a;&#x0a;{\small\begin{center}&#x0a;\begin{tabulary}{.9\textwidth}[]</xsl:text>
539 </xsl:otherwise>
540 </xsl:choose>
541 <xsl:text>{</xsl:text>
542 <xsl:choose>
543 <xsl:when test="@cols='1'">
544 <xsl:text>|L|</xsl:text>
545 </xsl:when>
546 <xsl:when test="@cols='2'">
547 <xsl:text>|L|L|</xsl:text>
548 </xsl:when>
549 <xsl:when test="@cols='3'">
550 <xsl:text>|L|L|L|</xsl:text>
551 </xsl:when>
552 <xsl:when test="@cols='4'">
553 <xsl:text>|L|L|L|L|</xsl:text>
554 </xsl:when>
555 <xsl:when test="@cols='5'">
556 <xsl:text>|L|L|L|L|L|</xsl:text>
557 </xsl:when>
558 <xsl:when test="@cols='6'">
559 <xsl:text>|L|L|L|L|L|L|</xsl:text>
560 </xsl:when>
561 <xsl:otherwise>
562 <xsl:message terminate="yes">Unsupported number of columns (<xsl:value-of select="@cols"/>), fix document or converter</xsl:message>
563 </xsl:otherwise>
564 </xsl:choose>
565 <xsl:text>}&#x0a;\hline&#x0a;</xsl:text>
566 <xsl:apply-templates />
567 <xsl:text>&#x0a;\end{tabulary}&#x0a;\end{center}}&#x0a;</xsl:text>
568 </xsl:template>
569
570 <xsl:template match="row">
571 <xsl:apply-templates />
572 <xsl:text>&#x0a;\\ \hline&#x0a;</xsl:text>
573 </xsl:template>
574
575 <xsl:template match="entry">
576 <xsl:if test="not(position()=1)">
577 <xsl:text> &amp; </xsl:text>
578 </xsl:if>
579 <xsl:apply-templates />
580 </xsl:template>
581
582 <xsl:template match="itemizedlist">
583 <xsl:call-template name="xsltprocNewlineOutputHack"/>
584 <xsl:text>&#x0a;\begin{itemize}&#x0a;</xsl:text>
585 <xsl:if test="@spacing = 'compact'">
586 <xsl:text> \setlength{\parskip}{0pt}&#x0a;</xsl:text>
587 <xsl:text> \setlength{\itemsep}{0pt}&#x0a;</xsl:text>
588 <xsl:text> \setlength{\topsep}{0pt}&#x0a;</xsl:text>
589 <xsl:text> \setlength{\parsep}{0pt}&#x0a;</xsl:text>
590 <xsl:text> \setlength{\partopsep}{0pt}&#x0a;</xsl:text>
591 </xsl:if>
592 <xsl:apply-templates />
593 <xsl:text>&#x0a;\end{itemize}&#x0a;</xsl:text>
594 </xsl:template>
595
596 <xsl:template match="orderedlist">
597 <xsl:call-template name="xsltprocNewlineOutputHack"/>
598 <xsl:text>&#x0a;\begin{enumerate}&#x0a;</xsl:text>
599 <xsl:if test="@spacing = 'compact'">
600 <xsl:text> \setlength{\parskip}{0pt}&#x0a;</xsl:text>
601 <xsl:text> \setlength{\itemsep}{0pt}&#x0a;</xsl:text>
602 <xsl:text> \setlength{\topsep}{0pt}&#x0a;</xsl:text>
603 <xsl:text> \setlength{\parsep}{0pt}&#x0a;</xsl:text>
604 <xsl:text> \setlength{\partopsep}{0pt}&#x0a;</xsl:text>
605 </xsl:if>
606 <xsl:apply-templates />
607 <xsl:text>&#x0a;\end{enumerate}&#x0a;</xsl:text>
608 </xsl:template>
609
610 <xsl:template match="variablelist">
611 <xsl:call-template name="xsltprocNewlineOutputHack"/>
612 <xsl:text>&#x0a;\begin{description}&#x0a;</xsl:text>
613 <xsl:if test="@spacing = 'compact'">
614 <xsl:text> \setlength{\parskip}{0pt}&#x0a;</xsl:text>
615 <xsl:text> \setlength{\itemsep}{0pt}&#x0a;</xsl:text>
616 <xsl:text> \setlength{\topsep}{0pt}&#x0a;</xsl:text>
617 <xsl:text> \setlength{\parsep}{0pt}&#x0a;</xsl:text>
618 <xsl:text> \setlength{\partopsep}{0pt}&#x0a;</xsl:text>
619 </xsl:if>
620 <xsl:apply-templates />
621 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
622 </xsl:template>
623
624 <xsl:template match="varlistentry">
625 <xsl:if test="not(./term) or not(./listitem) or count(./listitem) != 1">
626 <xsl:message terminate="yes">Expected at least one term and one listitem element in the varlistentry.</xsl:message>
627 </xsl:if>
628 <xsl:text>&#x0a;&#x0a;\item[{\parbox[t]{\linewidth}{\raggedright </xsl:text>
629 <xsl:apply-templates select="./term[1]"/>
630 <xsl:for-each select="./term[position() > 1]">
631 <xsl:text>\\&#x0a; </xsl:text>
632 <xsl:apply-templates select="."/>
633 </xsl:for-each>
634 <xsl:text>}}] \hfill \\&#x0a;</xsl:text>
635 <xsl:apply-templates select="listitem/*"/>
636 </xsl:template>
637
638 <xsl:template match="listitem">
639 <xsl:text>&#x0a;&#x0a;\item </xsl:text>
640 <xsl:apply-templates />
641 <xsl:text>&#x0a;</xsl:text>
642 </xsl:template>
643
644 <xsl:template match="glossterm">
645 <xsl:variable name="refid" select="(@id)" />
646 <xsl:if test="$refid">
647 <xsl:value-of select="concat('&#x0a;\label{', $refid, '}')" />
648 </xsl:if>
649 <xsl:text>&#x0a;&#x0a;\item[</xsl:text>
650 <xsl:apply-templates />
651 <xsl:text>]</xsl:text>
652 </xsl:template>
653
654 <xsl:template match="glosslist | glossdiv">
655 <xsl:text>&#x0a;&#x0a;\begin{description}&#x0a;</xsl:text>
656 <xsl:apply-templates />
657 <xsl:text>&#x0a;\end{description}&#x0a;</xsl:text>
658 </xsl:template>
659
660 <xsl:template match="superscript">
661 <xsl:variable name="contents">
662 <xsl:apply-templates />
663 </xsl:variable>
664 <xsl:value-of select="concat('\texorpdfstring{\textsuperscript{', $contents, '}}{', $contents, '}')" />
665 </xsl:template>
666
667 <xsl:template match="emphasis">
668 <xsl:choose>
669 <xsl:when test="@role='bold'">
670 <xsl:text>\textbf{</xsl:text>
671 </xsl:when>
672 <xsl:otherwise>
673 <xsl:text>\textit{</xsl:text>
674 </xsl:otherwise>
675 </xsl:choose>
676 <xsl:apply-templates />
677 <xsl:text>}</xsl:text>
678 </xsl:template>
679
680 <xsl:template match="computeroutput | code">
681 <xsl:text>\texttt{</xsl:text>
682 <xsl:apply-templates />
683 <xsl:text>}</xsl:text>
684 </xsl:template>
685
686 <xsl:template match="literal | filename">
687 <xsl:text>\texttt{</xsl:text>
688 <xsl:apply-templates />
689 <xsl:text>}</xsl:text>
690 </xsl:template>
691
692 <xsl:template match="citetitle">
693 <xsl:text>\textit{</xsl:text>
694 <xsl:apply-templates />
695 <xsl:text>}</xsl:text>
696 </xsl:template>
697
698 <xsl:template match="ulink">
699 <xsl:text>\url{</xsl:text>
700 <xsl:apply-templates />
701 <xsl:text>}</xsl:text>
702 </xsl:template>
703
704 <xsl:template match="xref">
705 <xsl:choose>
706 <xsl:when test="@endterm">
707 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
708 </xsl:when>
709 <xsl:otherwise>
710 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
711 </xsl:otherwise>
712 </xsl:choose>
713 </xsl:template>
714
715 <xsl:template match="link">
716 <xsl:choose>
717 <xsl:when test="@endterm">
718 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{', @endterm, '}}')" />
719 </xsl:when>
720 <xsl:when test="./text()">
721 <xsl:value-of select="concat('\hyperref[', @linkend, ']{\mbox{')" />
722 <xsl:apply-templates select="./text()"/>
723 <xsl:value-of select="'}}'" />
724 </xsl:when>
725 <xsl:otherwise>
726 <xsl:value-of select="concat($g_nlsChapter, ' \ref{', @linkend, '}, \textit{\nameref{', @linkend, '}}, ', $g_nlsPage, ' \pageref{', @linkend, '}')" />
727 </xsl:otherwise>
728 </xsl:choose>
729 </xsl:template>
730
731 <xsl:template match="trademark">
732 <xsl:apply-templates />
733 <xsl:text>\textsuperscript{\textregistered}</xsl:text>
734 </xsl:template>
735
736 <!-- for some reason, DocBook insists of having image data nested this way always:
737 mediaobject -> imageobject -> imagedata
738 but only imagedata is interesting -->
739 <xsl:template match="imagedata">
740 <xsl:if test="@align='center'">
741 <xsl:text>\begin{center}</xsl:text>
742 </xsl:if>
743 <xsl:value-of select="concat('&#x0a;\includegraphics[width=', @width, ']{', @fileref, '}&#x0a;')" />
744 <xsl:apply-templates />
745 <xsl:if test="@align='center'">
746 <xsl:text>\end{center}</xsl:text>
747 </xsl:if>
748 </xsl:template>
749
750 <!--
751 Turn the refsynopsisdiv part of a manpage into a named & indented paragraph.
752 -->
753 <xsl:template match="refsynopsisdiv">
754 <xsl:if test="name(*[1]) != 'cmdsynopsis'"><xsl:message terminate="yes">Expected refsynopsisdiv to start with cmdsynopsis</xsl:message></xsl:if>
755 <xsl:if test="title"><xsl:message terminate="yes">No title element supported in refsynopsisdiv</xsl:message></xsl:if>
756 <xsl:call-template name="xsltprocNewlineOutputHack"/>
757 <xsl:text>&#x0a;\subsection*{Synopsis}</xsl:text>
758 <xsl:if test="name(*[1]) != 'cmdsynopsis'"> <!-- just in case -->
759 <xsl:text>\hfill \\&#x0a;</xsl:text>
760 </xsl:if>
761 <xsl:text>&#x0a;</xsl:text>
762 <xsl:apply-templates />
763 </xsl:template>
764
765 <!--
766 The refsect1 is used for 'Description' and such. Do same as with refsynopsisdiv
767 and turn it into a named & indented paragraph.
768 -->
769 <xsl:template match="refsect1">
770 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
771 <xsl:message terminate="yes">Expected exactly one title as the first refsect1 element (remarks goes after title!).</xsl:message>
772 </xsl:if>
773 <xsl:apply-templates/>
774 </xsl:template>
775
776 <!--
777 The refsect2 element will be turned into a subparagraph if it has a title,
778 however, that didn't work out when it didn't have a title and started with
779 a cmdsynopsis instead (subcommand docs). So, we're doing some trickery
780 here (HACK ALERT) for the non-title case to feign a paragraph.
781 -->
782 <xsl:template match="refsect2">
783 <xsl:if test="name(*[1]) != 'title' or count(title) != 1">
784 <xsl:message terminate="yes">Expected exactly one title as the first refsect2 element (remarks goes after title!).</xsl:message>
785 </xsl:if>
786 <xsl:apply-templates/>
787 <xsl:text>&#x0a;</xsl:text>
788 </xsl:template>
789
790
791 <!--
792 Command Synopsis elements.
793
794 We treat each command element inside a cmdsynopsis as the start of
795 a new paragraph. The DocBook HTML converter does so too, but the
796 manpage one doesn't.
797
798 sbr and linebreaks made by latex should be indented from the base
799 command level. This is done by the \hangindent3em\hangafter1 bits.
800
801 We exploit the default paragraph indentation to get each command
802 indented from the left margin. This, unfortunately, doesn't work
803 if we're the first paragraph in a (sub*)section. \noindent cannot
804 counter this due to when latex enforces first paragraph stuff. Since
805 it's tedious to figure out when we're in the first paragraph and when
806 not, we just do \noindent\hspace{1em} everywhere.
807 -->
808 <xsl:template match="sbr">
809 <xsl:if test="not(ancestor::cmdsynopsis)">
810 <xsl:message terminate="yes">sbr only supported inside cmdsynopsis (because of hangindent)</xsl:message>
811 </xsl:if>
812 <xsl:text>\linebreak</xsl:text>
813 </xsl:template>
814
815 <xsl:template match="refentry|refnamediv|refentryinfo|refmeta|refsect3|refsect4|refsect5|synopfragment|synopfragmentref|cmdsynopsis/info">
816 <xsl:message terminate="yes"><xsl:value-of select="name()"/> is not supported</xsl:message>
817 </xsl:template>
818
819 <xsl:template match="cmdsynopsis">
820 <xsl:if test="preceding-sibling::cmdsynopsis">
821 <xsl:text>\par%cmdsynopsis</xsl:text>
822 </xsl:if>
823 <xsl:text>&#x0a;</xsl:text>
824 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
825 <!-- Overview fontsize trick -->
826 <xsl:text>{\footnotesize</xsl:text>
827 </xsl:if>
828 <xsl:text>\noindent\hspace{1em}</xsl:text>
829 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
830 <xsl:apply-templates />
831 <xsl:text>}</xsl:text>
832 <xsl:if test="following-sibling::*">
833 </xsl:if>
834
835 <!-- For refsect2 subcommand descriptions. -->
836 <xsl:if test="not(following-sibling::cmdsynopsis) and position() != last()">
837 <xsl:text>\linebreak</xsl:text>
838 </xsl:if>
839 <!-- Special overview trick for the current VBoxManage command overview. -->
840 <xsl:if test="parent::remark[@role='VBoxManage-overview']">
841 <xsl:text>}\vspace{1em}</xsl:text>
842 </xsl:if>
843 </xsl:template>
844
845 <xsl:template match="command">
846 <xsl:choose>
847 <xsl:when test="ancestor::cmdsynopsis">
848 <!-- Trigger a line break if this isn't the first command in a the synopsis -->
849 <xsl:if test="preceding-sibling::command">
850 <xsl:text>}\par%command&#x0a;</xsl:text>
851 <xsl:text>\noindent\hspace{1em}</xsl:text>
852 <xsl:text>\hangindent3em\hangafter1\texttt{</xsl:text>
853 </xsl:if>
854 <xsl:apply-templates />
855 </xsl:when>
856 <xsl:otherwise>
857 <xsl:text>\texttt{</xsl:text>
858 <xsl:apply-templates />
859 <xsl:text>}</xsl:text>
860 </xsl:otherwise>
861 </xsl:choose>
862 </xsl:template>
863
864 <xsl:template match="option">
865 <xsl:choose>
866 <xsl:when test="ancestor::cmdsynopsis">
867 <xsl:apply-templates />
868 </xsl:when>
869 <xsl:otherwise>
870 <xsl:text>\texttt{</xsl:text>
871 <xsl:apply-templates />
872 <xsl:text>}</xsl:text>
873 </xsl:otherwise>
874 </xsl:choose>
875 </xsl:template>
876
877 <!-- duplicated in docbook2latex.xsl -->
878 <xsl:template match="arg|group">
879 <!-- separator char if we're not the first child -->
880 <xsl:if test="position() > 1">
881 <xsl:choose>
882 <xsl:when test="parent::group"><xsl:value-of select="$arg.or.sep"/></xsl:when>
883 <xsl:when test="ancestor-or-self::*/@sepchar"><xsl:value-of select="ancestor-or-self::*/@sepchar"/></xsl:when>
884 <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
885 </xsl:choose>
886 </xsl:if>
887 <!-- open wrapping -->
888 <xsl:choose>
889 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.open.str"/></xsl:when>
890 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/></xsl:when>
891 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.open.str"/></xsl:when>
892 <xsl:when test="@choice = 'plain'"/>
893 <xsl:otherwise><xsl:message terminate="yes">Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise>
894 </xsl:choose>
895
896 <!-- render the arg (TODO: may need to do more work here) -->
897 <xsl:apply-templates />
898
899 <!-- repeat wrapping -->
900 <xsl:choose>
901 <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/>
902 <xsl:when test="@rep = 'repeat'"> <xsl:value-of select="$arg.rep.repeat.str"/></xsl:when>
903 <xsl:otherwise><xsl:message terminate="yes">Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise>
904 </xsl:choose>
905 <!-- close wrapping -->
906 <xsl:choose>
907 <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.close.str"/></xsl:when>
908 <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.close.str"/></xsl:when>
909 <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.close.str"/></xsl:when>
910 </xsl:choose>
911 </xsl:template>
912
913 <xsl:template match="replaceable">
914 <xsl:choose>
915 <xsl:when test="(not(ancestor::cmdsynopsis) and not(ancestor::option) and not(ancestor::screen)) or ancestor::arg">
916 <xsl:text>\texttt{\textit{</xsl:text>
917 <xsl:apply-templates />
918 <xsl:text>}}</xsl:text>
919 </xsl:when>
920 <xsl:otherwise>
921 <xsl:text>\textit{&lt;</xsl:text>
922 <xsl:apply-templates />
923 <xsl:text>&gt;}</xsl:text>
924 </xsl:otherwise>
925 </xsl:choose>
926 </xsl:template>
927
928
929 <!--
930 Generic element text magic.
931 -->
932 <xsl:template match="//text()">
933
934 <!-- Do the translation of \ into \textbackslash{} in two steps, to avoid
935 running into replacing {} as well which would be very wrong. -->
936 <xsl:variable name="subst1">
937 <xsl:call-template name="str:subst">
938 <xsl:with-param name="text" select="." />
939 <xsl:with-param name="replace" select="'\'" />
940 <xsl:with-param name="with" select="'\textbackslash'" />
941 <xsl:with-param name="disable-output-escaping" select="no" />
942 </xsl:call-template>
943 </xsl:variable>
944 <xsl:variable name="subst2">
945 <xsl:call-template name="str:subst">
946 <xsl:with-param name="text" select="$subst1" />
947 <xsl:with-param name="replace" select="'{'" />
948 <xsl:with-param name="with" select="'\{'" />
949 <xsl:with-param name="disable-output-escaping" select="no" />
950 </xsl:call-template>
951 </xsl:variable>
952 <xsl:variable name="subst3">
953 <xsl:call-template name="str:subst">
954 <xsl:with-param name="text" select="$subst2" />
955 <xsl:with-param name="replace" select="'}'" />
956 <xsl:with-param name="with" select="'\}'" />
957 <xsl:with-param name="disable-output-escaping" select="no" />
958 </xsl:call-template>
959 </xsl:variable>
960 <xsl:variable name="subst4">
961 <xsl:call-template name="str:subst">
962 <xsl:with-param name="text" select="$subst3" />
963 <xsl:with-param name="replace" select="'\textbackslash'" />
964 <xsl:with-param name="with" select="'\textbackslash{}'" />
965 <xsl:with-param name="disable-output-escaping" select="no" />
966 </xsl:call-template>
967 </xsl:variable>
968
969 <xsl:choose>
970 <xsl:when test="(name(..) = 'computeroutput') or (name(../..) = 'computeroutput')
971 or (name(..) = 'code') or (name(../..) = 'code')
972 or (name(..) = 'arg') or (name(../..) = 'arg')
973 or (name(..) = 'option') or (name(../..) = 'option')
974 or (name(..) = 'command') or (name(../..) = 'command')
975 or (name(..) = 'cmdsynopsis') or (name(../..) = 'cmdsynopsis')
976 or (name(..) = 'replaceable') or (name(../..) = 'replaceable')
977 ">
978 <xsl:variable name="subst5">
979 <xsl:call-template name="str:subst">
980 <xsl:with-param name="text" select="translate(normalize-space(concat('&#x7f;',$subst4,'&#x7f;')),'&#x7f;','')" />
981 <xsl:with-param name="replace" select="'--'" />
982 <xsl:with-param name="with" select="'-{}-'" />
983 <xsl:with-param name="disable-output-escaping" select="no" />
984 </xsl:call-template>
985 </xsl:variable>
986 <xsl:variable name="subst6">
987 <xsl:call-template name="str:subst">
988 <xsl:with-param name="text" select="$subst5" />
989 <xsl:with-param name="replace" select="'_'" />
990 <xsl:with-param name="with" select="'\_'" />
991 <xsl:with-param name="disable-output-escaping" select="no" />
992 </xsl:call-template>
993 </xsl:variable>
994 <xsl:variable name="subst7">
995 <xsl:call-template name="str:subst">
996 <xsl:with-param name="text" select="$subst6" />
997 <xsl:with-param name="replace" select="'$'" />
998 <xsl:with-param name="with" select="'\$'" />
999 <xsl:with-param name="disable-output-escaping" select="no" />
1000 </xsl:call-template>
1001 </xsl:variable>
1002 <xsl:variable name="subst8">
1003 <xsl:call-template name="str:subst">
1004 <xsl:with-param name="text" select="$subst7" />
1005 <xsl:with-param name="replace" select="'%'" />
1006 <xsl:with-param name="with" select="'\%'" />
1007 <xsl:with-param name="disable-output-escaping" select="no" />
1008 </xsl:call-template>
1009 </xsl:variable>
1010 <xsl:variable name="subst9">
1011 <xsl:call-template name="str:subst">
1012 <xsl:with-param name="text" select="$subst8" />
1013 <xsl:with-param name="replace" select="'#'" />
1014 <xsl:with-param name="with" select="'\#'" />
1015 <xsl:with-param name="disable-output-escaping" select="no" />
1016 </xsl:call-template>
1017 </xsl:variable>
1018 <xsl:variable name="subst10">
1019 <xsl:call-template name="str:subst">
1020 <xsl:with-param name="text" select="$subst9" />
1021 <xsl:with-param name="replace" select="'~'" />
1022 <xsl:with-param name="with" select="'\textasciitilde{}'" />
1023 <xsl:with-param name="disable-output-escaping" select="no" />
1024 </xsl:call-template>
1025 </xsl:variable>
1026 <xsl:variable name="subst11">
1027 <xsl:call-template name="str:subst">
1028 <xsl:with-param name="text" select="$subst10" />
1029 <xsl:with-param name="replace" select="'&amp;'" />
1030 <xsl:with-param name="with" select="'\&amp;'" />
1031 <xsl:with-param name="disable-output-escaping" select="no" />
1032 </xsl:call-template>
1033 </xsl:variable>
1034 <xsl:choose>
1035 <xsl:when test="parent::arg or parent::command">
1036 <xsl:variable name="subst12">
1037 <xsl:call-template name="str:subst">
1038 <xsl:with-param name="text" select="$subst10" />
1039 <xsl:with-param name="replace" select="' '" />
1040 <xsl:with-param name="with" select="'~'" />
1041 <xsl:with-param name="disable-output-escaping" select="no" />
1042 </xsl:call-template>
1043 </xsl:variable>
1044 <xsl:value-of select="$subst12" />
1045 </xsl:when>
1046 <xsl:otherwise>
1047 <xsl:value-of select="$subst11" />
1048 </xsl:otherwise>
1049 </xsl:choose>
1050 </xsl:when>
1051
1052 <xsl:when test="(name(..)='address') or (name(../..)='address')">
1053 <xsl:variable name="subst5">
1054 <xsl:call-template name="str:subst">
1055 <xsl:with-param name="text" select="$subst4" />
1056 <xsl:with-param name="replace" select="'&#x0a;'" />
1057 <xsl:with-param name="with" select="' \\'" />
1058 <xsl:with-param name="disable-output-escaping" select="no" />
1059 </xsl:call-template>
1060 </xsl:variable>
1061 <xsl:value-of select="$subst5" />
1062 </xsl:when>
1063
1064 <!-- <screen> and <programlisting>, which work with alltt environment. -->
1065 <xsl:otherwise>
1066 <xsl:variable name="subst5">
1067 <xsl:call-template name="str:subst">
1068 <xsl:with-param name="text" select="$subst4" />
1069 <xsl:with-param name="replace" select="'_'" />
1070 <xsl:with-param name="with" select="'\_'" />
1071 <xsl:with-param name="disable-output-escaping" select="no" />
1072 </xsl:call-template>
1073 </xsl:variable>
1074 <xsl:variable name="subst6">
1075 <xsl:call-template name="str:subst">
1076 <xsl:with-param name="text" select="$subst5" />
1077 <xsl:with-param name="replace" select="'$'" />
1078 <xsl:with-param name="with" select="'\$'" />
1079 <xsl:with-param name="disable-output-escaping" select="no" />
1080 </xsl:call-template>
1081 </xsl:variable>
1082 <xsl:variable name="subst7">
1083 <xsl:call-template name="str:subst">
1084 <xsl:with-param name="text" select="$subst6" />
1085 <xsl:with-param name="replace" select="'%'" />
1086 <xsl:with-param name="with" select="'\%'" />
1087 <xsl:with-param name="disable-output-escaping" select="no" />
1088 </xsl:call-template>
1089 </xsl:variable>
1090 <xsl:variable name="subst8">
1091 <xsl:call-template name="str:subst">
1092 <xsl:with-param name="text" select="$subst7" />
1093 <xsl:with-param name="replace" select="'#'" />
1094 <xsl:with-param name="with" select="'\#'" />
1095 <xsl:with-param name="disable-output-escaping" select="no" />
1096 </xsl:call-template>
1097 </xsl:variable>
1098 <xsl:variable name="subst9">
1099 <xsl:call-template name="str:subst">
1100 <xsl:with-param name="text" select="$subst8" />
1101 <xsl:with-param name="replace" select="'µ'" />
1102 <xsl:with-param name="with" select="'$\mu$'" />
1103 <xsl:with-param name="disable-output-escaping" select="no" />
1104 </xsl:call-template>
1105 </xsl:variable>
1106 <xsl:variable name="subst10">
1107 <xsl:call-template name="str:subst">
1108 <xsl:with-param name="text" select="$subst9" />
1109 <xsl:with-param name="replace" select="'®'" />
1110 <xsl:with-param name="with" select="'\texorpdfstring{\textregistered}{}'" />
1111 <xsl:with-param name="disable-output-escaping" select="no" />
1112 </xsl:call-template>
1113 </xsl:variable>
1114 <xsl:variable name="quote">"</xsl:variable>
1115 <!-- preparation for pretty quotes: replace all double quotes _outside_ screen
1116 sections with "\QUOTE{}" strings, which the makefile will then replace
1117 with pretty quotes by invoking sed a few times. Unfortunately there are
1118 no regular expressions in XSLT so there's no other way. -->
1119 <xsl:variable name="subst11">
1120 <xsl:choose>
1121 <xsl:when test="(name(..)='screen') or (name(../..)='screen')
1122 or (name(..)='programlisting') or (name(../..)='programlisting')
1123 ">
1124 <xsl:value-of select="$subst10" />
1125 </xsl:when>
1126 <xsl:otherwise>
1127 <xsl:call-template name="str:subst">
1128 <xsl:with-param name="text" select="$subst10" />
1129 <xsl:with-param name="replace" select="$quote" />
1130 <xsl:with-param name="with" select="'\QUOTE{}'" />
1131 <xsl:with-param name="disable-output-escaping" select="no" />
1132 </xsl:call-template>
1133 </xsl:otherwise>
1134 </xsl:choose>
1135 </xsl:variable>
1136 <xsl:variable name="subst12">
1137 <xsl:call-template name="str:subst">
1138 <xsl:with-param name="text" select="$subst11" />
1139 <xsl:with-param name="replace" select="'~'" />
1140 <xsl:with-param name="with" select="'\textasciitilde{}'" />
1141 <xsl:with-param name="disable-output-escaping" select="no" />
1142 </xsl:call-template>
1143 </xsl:variable>
1144 <xsl:variable name="subst13">
1145 <xsl:call-template name="str:subst">
1146 <xsl:with-param name="text" select="$subst12" />
1147 <xsl:with-param name="replace" select="'&amp;'" />
1148 <xsl:with-param name="with" select="'\&amp;'" />
1149 <xsl:with-param name="disable-output-escaping" select="no" />
1150 </xsl:call-template>
1151 </xsl:variable>
1152 <xsl:value-of select="$subst13" />
1153 </xsl:otherwise>
1154 </xsl:choose>
1155 </xsl:template>
1156
1157 <!--
1158 xsltprocNewlineOutputHack - emits a single new line.
1159
1160 Hack Alert! This template helps xsltproc split up the output text elements
1161 and avoid reallocating them into the MB range. Calls to this
1162 template is made occationally while generating larger output
1163 file. It's not necessary for small stuff like header.
1164
1165 The trick we're playing on xsltproc has to do with CDATA
1166 and/or the escape setting of the xsl:text element. It forces
1167 xsltproc to allocate a new output element, thus preventing
1168 things from growing out of proportions and slowing us down.
1169
1170 This was successfully employed to reduce a 18+ seconds run to
1171 around one second (possibly less due to kmk overhead).
1172 -->
1173 <xsl:template name="xsltprocNewlineOutputHack">
1174 <xsl:text disable-output-escaping="yes"><![CDATA[
1175]]></xsl:text>
1176 </xsl:template>
1177
1178</xsl:stylesheet>
1179
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette