1 <?xml version="1.0" encoding="utf-8"?>
3 Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
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)
9 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:xi="http://www.w3.org/2001/XInclude"
12 <xsl:include href="reference.xsl"/>
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"/>
18 <!-- The maximum number of columns allowed in preformatted text -->
19 <xsl:param name="max-columns" select="78"/>
21 <!-- The root of the Boost directory -->
22 <xsl:param name="boost.root" select="'../..'"/>
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="''"/>
28 <!-- Whether to rewrite relative URL's to point to the website -->
29 <xsl:param name="boost.url.prefix"/>
31 <!-- A space-separated list of xml elements in the input file for which
32 whitespace should be preserved -->
33 <xsl:preserve-space elements="*"/>
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>
41 <xsl:value-of select="$boost.root"/>
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)"/>
49 <xsl:if test="($boost.url.prefix = '') or contains($boost.root, '://')">
50 <xsl:value-of select="$boost.root"/>
54 <xsl:template match="library-reference">
56 <xsl:when test="ancestor::library-reference">
57 <xsl:apply-templates/>
63 <xsl:attribute name="id">
64 <xsl:value-of select="@id"/>
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>
74 <xsl:if test="not(title)">
76 <xsl:text>Reference</xsl:text>
80 <xsl:if test="concept">
84 <xsl:attribute name="id">
85 <xsl:value-of select="@id"/>
86 <xsl:text>.concepts</xsl:text>
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>
97 <title>Concepts</title>
100 <xsl:for-each select="concept">
102 <xsl:call-template name="internal-link">
103 <xsl:with-param name="to">
104 <xsl:call-template name="generate.id"/>
106 <xsl:with-param name="text" select="@name"/>
108 </simpara></listitem>
114 <xsl:apply-templates/>
120 <xsl:template match="header">
123 <xsl:attribute name="id">
124 <xsl:call-template name="generate.id"/>
128 <xsl:text>Header <</xsl:text>
130 <xsl:attribute name="url">
131 <xsl:value-of select="$boost.header.root"/>
132 <xsl:text>/</xsl:text>
133 <xsl:value-of select="@name"/>
135 <xsl:value-of select="@name"/>
137 <xsl:text>></xsl:text>
140 <xsl:apply-templates select="para|section" mode="annotation"/>
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>
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
163 <xsl:with-param name="indentation" select="0"/>
164 </xsl:apply-templates>
169 <xsl:apply-templates mode="namespace-reference"/>
174 <xsl:template match="header" mode="generate.id">
175 <xsl:text>header.</xsl:text>
176 <xsl:value-of select="translate(@name, '/.', '._')"/>
179 <xsl:template match="*" mode="passthrough">
180 <xsl:copy-of select="."/>
183 <xsl:template name="monospaced">
184 <xsl:param name="text"/>
185 <computeroutput><xsl:value-of select="$text"/></computeroutput>
189 <xsl:template match="ulink">
191 <xsl:copy-of select="@*"/>
192 <xsl:attribute name="url">
194 <xsl:when test="starts-with(@url, 'boost:/')">
195 <xsl:value-of select="concat($boost.protocol.text, substring-after(@url, 'boost:'))"/>
197 <xsl:when test="starts-with(@url, 'boost:')">
198 <xsl:value-of select="concat($boost.protocol.text, '/', substring-after(@url, 'boost:'))"/>
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)"/>
204 <xsl:value-of select="@url"/>
208 <xsl:apply-templates/>
211 <xsl:template name="internal-link">
212 <xsl:param name="to"/>
213 <xsl:param name="text"/>
214 <xsl:param name="highlight" select="false()"/>
216 <link linkend="{$to}">
217 <xsl:if test="$highlight">
218 <xsl:call-template name="source-highlight">
219 <xsl:with-param name="text" select="$text"/>
222 <xsl:if test="not($highlight)">
223 <xsl:value-of select="string($text)"/>
228 <xsl:template name="anchor">
229 <xsl:param name="to"/>
230 <xsl:param name="text"/>
231 <xsl:param name="highlight" select="false()"/>
234 <xsl:if test="$highlight">
235 <xsl:call-template name="source-highlight">
236 <xsl:with-param name="text" select="$text"/>
239 <xsl:if test="not($highlight)">
240 <xsl:value-of select="$text"/>
244 <xsl:template name="link-or-anchor">
245 <xsl:param name="to"/>
246 <xsl:param name="text"/>
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"/>
254 <!-- 'anchor', 'link', or 'none' -->
255 <xsl:param name="link-type">
257 <xsl:when test="$is-anchor">
258 <xsl:text>anchor</xsl:text>
261 <xsl:text>link</xsl:text>
266 <xsl:param name="highlight" select="false()"/>
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"/>
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"/>
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"/>
289 <xsl:if test="not($highlight)">
290 <xsl:value-of select="$text"/>
295 Error: XSL template 'link-or-anchor' called with invalid link-type '<xsl:value-of select="$link-type"/>'
301 <xsl:template name="separator"/>
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"/>
311 <refentry id="{$anchor}">
313 <refentrytitle><xsl:value-of select="$name"/></refentrytitle>
314 <manvolnum>3</manvolnum>
317 <refname><xsl:value-of select="$refname"/></refname>
319 <xsl:apply-templates mode="purpose" select="$purpose"/>
324 <xsl:copy-of select="$synopsis"/>
327 <xsl:if test="not(string($text)='')">
329 <title>Description</title>
330 <xsl:copy-of select="$text"/>
336 <xsl:template name="member-documentation">
337 <xsl:param name="name"/>
338 <xsl:param name="text"/>
341 <title><xsl:copy-of select="$name"/></title>
342 <xsl:copy-of select="$text"/>
346 <xsl:template name="preformatted">
347 <xsl:param name="text"/>
349 <literallayout class="monospaced">
350 <xsl:copy-of select="$text"/>
354 <xsl:template name="synopsis">
355 <xsl:param name="text"/>
358 <xsl:copy-of select="$text"/>
362 <!-- Fallthrough for DocBook elements -->
363 <xsl:template match="*">
364 <xsl:element name="{name(.)}">
365 <xsl:for-each select="./@*">
367 <xsl:when test="local-name(.)='last-revision'">
369 name="rev:last-revision"
370 namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision">
371 <xsl:value-of select="."/>
375 <xsl:attribute name="{name(.)}">
376 <xsl:value-of select="."/>
381 <xsl:apply-templates/>
385 <xsl:template match="processing-instruction()">
389 <xsl:template match="code">
391 <xsl:apply-templates mode="annotation"/>
395 <xsl:template match="code[@language='jam']">
397 <xsl:apply-templates mode="highlight-jam"/>
401 <xsl:template match="code[@language='c++']">
402 <xsl:apply-templates select="." mode="annotation"/>
405 <xsl:template match="bold">
406 <emphasis role="bold">
407 <xsl:apply-templates mode="annotation"/>
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))">
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"/>
423 <xsl:if test="@last-revision">
425 name="rev:last-revision"
426 namespace="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision">
427 <xsl:value-of select="@last-revision"/>
430 <xsl:apply-templates/>
435 <xsl:template match="chapter">
436 <xsl:if test="$boost.include.libraries=''">
438 <xsl:copy-of select="./@*" />
439 <xsl:apply-templates/>
444 <xsl:template match="boostbook">
446 <xsl:copy-of select="@*[not(contains(' last-revision name dirname html-only url ', concat(' ',local-name(),' ')))]"/>
447 <xsl:apply-templates/>
451 <xsl:template match="programlisting">
452 <programlisting><xsl:apply-templates/></programlisting>
455 <xsl:template match="programlisting[@language='jam']">
457 <xsl:apply-templates mode="highlight-jam"/>
461 <xsl:template match="programlisting[@language='c++']">
462 <xsl:apply-templates select="." mode="annotation"/>
465 <!-- These DocBook elements have special meaning. Use the annotation mode -->
466 <xsl:template match="classname|methodname|functionname|enumname|
467 macroname|headername|globalname">
469 <xsl:apply-templates select="." mode="annotation"/>
473 <xsl:template match="libraryname|conceptname">
474 <xsl:apply-templates select="." mode="annotation"/>
477 <xsl:template match="description">
478 <xsl:apply-templates mode="annotation"/>
481 <!-- Swallow using-namespace and using-class directives along with
482 last-revised elements -->
483 <xsl:template match="using-namespace|using-class|last-revised"/>
485 <!-- If there is no "namespace-reference" mode, forward to
487 <xsl:template match="*" mode="namespace-reference">
488 <xsl:apply-templates select="." mode="reference"/>
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">
496 <xsl:copy-of select="./@*"/>
497 <xsl:apply-templates/>
500 <xsl:template match="part/part/partinfo|part/article/articleinfo">
501 <chapterinfo><xsl:apply-templates/></chapterinfo>
503 <xsl:template match="part/part/chapter|part/part/appendix">
505 <xsl:copy-of select="./@*"/>
506 <xsl:apply-templates/>
509 <xsl:template match="part/part/chapter/chapterinfo|part/part/appendix/appendixinfo">
510 <sectioninfo><xsl:apply-templates/></sectioninfo>
513 <!-- Header link comment to be inserted at the start of a reference page's
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: <</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]"/>
526 <xsl:with-param name="text" select="ancestor::header[1]/@name" />
528 <xsl:text>> </xsl:text>