• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Copyright 2003 Douglas Gregor -->
3<!-- Distributed under the Boost Software License, Version 1.0. -->
4<!-- (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) -->
5
6<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7                xmlns:fo="http://www.w3.org/1999/XSL/Format"
8                version="1.0">
9
10  <!-- Import the FO stylesheet -->
11  <xsl:import
12    href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
13
14  <xsl:param name="chapter.autolabel" select="0"/>
15  <xsl:param name="refentry.generate.name" select="0"/>
16  <xsl:param name="refentry.generate.title" select="1"/>
17  <xsl:param name="fop1.extensions" select="1"/>
18  <xsl:param name="make.year.ranges" select="1"/>
19  <xsl:param name="ulink.show" select="0"/>
20
21
22  <!--
23  The following code sets which sections start new pages in the PDF document flow.
24
25  The parameter "boost.section.newpage.depth" set how far down the hierarchy the
26  page breaks go.  Defaults to 1 (the same as html chunking), in which case only
27  top level sections start a new page, set to a higher value to force nested sections
28  onto new pages as well.
29
30  For top level sections (level 1), we use "break-before" which forces the very first
31  section onto a separate page from the TOC.
32
33  For nested sections (level 2 and greater) we use "break-after" which keeps nested
34  sections together with their enclosing section (rationale: the enclosing section
35  often has nothing but a title, and no content except the nested sections, and we
36  don't want a page break right after a section title!).
37
38  For reference sections, we turn page breaks *off* by setting "refentry.pagebreak" to 0.
39  This is for the same reason we use "break-after" for nested sections - we want reference
40  entries to be on the same page as the title and synopsis which encloses them.  Ideally
41  we'd use "break-after" here too, but I can't find an easy to to fix that.
42
43  Finally note that TOC's and Indexes don't get page breaks forced after them.
44  Again there's no easy fix here, *except* for the top level TOC which gets a page break
45  after it thanks to the "break-before" on level 1 sections.  Unfortunately this means
46  there's no break after the last section and before the first Index, *unless* the
47  final section has nested sections which may then trigger one!
48
49  We could fix all this by cut-and-pasting the relevant XSL from the stylesheets to here
50  and making sure everything uses "break-after", but whether it's worth it is questionable...?
51
52  -->
53
54  <xsl:param name="boost.section.newpage.depth" select="1"/>
55  <xsl:param name="refentry.pagebreak" select="0"/>
56
57   <xsl:attribute-set name="section.level1.properties" use-attribute-sets="section.properties">
58      <xsl:attribute name="break-before">
59         <xsl:if test="($boost.section.newpage.depth &gt; 0)">
60            page
61         </xsl:if>
62         <xsl:if test="not($boost.section.newpage.depth &gt; 0)">
63            auto
64         </xsl:if>
65      </xsl:attribute>
66   </xsl:attribute-set>
67
68   <xsl:attribute-set name="section.level2.properties" use-attribute-sets="section.properties">
69      <xsl:attribute name="break-after">
70         <xsl:if test="($boost.section.newpage.depth &gt; 1)">
71            page
72         </xsl:if>
73         <xsl:if test="not($boost.section.newpage.depth &gt; 1)">
74            auto
75         </xsl:if>
76      </xsl:attribute>
77   </xsl:attribute-set>
78
79   <xsl:attribute-set name="section.level3.properties" use-attribute-sets="section.properties">
80      <xsl:attribute name="break-after">
81         <xsl:if test="($boost.section.newpage.depth &gt; 2)">
82            page
83         </xsl:if>
84         <xsl:if test="not($boost.section.newpage.depth &gt; 2)">
85            auto
86         </xsl:if>
87      </xsl:attribute>
88   </xsl:attribute-set>
89
90   <xsl:attribute-set name="section.level4.properties" use-attribute-sets="section.properties">
91      <xsl:attribute name="break-after">
92         <xsl:if test="($boost.section.newpage.depth &gt; 3)">
93            page
94         </xsl:if>
95         <xsl:if test="not($boost.section.newpage.depth &gt; 3)">
96            auto
97         </xsl:if>
98      </xsl:attribute>
99   </xsl:attribute-set>
100
101   <xsl:attribute-set name="section.level5.properties" use-attribute-sets="section.properties">
102      <xsl:attribute name="break-after">
103         <xsl:if test="($boost.section.newpage.depth &gt; 4)">
104            page
105         </xsl:if>
106         <xsl:if test="not($boost.section.newpage.depth &gt; 4)">
107            auto
108         </xsl:if>
109      </xsl:attribute>
110   </xsl:attribute-set>
111
112   <xsl:attribute-set name="section.level6.properties" use-attribute-sets="section.properties">
113      <xsl:attribute name="break-after">
114         <xsl:if test="($boost.section.newpage.depth &gt; 5)">
115            page
116         </xsl:if>
117         <xsl:if test="not($boost.section.newpage.depth &gt; 5)">
118            auto
119         </xsl:if>
120      </xsl:attribute>
121   </xsl:attribute-set>
122
123   <!-- The question and answer templates are copied here from the
124       1.61.3 DocBook XSL stylesheets so that we can eliminate the emission
125       of id attributes in the emitted fo:list-item-label elements. FOP
126       0.20.5 has problems with these id attributes, and they are otherwise
127       unused. -->
128<xsl:template match="question">
129  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
130
131  <xsl:variable name="entry.id">
132    <xsl:call-template name="object.id">
133      <xsl:with-param name="object" select="parent::*"/>
134    </xsl:call-template>
135  </xsl:variable>
136
137  <xsl:variable name="deflabel">
138    <xsl:choose>
139      <xsl:when test="ancestor-or-self::*[@defaultlabel]">
140        <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
141                              /@defaultlabel"/>
142      </xsl:when>
143      <xsl:otherwise>
144        <xsl:value-of select="$qanda.defaultlabel"/>
145      </xsl:otherwise>
146    </xsl:choose>
147  </xsl:variable>
148
149  <fo:list-item id="{$entry.id}" xsl:use-attribute-sets="list.item.spacing">
150    <fo:list-item-label end-indent="label-end()">
151      <xsl:choose>
152        <xsl:when test="$deflabel = 'none'">
153          <fo:block/>
154        </xsl:when>
155        <xsl:otherwise>
156          <fo:block>
157            <xsl:apply-templates select="." mode="label.markup"/>
158            <xsl:text>.</xsl:text> <!-- FIXME: Hack!!! This should be in the locale! -->
159          </fo:block>
160        </xsl:otherwise>
161      </xsl:choose>
162    </fo:list-item-label>
163    <fo:list-item-body start-indent="body-start()">
164      <xsl:choose>
165        <xsl:when test="$deflabel = 'none'">
166          <fo:block font-weight="bold">
167            <xsl:apply-templates select="*[local-name(.)!='label']"/>
168          </fo:block>
169        </xsl:when>
170        <xsl:otherwise>
171          <xsl:apply-templates select="*[local-name(.)!='label']"/>
172        </xsl:otherwise>
173      </xsl:choose>
174    </fo:list-item-body>
175  </fo:list-item>
176</xsl:template>
177
178<xsl:template match="answer">
179  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
180  <xsl:variable name="entry.id">
181    <xsl:call-template name="object.id">
182      <xsl:with-param name="object" select="parent::*"/>
183    </xsl:call-template>
184  </xsl:variable>
185
186  <xsl:variable name="deflabel">
187    <xsl:choose>
188      <xsl:when test="ancestor-or-self::*[@defaultlabel]">
189        <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
190                              /@defaultlabel"/>
191      </xsl:when>
192      <xsl:otherwise>
193        <xsl:value-of select="$qanda.defaultlabel"/>
194      </xsl:otherwise>
195    </xsl:choose>
196  </xsl:variable>
197
198  <fo:list-item xsl:use-attribute-sets="list.item.spacing">
199    <fo:list-item-label end-indent="label-end()">
200      <xsl:choose>
201        <xsl:when test="$deflabel = 'none'">
202          <fo:block/>
203        </xsl:when>
204        <xsl:otherwise>
205          <fo:block>
206            <!-- FIXME: Hack!!! This should be in the locale! -->
207            <xsl:variable name="answer.label">
208              <xsl:apply-templates select="." mode="label.markup"/>
209            </xsl:variable>
210            <xsl:copy-of select="$answer.label"/>
211            <xsl:if test="string($answer.label) != ''">
212              <xsl:text>.</xsl:text>
213            </xsl:if>
214          </fo:block>
215        </xsl:otherwise>
216      </xsl:choose>
217    </fo:list-item-label>
218    <fo:list-item-body start-indent="body-start()">
219      <xsl:apply-templates select="*[local-name(.)!='label']"/>
220    </fo:list-item-body>
221  </fo:list-item>
222</xsl:template>
223
224
225<!--
226
227  The following rules apply text coloring to Quickbook items like
228
229    [role blue Some blue text]
230
231  These correspond to an arbitrary list of colors added to the CSS file
232
233    $(BOOST-ROOT)\doc\src\boostbook.css
234
235  and are required for building pdf documentation.
236
237  A more elegant way of doing this is probably possible.
238  Other colors can be added simply by copying these examples.
239-->
240
241<xsl:template match="phrase[@role='red']">
242  <fo:inline color="red">
243    <xsl:apply-templates/>
244  </fo:inline>
245</xsl:template>
246
247<xsl:template match="phrase[@role='blue']">
248  <fo:inline color="blue">
249    <xsl:apply-templates/>
250  </fo:inline>
251</xsl:template>
252
253<xsl:template match="phrase[@role='green']">
254  <fo:inline color="green">
255    <xsl:apply-templates/>
256  </fo:inline>
257</xsl:template>
258<xsl:template match="phrase[@role='lime']">
259  <fo:inline color="lime">
260    <xsl:apply-templates/>
261  </fo:inline>
262</xsl:template>
263<xsl:template match="phrase[@role='navy']">
264  <fo:inline color="navy">
265    <xsl:apply-templates/>
266  </fo:inline>
267</xsl:template>
268<xsl:template match="phrase[@role='yellow']">
269  <fo:inline color="yellow">
270    <xsl:apply-templates/>
271  </fo:inline>
272</xsl:template>
273<xsl:template match="phrase[@role='magenta']">
274  <fo:inline color="magenta">
275    <xsl:apply-templates/>
276  </fo:inline>
277</xsl:template>
278
279<xsl:template match="phrase[@role='indigo']">
280  <fo:inline color="indigo">
281    <xsl:apply-templates/>
282  </fo:inline>
283</xsl:template>
284
285<xsl:template match="phrase[@role='cyan']">
286  <fo:inline color="cyan">
287    <xsl:apply-templates/>
288  </fo:inline>
289</xsl:template>
290
291<xsl:template match="phrase[@role='purple']">
292  <fo:inline color="purple">
293    <xsl:apply-templates/>
294  </fo:inline>
295</xsl:template>
296
297<xsl:template match="phrase[@role='gold']">
298  <fo:inline color="gold">
299    <xsl:apply-templates/>
300  </fo:inline>
301</xsl:template>
302
303<xsl:template match="phrase[@role='silver']">
304  <fo:inline color="silver">
305    <xsl:apply-templates/>
306  </fo:inline>
307</xsl:template>
308
309<xsl:template match="phrase[@role='gray']">
310  <fo:inline color="gray">
311    <xsl:apply-templates/>
312  </fo:inline>
313</xsl:template>
314
315<!-- alignment -->
316
317<xsl:template match="phrase[@role='aligncenter']">
318  <fo:inline>
319    <fo:block text-align="center">
320      <xsl:apply-templates/>
321    </fo:block>
322  </fo:inline>
323</xsl:template>
324
325<xsl:template match="phrase[@role='alignleft']">
326  <fo:inline>
327    <fo:block text-align="left">
328      <xsl:apply-templates/>
329    </fo:block>
330  </fo:inline>
331</xsl:template>
332
333<xsl:template match="phrase[@role='alignright']">
334  <fo:inline>
335    <fo:block text-align="right">
336     <xsl:apply-templates/>
337    </fo:block>
338  </fo:inline>
339</xsl:template>
340
341<xsl:template match="phrase[@role='alignjustify']">
342  <fo:inline>
343    <fo:block text-align="justify">
344     <xsl:apply-templates/>
345    </fo:block>
346  </fo:inline>
347</xsl:template>
348
349  <!--
350
351 The following rules apply syntax highlighting to phrases
352 that have been appropriately marked up, the highlighting
353 used is the same as that used by our CSS style sheets,
354 but potentially we have the option to do better here
355 since we can add bold and italic formatting quite easily
356
357 -->
358
359<xsl:template match="//phrase[@role='keyword' and
360                     (ancestor::programlisting or
361                      ancestor::synopsis or
362                      ancestor::literallayout)]">
363  <fo:inline color="#0000AA"><xsl:apply-templates/></fo:inline>
364</xsl:template>
365<xsl:template match="//phrase[@role='special' and
366                     (ancestor::programlisting or
367                      ancestor::synopsis or
368                      ancestor::literallayout)]">
369  <fo:inline color="#707070"><xsl:apply-templates/></fo:inline>
370</xsl:template>
371<xsl:template match="//phrase[@role='preprocessor' and
372                     (ancestor::programlisting or
373                      ancestor::synopsis or
374                      ancestor::literallayout)]">
375  <fo:inline color="#402080"><xsl:apply-templates/></fo:inline>
376</xsl:template>
377<xsl:template match="//phrase[@role='char' and
378                     (ancestor::programlisting or
379                      ancestor::synopsis or
380                      ancestor::literallayout)]">
381  <fo:inline color="teal"><xsl:apply-templates/></fo:inline>
382</xsl:template>
383<xsl:template match="//phrase[@role='comment' and
384                     (ancestor::programlisting or
385                      ancestor::synopsis or
386                      ancestor::literallayout)]">
387  <fo:inline color="#800000"><xsl:apply-templates/></fo:inline>
388</xsl:template>
389<xsl:template match="//phrase[@role='string' and
390                     (ancestor::programlisting or
391                      ancestor::synopsis or
392                      ancestor::literallayout)]">
393  <fo:inline color="teal"><xsl:apply-templates/></fo:inline>
394</xsl:template>
395<xsl:template match="//phrase[@role='number' and
396                     (ancestor::programlisting or
397                      ancestor::synopsis or
398                      ancestor::literallayout)]">
399  <fo:inline color="teal"><xsl:apply-templates/></fo:inline>
400</xsl:template>
401<xsl:template match="//phrase[@role='white_bkd' and
402                     (ancestor::programlisting or
403                      ancestor::synopsis or
404                      ancestor::literallayout)]">
405  <fo:inline color="#FFFFFF"><xsl:apply-templates/></fo:inline>
406</xsl:template>
407<xsl:template match="//phrase[@role='dk_grey_bkd' and
408                     (ancestor::programlisting or
409                      ancestor::synopsis or
410                      ancestor::literallayout)]">
411  <fo:inline color="#999999"><xsl:apply-templates/></fo:inline>
412</xsl:template>
413
414<!--
415Make all hyperlinks blue colored:
416-->
417<xsl:attribute-set name="xref.properties">
418  <xsl:attribute name="color">blue</xsl:attribute>
419</xsl:attribute-set>
420
421<!--
422Put a box around admonishments and keep them together:
423-->
424<xsl:attribute-set name="graphical.admonition.properties">
425  <xsl:attribute name="border-color">#FF8080</xsl:attribute>
426  <xsl:attribute name="border-width">1px</xsl:attribute>
427  <xsl:attribute name="border-style">solid</xsl:attribute>
428  <xsl:attribute name="padding-left">0.2cm</xsl:attribute>
429  <xsl:attribute name="padding-right">0.2cm</xsl:attribute>
430  <xsl:attribute name="padding-top">0.2cm</xsl:attribute>
431  <xsl:attribute name="padding-bottom">0.2cm</xsl:attribute>
432  <xsl:attribute name="keep-together.within-page">1</xsl:attribute>
433  <xsl:attribute name="margin-left">0pt</xsl:attribute>
434  <xsl:attribute name="margin-right">0pt</xsl:attribute>
435</xsl:attribute-set>
436
437<!--
438Put a box around code blocks, also set the font size
439and keep the block together if we can using the widows
440and orphans controls.  Hyphenation and line wrapping
441is also turned on, so that long lines of code don't
442bleed off the edge of the page, a carriage return
443symbol is used as the hyphenation character:
444-->
445<xsl:attribute-set name="monospace.verbatim.properties">
446  <xsl:attribute name="border-color">#DCDCDC</xsl:attribute>
447  <xsl:attribute name="border-width">1px</xsl:attribute>
448  <xsl:attribute name="border-style">solid</xsl:attribute>
449  <xsl:attribute name="padding-left">0.2cm</xsl:attribute>
450  <xsl:attribute name="padding-right">0.2cm</xsl:attribute>
451  <xsl:attribute name="padding-top">0.2cm</xsl:attribute>
452  <xsl:attribute name="padding-bottom">0.2cm</xsl:attribute>
453  <xsl:attribute name="widows">6</xsl:attribute>
454  <xsl:attribute name="orphans">40</xsl:attribute>
455  <xsl:attribute name="font-size">9pt</xsl:attribute>
456  <xsl:attribute name="hyphenate">true</xsl:attribute>
457  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
458  <xsl:attribute name="hyphenation-character">&#x21B5;</xsl:attribute>
459  <xsl:attribute name="margin-left">0pt</xsl:attribute>
460  <xsl:attribute name="margin-right">0pt</xsl:attribute>
461</xsl:attribute-set>
462
463<xsl:param name="hyphenate.verbatim" select="1"></xsl:param>
464<xsl:param name="monospace.font.family">monospace,Symbol</xsl:param>
465
466  <!--Regular monospace text should have the same font size as code blocks etc-->
467<xsl:attribute-set name="monospace.properties">
468  <xsl:attribute name="font-size">9pt</xsl:attribute>
469</xsl:attribute-set>
470
471<!--
472Put some small amount of padding around table cells, and keep tables
473together on one page if possible:
474-->
475<xsl:attribute-set name="table.cell.padding">
476  <xsl:attribute name="padding-left">0.2cm</xsl:attribute>
477  <xsl:attribute name="padding-right">0.2cm</xsl:attribute>
478  <xsl:attribute name="padding-top">0.2cm</xsl:attribute>
479  <xsl:attribute name="padding-bottom">0.2cm</xsl:attribute>
480</xsl:attribute-set>
481
482  <!--Formal and informal tables have the same properties
483      Using widow-and-orphan control here gives much better
484      results for very large tables than a simple "keep-together"
485      instruction-->
486<xsl:attribute-set name="table.properties">
487  <xsl:attribute name="keep-together.within-page">1</xsl:attribute>
488</xsl:attribute-set>
489<xsl:attribute-set name="informaltable.properties">
490  <xsl:attribute name="keep-together.within-page">1</xsl:attribute>
491</xsl:attribute-set>
492
493<!--
494General default options go here:
495* Borders are mid-grey.
496* Body text is not indented compared to the titles.
497* Page margins are a rather small 0.5in, but we need
498  all the space we can get for code blocks.
499* Paper size is A4: an ISO standard, slightly taller and narrower than US Letter.
500* Use SVG graphics for admonishments: the bitmaps look awful in PDF's.
501* Disable draft mode so we're not constantly trying to download the necessary graphic.
502* Set default image paths to pull down direct from SVN: individual Jamfiles can override this
503  and pass an absolute path to local versions of the images, but we can't get that here, so
504  we'll use SVN instead so that most things "just work".
505-->
506<xsl:param name="table.frame.border.color">#DCDCDC</xsl:param>
507<xsl:param name="table.cell.border.color">#DCDCDC</xsl:param>
508<xsl:param name="body.start.indent">0pt</xsl:param>
509<xsl:param name="page.margin.inner">0.5in</xsl:param>
510<xsl:param name="page.margin.outer">0.5in</xsl:param>
511<xsl:param name="paper.type">A4</xsl:param>
512<xsl:param name="admon.graphics">1</xsl:param>
513<xsl:param name="admon.graphics.extension">.svg</xsl:param>
514<xsl:param name="draft.mode">no</xsl:param>
515<xsl:param name="admon.graphics.path">http://www.boost.org/doc/libs/develop/doc/src/images/</xsl:param>
516<xsl:param name="callout.graphics.path">http://www.boost.org/doc/libs/develop/doc/src/images/callouts/</xsl:param>
517<xsl:param name="img.src.path">http://www.boost.org/doc/libs/devlop/doc/html/</xsl:param>
518
519</xsl:stylesheet>
520
521