]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/boostbook/xsl/docbook.xsl
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / tools / boostbook / xsl / docbook.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
4
5 Distributed under the Boost Software License, Version 1.0.
6 (See accompanying file LICENSE_1_0.txt or copy at
7 http://www.boost.org/LICENSE_1_0.txt)
8 -->
9 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:xi="http://www.w3.org/2001/XInclude"
11 version="1.0">
12 <xsl:include href="reference.xsl"/>
13
14 <xsl:output method="xml"
15 doctype-public="-//OASIS//DTD DocBook XML V4.2//EN"
16 doctype-system="http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"/>
17
18 <!-- The maximum number of columns allowed in preformatted text -->
19 <xsl:param name="max-columns" select="78"/>
20
21 <!-- The root of the Boost directory -->
22 <xsl:param name="boost.root" select="'../..'"/>
23
24 <!-- A space-separated list of libraries to include in the
25 output. If this list is empty, all libraries will be included. -->
26 <xsl:param name="boost.include.libraries" select="''"/>
27
28 <!-- Whether to rewrite relative URL's to point to the website -->
29 <xsl:param name="boost.url.prefix"/>
30
31 <!-- A space-separated list of xml elements in the input file for which
32 whitespace should be preserved -->
33 <xsl:preserve-space elements="*"/>
34
35 <!-- The root for boost headers -->
36 <xsl:param name="boost.header.root">
37 <xsl:if test="$boost.url.prefix">
38 <xsl:value-of select="$boost.url.prefix"/>
39 <xsl:text>/</xsl:text>
40 </xsl:if>
41 <xsl:value-of select="$boost.root"/>
42 </xsl:param>
43
44 <!-- The prefix for 'boost:' links. -->
45 <xsl:variable name="boost.protocol.text">
46 <xsl:if test="($boost.url.prefix != '') and (contains($boost.root, '://') = 0)">
47 <xsl:value-of select="concat($boost.url.prefix, '/', $boost.root)"/>
48 </xsl:if>
49 <xsl:if test="($boost.url.prefix = '') or contains($boost.root, '://')">
50 <xsl:value-of select="$boost.root"/>
51 </xsl:if>
52 </xsl:variable>
53
54 <xsl:template match="library-reference">
55 <xsl:choose>
56 <xsl:when test="ancestor::library-reference">
57 <xsl:apply-templates/>
58 </xsl:when>
59 <xsl:otherwise>
60 <section>
61 <xsl:choose>
62 <xsl:when test="@id">
63 <xsl:attribute name="id">
64 <xsl:value-of select="@id"/>
65 </xsl:attribute>
66 </xsl:when>
67 <xsl:when test="ancestor::library/attribute::id">
68 <xsl:attribute name="id">
69 <xsl:value-of select="ancestor::library/attribute::id"/>
70 <xsl:text>.reference</xsl:text>
71 </xsl:attribute>
72 </xsl:when>
73 </xsl:choose>
74 <xsl:if test="not(title)">
75 <title>
76 <xsl:text>Reference</xsl:text>
77 </title>
78 </xsl:if>
79
80 <xsl:if test="concept">
81 <section>
82 <xsl:choose>
83 <xsl:when test="@id">
84 <xsl:attribute name="id">
85 <xsl:value-of select="@id"/>
86 <xsl:text>.concepts</xsl:text>
87 </xsl:attribute>
88 </xsl:when>
89 <xsl:when test="ancestor::library/attribute::id">
90 <xsl:attribute name="id">
91 <xsl:value-of select="ancestor::library/attribute::id"/>
92 <xsl:text>.concepts</xsl:text>
93 </xsl:attribute>
94 </xsl:when>
95 </xsl:choose>
96
97 <title>Concepts</title>
98
99 <itemizedlist>
100 <xsl:for-each select="concept">
101 <listitem><simpara>
102 <xsl:call-template name="internal-link">
103 <xsl:with-param name="to">
104 <xsl:call-template name="generate.id"/>
105 </xsl:with-param>
106 <xsl:with-param name="text" select="@name"/>
107 </xsl:call-template>
108 </simpara></listitem>
109 </xsl:for-each>
110 </itemizedlist>
111 </section>
112 </xsl:if>
113
114 <xsl:apply-templates/>
115 </section>
116 </xsl:otherwise>
117 </xsl:choose>
118 </xsl:template>
119
120 <xsl:template match="header">
121 <xsl:if test="*">
122 <section>
123 <xsl:attribute name="id">
124 <xsl:call-template name="generate.id"/>
125 </xsl:attribute>
126
127 <title>
128 <xsl:text>Header &lt;</xsl:text>
129 <ulink>
130 <xsl:attribute name="url">
131 <xsl:value-of select="$boost.header.root"/>
132 <xsl:text>/</xsl:text>
133 <xsl:value-of select="@name"/>
134 </xsl:attribute>
135 <xsl:value-of select="@name"/>
136 </ulink>
137 <xsl:text>&gt;</xsl:text>
138 </title>
139
140 <xsl:apply-templates select="para|section" mode="annotation"/>
141
142 <xsl:if test="macro">
143 <xsl:call-template name="synopsis">
144 <xsl:with-param name="text">
145 <xsl:apply-templates mode="synopsis" select="macro">
146 <xsl:with-param name="indentation" select="0"/>
147 </xsl:apply-templates>
148 </xsl:with-param>
149 </xsl:call-template>
150 </xsl:if>
151
152 <xsl:if test="descendant::class|descendant::struct|descendant::union
153 |descendant::function|descendant::free-function-group
154 |descendant::overloaded-function|descendant::enum
155 |descendant::typedef">
156 <xsl:call-template name="synopsis">
157 <xsl:with-param name="text">
158 <xsl:apply-templates mode="synopsis"
159 select="namespace|class|struct|union
160 |function|free-function-group
161 |overloaded-function|enum
162 |typedef">
163 <xsl:with-param name="indentation" select="0"/>
164 </xsl:apply-templates>
165 </xsl:with-param>
166 </xsl:call-template>
167 </xsl:if>
168
169 <xsl:apply-templates mode="namespace-reference"/>
170 </section>
171 </xsl:if>
172 </xsl:template>
173
174 <xsl:template match="header" mode="generate.id">
175 <xsl:text>header.</xsl:text>
176 <xsl:value-of select="translate(@name, '/.', '._')"/>
177 </xsl:template>
178
179 <xsl:template match="*" mode="passthrough">
180 <xsl:copy-of select="."/>
181 </xsl:template>
182
183 <xsl:template name="monospaced">
184 <xsl:param name="text"/>
185 <computeroutput><xsl:value-of select="$text"/></computeroutput>
186 </xsl:template>
187
188 <!-- Linking -->
189 <xsl:template match="ulink">
190 <xsl:copy>
191 <xsl:copy-of select="@*"/>
192 <xsl:attribute name="url">
193 <xsl:choose>
194 <xsl:when test="starts-with(@url, 'boost:/')">
195 <xsl:value-of select="concat($boost.protocol.text, substring-after(@url, 'boost:'))"/>
196 </xsl:when>
197 <xsl:when test="starts-with(@url, 'boost:')">
198 <xsl:value-of select="concat($boost.protocol.text, '/', substring-after(@url, 'boost:'))"/>
199 </xsl:when>
200 <xsl:when test="$boost.url.prefix != '' and not(contains(@url, ':') or starts-with(@url, '//'))">
201 <xsl:value-of select="concat($boost.url.prefix, '/', @url)"/>
202 </xsl:when>
203 <xsl:otherwise>
204 <xsl:value-of select="@url"/>
205 </xsl:otherwise>
206 </xsl:choose>
207 </xsl:attribute>
208 <xsl:apply-templates/>
209 </xsl:copy>
210 </xsl:template>
211 <xsl:template name="internal-link">
212 <xsl:param name="to"/>
213 <xsl:param name="text"/>
214 <xsl:param name="highlight" select="false()"/>
215
216 <link linkend="{$to}">
217 <xsl:if test="$highlight">
218 <xsl:call-template name="source-highlight">
219 <xsl:with-param name="text" select="$text"/>
220 </xsl:call-template>
221 </xsl:if>
222 <xsl:if test="not($highlight)">
223 <xsl:value-of select="string($text)"/>
224 </xsl:if>
225 </link>
226 </xsl:template>
227
228 <xsl:template name="anchor">
229 <xsl:param name="to"/>
230 <xsl:param name="text"/>
231 <xsl:param name="highlight" select="false()"/>
232
233 <anchor id="{$to}"/>
234 <xsl:if test="$highlight">
235 <xsl:call-template name="source-highlight">
236 <xsl:with-param name="text" select="$text"/>
237 </xsl:call-template>
238 </xsl:if>
239 <xsl:if test="not($highlight)">
240 <xsl:value-of select="$text"/>
241 </xsl:if>
242 </xsl:template>
243
244 <xsl:template name="link-or-anchor">
245 <xsl:param name="to"/>
246 <xsl:param name="text"/>
247
248 <!-- True if we should create an anchor, otherwise we will create
249 a link. If you require more control (e.g., with the possibility of
250 having no link or anchor), set link-type instead: if present, it
251 takes precedence. -->
252 <xsl:param name="is-anchor"/>
253
254 <!-- 'anchor', 'link', or 'none' -->
255 <xsl:param name="link-type">
256 <xsl:choose>
257 <xsl:when test="$is-anchor">
258 <xsl:text>anchor</xsl:text>
259 </xsl:when>
260 <xsl:otherwise>
261 <xsl:text>link</xsl:text>
262 </xsl:otherwise>
263 </xsl:choose>
264 </xsl:param>
265
266 <xsl:param name="highlight" select="false()"/>
267
268 <xsl:choose>
269 <xsl:when test="$link-type='anchor'">
270 <xsl:call-template name="anchor">
271 <xsl:with-param name="to" select="$to"/>
272 <xsl:with-param name="text" select="$text"/>
273 <xsl:with-param name="highlight" select="$highlight"/>
274 </xsl:call-template>
275 </xsl:when>
276 <xsl:when test="$link-type='link'">
277 <xsl:call-template name="internal-link">
278 <xsl:with-param name="to" select="$to"/>
279 <xsl:with-param name="text" select="$text"/>
280 <xsl:with-param name="highlight" select="$highlight"/>
281 </xsl:call-template>
282 </xsl:when>
283 <xsl:when test="$link-type='none'">
284 <xsl:if test="$highlight">
285 <xsl:call-template name="source-highlight">
286 <xsl:with-param name="text" select="$text"/>
287 </xsl:call-template>
288 </xsl:if>
289 <xsl:if test="not($highlight)">
290 <xsl:value-of select="$text"/>
291 </xsl:if>
292 </xsl:when>
293 <xsl:otherwise>
294 <xsl:message>
295 Error: XSL template 'link-or-anchor' called with invalid link-type '<xsl:value-of select="$link-type"/>'
296 </xsl:message>
297 </xsl:otherwise>
298 </xsl:choose>
299 </xsl:template>
300
301 <xsl:template name="separator"/>
302
303 <xsl:template name="reference-documentation">
304 <xsl:param name="name"/>
305 <xsl:param name="refname"/>
306 <xsl:param name="purpose"/>
307 <xsl:param name="anchor"/>
308 <xsl:param name="synopsis"/>
309 <xsl:param name="text"/>
310
311 <refentry id="{$anchor}">
312 <refmeta>
313 <refentrytitle><xsl:value-of select="$name"/></refentrytitle>
314 <manvolnum>3</manvolnum>
315 </refmeta>
316 <refnamediv>
317 <refname><xsl:value-of select="$refname"/></refname>
318 <refpurpose>
319 <xsl:apply-templates mode="purpose" select="$purpose"/>
320 </refpurpose>
321 </refnamediv>
322 <refsynopsisdiv>
323 <synopsis>
324 <xsl:copy-of select="$synopsis"/>
325 </synopsis>
326 </refsynopsisdiv>
327 <xsl:if test="not(string($text)='')">
328 <refsect1>
329 <title>Description</title>
330 <xsl:copy-of select="$text"/>
331 </refsect1>
332 </xsl:if>
333 </refentry>
334 </xsl:template>
335
336 <xsl:template name="member-documentation">
337 <xsl:param name="name"/>
338 <xsl:param name="text"/>
339
340 <refsect2>
341 <title><xsl:copy-of select="$name"/></title>
342 <xsl:copy-of select="$text"/>
343 </refsect2>
344 </xsl:template>
345
346 <xsl:template name="preformatted">
347 <xsl:param name="text"/>
348
349 <literallayout class="monospaced">
350 <xsl:copy-of select="$text"/>
351 </literallayout>
352 </xsl:template>
353
354 <xsl:template name="synopsis">
355 <xsl:param name="text"/>
356
357 <synopsis>
358 <xsl:copy-of select="$text"/>
359 </synopsis>
360 </xsl:template>
361
362 <!-- Fallthrough for DocBook elements -->
363 <xsl:template match="*">
364 <xsl:element name="{name(.)}">
365 <xsl:for-each select="./@*">
366 <xsl:choose>
367 <xsl:when test="local-name(.)='last-revision'">
368 <xsl:attribute
369 name="rev:last-revision"
370 namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision">
371 <xsl:value-of select="."/>
372 </xsl:attribute>
373 </xsl:when>
374 <xsl:otherwise>
375 <xsl:attribute name="{name(.)}">
376 <xsl:value-of select="."/>
377 </xsl:attribute>
378 </xsl:otherwise>
379 </xsl:choose>
380 </xsl:for-each>
381 <xsl:apply-templates/>
382 </xsl:element>
383 </xsl:template>
384
385 <xsl:template match="processing-instruction()">
386 <xsl:copy/>
387 </xsl:template>
388
389 <xsl:template match="code">
390 <computeroutput>
391 <xsl:apply-templates mode="annotation"/>
392 </computeroutput>
393 </xsl:template>
394
395 <xsl:template match="code[@language='jam']">
396 <computeroutput>
397 <xsl:apply-templates mode="highlight-jam"/>
398 </computeroutput>
399 </xsl:template>
400
401 <xsl:template match="code[@language='c++']">
402 <xsl:apply-templates select="." mode="annotation"/>
403 </xsl:template>
404
405 <xsl:template match="bold">
406 <emphasis role="bold">
407 <xsl:apply-templates mode="annotation"/>
408 </emphasis>
409 </xsl:template>
410
411 <xsl:template match="library">
412 <xsl:if test="not(@html-only = 1) and
413 ($boost.include.libraries='' or
414 contains($boost.include.libraries, @id))">
415 <chapter>
416 <xsl:copy-of select="@*[not(contains(' last-revision name dirname html-only url ', concat(' ',local-name(),' ')))]"/>
417 <xsl:if test="not(@id)">
418 <xsl:attribute name="id">
419 <xsl:call-template name="generate.id"/>
420 </xsl:attribute>
421 </xsl:if>
422
423 <xsl:if test="@last-revision">
424 <xsl:attribute
425 name="rev:last-revision"
426 namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision">
427 <xsl:value-of select="@last-revision"/>
428 </xsl:attribute>
429 </xsl:if>
430 <xsl:apply-templates/>
431 </chapter>
432 </xsl:if>
433 </xsl:template>
434
435 <xsl:template match="chapter">
436 <xsl:if test="$boost.include.libraries=''">
437 <chapter>
438 <xsl:copy-of select="./@*" />
439 <xsl:apply-templates/>
440 </chapter>
441 </xsl:if>
442 </xsl:template>
443
444 <xsl:template match="boostbook">
445 <book>
446 <xsl:copy-of select="@*[not(contains(' last-revision name dirname html-only url ', concat(' ',local-name(),' ')))]"/>
447 <xsl:apply-templates/>
448 </book>
449 </xsl:template>
450
451 <xsl:template match="programlisting">
452 <programlisting><xsl:apply-templates/></programlisting>
453 </xsl:template>
454
455 <xsl:template match="programlisting[@language='jam']">
456 <programlisting>
457 <xsl:apply-templates mode="highlight-jam"/>
458 </programlisting>
459 </xsl:template>
460
461 <xsl:template match="programlisting[@language='c++']">
462 <xsl:apply-templates select="." mode="annotation"/>
463 </xsl:template>
464
465 <!-- These DocBook elements have special meaning. Use the annotation mode -->
466 <xsl:template match="classname|methodname|functionname|enumname|
467 macroname|headername|globalname">
468 <computeroutput>
469 <xsl:apply-templates select="." mode="annotation"/>
470 </computeroutput>
471 </xsl:template>
472
473 <xsl:template match="libraryname|conceptname">
474 <xsl:apply-templates select="." mode="annotation"/>
475 </xsl:template>
476
477 <xsl:template match="description">
478 <xsl:apply-templates mode="annotation"/>
479 </xsl:template>
480
481 <!-- Swallow using-namespace and using-class directives along with
482 last-revised elements -->
483 <xsl:template match="using-namespace|using-class|last-revised"/>
484
485 <!-- If there is no "namespace-reference" mode, forward to
486 "reference" mode -->
487 <xsl:template match="*" mode="namespace-reference">
488 <xsl:apply-templates select="." mode="reference"/>
489 </xsl:template>
490
491 <!-- Make the various blocks immediately below a "part" be
492 "chapter"-s. Must also take into account turning
493 chapters within chpaters into sections. -->
494 <xsl:template match="part/part|part/article">
495 <chapter>
496 <xsl:copy-of select="./@*"/>
497 <xsl:apply-templates/>
498 </chapter>
499 </xsl:template>
500 <xsl:template match="part/part/partinfo|part/article/articleinfo">
501 <chapterinfo><xsl:apply-templates/></chapterinfo>
502 </xsl:template>
503 <xsl:template match="part/part/chapter|part/part/appendix">
504 <section>
505 <xsl:copy-of select="./@*"/>
506 <xsl:apply-templates/>
507 </section>
508 </xsl:template>
509 <xsl:template match="part/part/chapter/chapterinfo|part/part/appendix/appendixinfo">
510 <sectioninfo><xsl:apply-templates/></sectioninfo>
511 </xsl:template>
512
513 <!-- Header link comment to be inserted at the start of a reference page's
514 synopsis -->
515 <xsl:template name="header-link">
516 <xsl:if test="ancestor::header">
517 <xsl:call-template name="highlight-comment">
518 <xsl:with-param name="text">
519 <xsl:text>// In header: &lt;</xsl:text>
520 <xsl:call-template name="internal-link">
521 <xsl:with-param name="to">
522 <xsl:call-template name="generate.id">
523 <xsl:with-param name="node" select="ancestor::header[1]"/>
524 </xsl:call-template>
525 </xsl:with-param>
526 <xsl:with-param name="text" select="ancestor::header[1]/@name" />
527 </xsl:call-template>
528 <xsl:text>&gt;&#10;&#10;</xsl:text>
529 </xsl:with-param>
530 </xsl:call-template>
531 </xsl:if>
532 </xsl:template>
533 </xsl:stylesheet>
534