• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"
11                version="1.0">
12
13  <xsl:param name="html.stylesheet">
14    <xsl:choose>
15      <xsl:when test = "$boost.defaults = 'Boost'">
16        <xsl:value-of select = "concat($boost.root, '/doc/src/boostbook.css')"/>
17      </xsl:when>
18      <xsl:otherwise>
19        boostbook.css
20      </xsl:otherwise>
21    </xsl:choose>
22  </xsl:param>
23
24  <xsl:param name="boost.graphics.root">
25    <xsl:choose>
26      <xsl:when test = "$boost.defaults = 'Boost'">
27        <xsl:value-of select = "concat($boost.root, '/doc/src/images/')"/>
28      </xsl:when>
29      <xsl:otherwise>
30        <xsl:value-of select = "'images/'"/>
31      </xsl:otherwise>
32    </xsl:choose>
33  </xsl:param>
34
35  <xsl:param name="boost.mathjax" select="0"/>
36  <xsl:param name="boost.mathjax.script"
37             select="'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'"/>
38  <!--See usage below for explanation of this param-->
39  <xsl:param name="boost.noexpand.chapter.toc" select="0"/>
40  <!-- Currently just adds a viewport meta tag -->
41  <xsl:param name="boost.mobile" select="0"/>
42
43  <xsl:param name="admon.style"/>
44  <xsl:param name="admon.graphics">1</xsl:param>
45  <xsl:param name="boostbook.verbose" select="0"/>
46  <xsl:param name="navig.graphics" select="1"/>
47  <xsl:param name="navig.graphics.extension" select="'.png'"/>
48  <xsl:param name="chapter.autolabel" select="1"/>
49  <xsl:param name="use.id.as.filename" select="1"/>
50  <xsl:param name="refentry.generate.name" select="0"/>
51  <xsl:param name="refentry.generate.title" select="1"/>
52  <xsl:param name="make.year.ranges" select="1"/>
53  <xsl:param name="generate.manifest" select="1"/>
54  <xsl:param name="generate.section.toc.level" select="3"/>
55  <xsl:param name="doc.standalone">false</xsl:param>
56  <xsl:param name="chunker.output.indent">yes</xsl:param>
57  <xsl:param name="chunker.output.encoding">UTF-8</xsl:param>
58  <xsl:param name="chunk.quietly" select="not(number($boostbook.verbose))"/>
59  <xsl:param name="toc.max.depth">2</xsl:param>
60  <xsl:param name="callout.graphics.number.limit">15</xsl:param>
61  <xsl:param name = "admon.graphics.path" select="$boost.graphics.root" />
62  <xsl:param name = "navig.graphics.path" select="$boost.graphics.root" />
63  <xsl:param name = "callout.graphics.path"
64            select = "concat($boost.graphics.root, 'callouts/')"/>
65
66
67  <xsl:param name="admon.style">
68    <!-- Remove the style. Let the CSS do the styling -->
69</xsl:param>
70
71<!-- Always have graphics -->
72<xsl:param name="admon.graphics" select="1"/>
73
74  <xsl:param name="generate.toc">
75appendix  toc,title
76article/appendix  nop
77article   toc,title
78book      toc,title
79chapter   toc,title
80part      toc,title
81preface   toc,title
82qandadiv  toc
83qandaset  toc
84reference toc,title
85sect1     toc
86sect2     toc
87sect3     toc
88sect4     toc
89sect5     toc
90section   toc
91set       toc,title
92  </xsl:param>
93
94
95  <xsl:template name="format.cvs.revision">
96    <xsl:param name="text"/>
97
98    <!-- Remove the "$Date: " -->
99    <xsl:variable name="text.noprefix"
100      select="substring-after($text, '$Date: ')"/>
101
102    <!-- Grab the year -->
103    <xsl:variable name="year" select="substring-before($text.noprefix, '/')"/>
104    <xsl:variable name="text.noyear"
105      select="substring-after($text.noprefix, '/')"/>
106
107    <!-- Grab the month -->
108    <xsl:variable name="month" select="substring-before($text.noyear, '/')"/>
109    <xsl:variable name="text.nomonth"
110      select="substring-after($text.noyear, '/')"/>
111
112    <!-- Grab the year -->
113    <xsl:variable name="day" select="substring-before($text.nomonth, ' ')"/>
114    <xsl:variable name="text.noday"
115      select="substring-after($text.nomonth, ' ')"/>
116
117    <!-- Get the time -->
118    <xsl:variable name="time" select="substring-before($text.noday, ' ')"/>
119
120    <xsl:variable name="month.name">
121      <xsl:choose>
122        <xsl:when test="$month=1">January</xsl:when>
123        <xsl:when test="$month=2">February</xsl:when>
124        <xsl:when test="$month=3">March</xsl:when>
125        <xsl:when test="$month=4">April</xsl:when>
126        <xsl:when test="$month=5">May</xsl:when>
127        <xsl:when test="$month=6">June</xsl:when>
128        <xsl:when test="$month=7">July</xsl:when>
129        <xsl:when test="$month=8">August</xsl:when>
130        <xsl:when test="$month=9">September</xsl:when>
131        <xsl:when test="$month=10">October</xsl:when>
132        <xsl:when test="$month=11">November</xsl:when>
133        <xsl:when test="$month=12">December</xsl:when>
134      </xsl:choose>
135    </xsl:variable>
136
137    <xsl:value-of select="concat($month.name, ' ', $day, ', ', $year, ' at ',
138                                 $time, ' GMT')"/>
139  </xsl:template>
140
141
142  <xsl:template name="format.svn.revision">
143    <xsl:param name="text"/>
144
145    <!-- Remove the "$Date: " or "$Date:: " -->
146    <xsl:variable name="text.noprefix"
147      select="substring-after($text, ': ')"/>
148
149    <!-- Grab the year -->
150    <xsl:variable name="year" select="substring-before($text.noprefix, '-')"/>
151    <xsl:variable name="text.noyear"
152      select="substring-after($text.noprefix, '-')"/>
153
154    <!-- Grab the month -->
155    <xsl:variable name="month" select="substring-before($text.noyear, '-')"/>
156    <xsl:variable name="text.nomonth"
157      select="substring-after($text.noyear, '-')"/>
158
159    <!-- Grab the year -->
160    <xsl:variable name="day" select="substring-before($text.nomonth, ' ')"/>
161    <xsl:variable name="text.noday"
162      select="substring-after($text.nomonth, ' ')"/>
163
164    <!-- Get the time -->
165    <xsl:variable name="time" select="substring-before($text.noday, ' ')"/>
166    <xsl:variable name="text.notime"
167      select="substring-after($text.noday, ' ')"/>
168
169    <!-- Get the timezone -->
170    <xsl:variable name="timezone" select="substring-before($text.notime, ' ')"/>
171
172    <xsl:variable name="month.name">
173      <xsl:choose>
174        <xsl:when test="$month=1">January</xsl:when>
175        <xsl:when test="$month=2">February</xsl:when>
176        <xsl:when test="$month=3">March</xsl:when>
177        <xsl:when test="$month=4">April</xsl:when>
178        <xsl:when test="$month=5">May</xsl:when>
179        <xsl:when test="$month=6">June</xsl:when>
180        <xsl:when test="$month=7">July</xsl:when>
181        <xsl:when test="$month=8">August</xsl:when>
182        <xsl:when test="$month=9">September</xsl:when>
183        <xsl:when test="$month=10">October</xsl:when>
184        <xsl:when test="$month=11">November</xsl:when>
185        <xsl:when test="$month=12">December</xsl:when>
186      </xsl:choose>
187    </xsl:variable>
188
189    <xsl:value-of select="concat($month.name, ' ', $day, ', ', $year)"/>
190    <xsl:if test="$time != ''">
191      <xsl:value-of select="concat(' at ', $time, ' ', $timezone)"/>
192    </xsl:if>
193  </xsl:template>
194
195  <!-- Footer Copyright -->
196  <xsl:template match="copyright" mode="boost.footer">
197    <xsl:if test="position() &gt; 1">
198      <br/>
199    </xsl:if>
200    <xsl:call-template name="gentext">
201      <xsl:with-param name="key" select="'Copyright'"/>
202    </xsl:call-template>
203    <xsl:call-template name="gentext.space"/>
204    <xsl:call-template name="dingbat">
205      <xsl:with-param name="dingbat">copyright</xsl:with-param>
206    </xsl:call-template>
207    <xsl:call-template name="gentext.space"/>
208    <xsl:call-template name="copyright.years">
209      <xsl:with-param name="years" select="year"/>
210      <xsl:with-param name="print.ranges" select="$make.year.ranges"/>
211      <xsl:with-param name="single.year.ranges"
212        select="$make.single.year.ranges"/>
213    </xsl:call-template>
214    <xsl:call-template name="gentext.space"/>
215    <xsl:apply-templates select="holder" mode="titlepage.mode"/>
216  </xsl:template>
217
218  <!-- Footer License -->
219  <xsl:template match="legalnotice" mode="boost.footer">
220    <xsl:apply-templates select="para" mode="titlepage.mode" />
221  </xsl:template>
222
223  <xsl:template name="user.footer.content">
224    <table width="100%">
225      <tr>
226        <td align="left">
227          <xsl:variable name="revision-nodes"
228            select="ancestor-or-self::*
229                    [not (attribute::rev:last-revision='')]"/>
230          <xsl:if test="count($revision-nodes) &gt; 0">
231            <xsl:variable name="revision-node"
232              select="$revision-nodes[last()]"/>
233            <xsl:variable name="revision-text">
234              <xsl:value-of
235                select="normalize-space($revision-node/attribute::rev:last-revision)"/>
236            </xsl:variable>
237            <xsl:if test="string-length($revision-text) &gt; 0 and not($revision-text = '$Date$')">
238              <p>
239                <small>
240                  <xsl:text>Last revised: </xsl:text>
241                  <xsl:choose>
242                    <xsl:when test="not(contains($revision-text, '$Date: ')) and not(contains($revision-text, '$Date:: '))">
243                      <xsl:value-of select="$revision-text"/>
244                    </xsl:when>
245                    <xsl:when test="contains($revision-text, '/')">
246                      <xsl:call-template name="format.cvs.revision">
247                        <xsl:with-param name="text" select="$revision-text"/>
248                      </xsl:call-template>
249                    </xsl:when>
250                    <xsl:otherwise>
251                      <xsl:call-template name="format.svn.revision">
252                        <xsl:with-param name="text" select="$revision-text"/>
253                      </xsl:call-template>
254                    </xsl:otherwise>
255                  </xsl:choose>
256                </small>
257              </p>
258            </xsl:if>
259          </xsl:if>
260        </td>
261        <td align="right">
262          <div class = "copyright-footer">
263            <xsl:apply-templates select="ancestor::*/*/copyright"
264              mode="boost.footer"/>
265            <xsl:apply-templates select="ancestor::*/*/legalnotice"
266              mode="boost.footer"/>
267          </div>
268        </td>
269      </tr>
270    </table>
271  </xsl:template>
272
273  <!-- We don't want refentry's to show up in the TOC because they
274       will merely be redundant with the synopsis. -->
275  <xsl:template match="refentry" mode="toc"/>
276
277  <!-- override the behaviour of some DocBook elements for better
278       rendering facilities -->
279
280  <xsl:template match = "programlisting[ancestor::informaltable]">
281     <pre class = "table-{name(.)}"><xsl:apply-templates/></pre>
282  </xsl:template>
283
284  <xsl:template match = "refsynopsisdiv">
285     <h2 class = "{name(.)}-title">Synopsis</h2>
286     <div class = "{name(.)}">
287        <xsl:apply-templates/>
288     </div>
289  </xsl:template>
290
291  <xsl:template name="generate.html.title"/>
292
293  <xsl:template match="*" mode="detect-math">
294    <xsl:variable name="is-chunk">
295      <xsl:call-template name="chunk"/>
296    </xsl:variable>
297    <xsl:if test="$is-chunk = '0'">
298      <xsl:apply-templates mode="detect-math"/>
299    </xsl:if>
300  </xsl:template>
301
302  <xsl:template match="text()" mode="detect-math"/>
303
304  <xsl:template match="textobject[@role='tex']" mode="detect-math">
305    <xsl:text>1</xsl:text>
306  </xsl:template>
307
308  <xsl:template name="user.head.content">
309    <xsl:if test="$boost.mathjax = 1">
310      <xsl:variable name="has-math">
311        <xsl:apply-templates mode="detect-math" select="*"/>
312      </xsl:variable>
313      <xsl:if test="string($has-math) != ''">
314        <script type="text/javascript" src="{$boost.mathjax.script}"/>
315      </xsl:if>
316    </xsl:if>
317    <xsl:if test="$boost.mobile = 1">
318      <meta name="viewport" content="width=device-width"/>
319    </xsl:if>
320  </xsl:template>
321
322  <xsl:template match="inlinemediaobject">
323    <xsl:choose>
324      <xsl:when test="$boost.mathjax = 1 and textobject[@role='tex']">
325        <xsl:variable name="content" select="string(textobject[@role='tex'])"/>
326        <xsl:variable name="plain-content">
327          <xsl:choose>
328            <!--strip $$-->
329            <xsl:when test="substring($content, 1, 1) = '$' and
330                            substring($content, string-length($content), 1) = '$'">
331              <xsl:value-of select="substring($content, 2, string-length($content) - 2)"/>
332            </xsl:when>
333            <xsl:otherwise>
334              <xsl:value-of select="$content"/>
335            </xsl:otherwise>
336          </xsl:choose>
337        </xsl:variable>
338        <script type="math/tex">
339          <xsl:value-of select="$plain-content"/>
340        </script>
341        <noscript>
342          <xsl:apply-imports/>
343        </noscript>
344      </xsl:when>
345      <xsl:otherwise>
346        <xsl:apply-imports/>
347      </xsl:otherwise>
348    </xsl:choose>
349  </xsl:template>
350
351<!-- ============================================================ -->
352
353<xsl:template name="output.html.stylesheets">
354    <xsl:param name="stylesheets" select="''"/>
355
356    <xsl:choose>
357        <xsl:when test="contains($stylesheets, ' ')">
358            <link rel="stylesheet">
359                <xsl:attribute name="href">
360                    <xsl:call-template name="href.target.relative">
361                        <xsl:with-param name="target" select="substring-before($stylesheets, ' ')"/>
362                    </xsl:call-template>
363                </xsl:attribute>
364                <xsl:if test="$html.stylesheet.type != ''">
365                    <xsl:attribute name="type">
366                        <xsl:value-of select="$html.stylesheet.type"/>
367                    </xsl:attribute>
368                </xsl:if>
369            </link>
370            <xsl:call-template name="output.html.stylesheets">
371                <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/>
372            </xsl:call-template>
373        </xsl:when>
374        <xsl:when test="$stylesheets != ''">
375            <link rel="stylesheet">
376                <xsl:attribute name="href">
377                    <xsl:call-template name="href.target.relative">
378                        <xsl:with-param name="target" select="$stylesheets"/>
379                    </xsl:call-template>
380                </xsl:attribute>
381                <xsl:if test="$html.stylesheet.type != ''">
382                    <xsl:attribute name="type">
383                        <xsl:value-of select="$html.stylesheet.type"/>
384                    </xsl:attribute>
385                </xsl:if>
386            </link>
387        </xsl:when>
388    </xsl:choose>
389</xsl:template>
390
391<xsl:template match="itemizedlist[@role = 'index']" mode="class.value">
392   <xsl:value-of select="'index'"/>
393</xsl:template>
394
395<xsl:template match="sidebar[@role = 'blurb']" mode="class.value">
396   <xsl:value-of select="'blurb'"/>
397</xsl:template>
398
399<xsl:template match="preface|chapter|appendix|article" mode="toc">
400  <xsl:param name="toc-context" select="."/>
401
402  <!--
403      When boost.noexpand.chapter.toc is set to 1, then the TOC for
404      chapters is only one level deep (ie toc.max.depth has no effect)
405      and nested sections within chapters are not shown.  TOC's and LOC's
406      at other levels are not effected and respond to toc.max.depth as normal.
407  -->
408  <xsl:choose>
409    <xsl:when test="local-name($toc-context) = 'book' and $boost.noexpand.chapter.toc = 1">
410      <xsl:call-template name="subtoc">
411        <xsl:with-param name="toc-context" select="$toc-context"/>
412        <xsl:with-param name="nodes" select="foo"/>
413      </xsl:call-template>
414    </xsl:when>
415    <xsl:otherwise>
416      <xsl:call-template name="subtoc">
417        <xsl:with-param name="toc-context" select="$toc-context"/>
418        <xsl:with-param name="nodes"
419              select="section|sect1|glossary|bibliography|index
420                     |bridgehead[$bridgehead.in.toc != 0]"/>
421      </xsl:call-template>
422    </xsl:otherwise>
423  </xsl:choose>
424</xsl:template>
425
426</xsl:stylesheet>
427
428
429