VirtualBox

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

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

doc/manual: use the appropriate markup for the Preface, and make sure that the sections in it are unnumbered (a bit incomplete for the HTML/... case, but can be improved later), important fix for HTML manual as it restores the validity of the (per chapter) links to the HTML manual.

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