aboutsummaryrefslogtreecommitdiffstats
path: root/stylesheets/lfs-xsl/pdf/lfs-mixed.xsl
blob: 4a0647f74f13a821afb73d3c5957052446175102 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<?xml version='1.0' encoding='ISO-8859-1'?>

<!--
$LastChangedBy$
$Date$
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                version="1.0">

  <!-- This stylesheet contains misc params, attribute sets and templates
       for output formating.
       This file is for that templates that don't fit in other files. -->

    <!-- What space do you want between normal paragraphs. -->
  <xsl:attribute-set name="normal.para.spacing">
    <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
    <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
    <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
    <xsl:attribute name="orphans">3</xsl:attribute>
    <xsl:attribute name="widows">3</xsl:attribute>
  </xsl:attribute-set>

    <!-- Properties associated with verbatim text. -->
  <xsl:attribute-set name="verbatim.properties">
    <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
    <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
    <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
    <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
    <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
    <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
    <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
    <xsl:attribute name="hyphenate">false</xsl:attribute>
    <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
    <xsl:attribute name="white-space-collapse">false</xsl:attribute>
    <xsl:attribute name="white-space-treatment">preserve</xsl:attribute>
    <xsl:attribute name="linefeed-treatment">preserve</xsl:attribute>
    <xsl:attribute name="text-align">start</xsl:attribute>
  </xsl:attribute-set>

    <!-- Should verbatim environments be shaded? 1 =yes, 0 = no -->
  <xsl:param name="shade.verbatim" select="1"/>

    <!-- Properties that specify the style of shaded verbatim listings -->
  <xsl:attribute-set name="shade.verbatim.style">
    <xsl:attribute name="background-color">#E9E9E9</xsl:attribute>
    <xsl:attribute name="border-style">solid</xsl:attribute>
    <xsl:attribute name="border-width">0.5pt</xsl:attribute>
    <xsl:attribute name="border-color">#888</xsl:attribute>
    <xsl:attribute name="padding-start">5pt</xsl:attribute>
    <xsl:attribute name="padding-top">2pt</xsl:attribute>
    <xsl:attribute name="padding-bottom">2pt</xsl:attribute>
  </xsl:attribute-set>

    <!-- para:
           Skip empty "Home page" in packages.xml.
           Allow forced line breaks inside paragraphs emulating literallayout.
           Removed vertical space in variablelist. -->
    <!-- The original template is in {docbook-xsl}/fo/block.xsl -->
  <xsl:template match="para">
    <xsl:choose>
      <xsl:when test="child::ulink[@url=' ']"/>
      <xsl:when test="./@remap='verbatim'">
        <fo:block xsl:use-attribute-sets="verbatim.properties">
          <xsl:call-template name="anchor"/>
          <xsl:apply-templates/>
        </fo:block>
      </xsl:when>
      <xsl:when test="ancestor::variablelist">
        <fo:block>
          <xsl:attribute name="space-before.optimum">0.1em</xsl:attribute>
          <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
          <xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
          <xsl:call-template name="anchor"/>
          <xsl:apply-templates/>
        </fo:block>
      </xsl:when>
      <xsl:otherwise>
        <fo:block xsl:use-attribute-sets="normal.para.spacing">
          <xsl:call-template name="anchor"/>
          <xsl:apply-templates/>
        </fo:block>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

    <!-- screen, literallayout:
          Self-made template that creates a fo:block wrapper with keep-together
          processing instruction support around the output generated by
          original screen templates. -->
  <xsl:template match="screen|literallayout">
    <xsl:variable name="keep.together">
      <xsl:call-template name="pi.dbfo_keep-together"/>
    </xsl:variable>
    <fo:block>
      <xsl:attribute name="keep-together.within-column">
        <xsl:choose>
          <xsl:when test="$keep.together != ''">
            <xsl:value-of select="$keep.together"/>
          </xsl:when>

<!-- The following section has been modified by Martin Miehe. Page breaks
     should be allowed within the long script listings in the appendices.

          <xsl:otherwise>always</xsl:otherwise>
-->
          <xsl:otherwise>
            <xsl:choose>
              <xsl:when test="ancestor::appendix">auto</xsl:when>
              <xsl:otherwise>always</xsl:otherwise>
            </xsl:choose>
          </xsl:otherwise>
<!-- End of modification -->

        </xsl:choose>
      </xsl:attribute>

<!-- The following lines were inserted by Martin Miehe. Scripts and rules 
     in the appendices should have a smaller font-size so that at least 
     80 characters fit to one line. -->

      <xsl:if test="ancestor::appendix">    <!-- name(/) != appendix" -->
        <xsl:attribute name="font-size">10pt</xsl:attribute>
      </xsl:if>
<!-- End of insertion. -->

      <xsl:apply-imports/>
    </fo:block>
  </xsl:template>

    <!-- literal:
           Be sure that literal will use allways normal font weight. -->
    <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  <xsl:template match="literal">
    <fo:inline  font-weight="normal">
      <xsl:call-template name="inline.monoseq"/>
    </fo:inline>
  </xsl:template>

    <!-- inline.monoseq:
           Added hyphenate-url support to classname, exceptionname, interfacename,
           methodname, computeroutput, constant, envar, filename, function, code,
           literal, option, promt, systemitem, varname, sgmltag, tag, and uri -->
    <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  <xsl:template name="inline.monoseq">
    <xsl:param name="content">
      <xsl:call-template name="simple.xlink">
        <xsl:with-param name="content">
          <xsl:choose>
            <xsl:when test="ancestor::para and not(ancestor::screen)
                            and not(descendant::ulink)">
              <xsl:call-template name="hyphenate-url">
                <xsl:with-param name="url">
                  <xsl:apply-templates/>
                </xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:param>
    <fo:inline xsl:use-attribute-sets="monospace.properties">
      <xsl:if test="@dir">
        <xsl:attribute name="direction">
          <xsl:choose>
            <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
            <xsl:otherwise>rtl</xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
      </xsl:if>
      <xsl:copy-of select="$content"/>
    </fo:inline>
  </xsl:template>

    <!-- inline.italicmonoseq:
           Added hyphenate-url support to parameter, replaceable, structfield,
           function/parameter, and function/replaceable -->
    <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  <xsl:template name="inline.italicmonoseq">
    <xsl:param name="content">
      <xsl:call-template name="simple.xlink">
        <xsl:with-param name="content">
          <xsl:choose>
            <xsl:when test="ancestor::para and not(ancestor::screen)
                            and not(descendant::ulink)">
              <xsl:call-template name="hyphenate-url">
                <xsl:with-param name="url">
                  <xsl:apply-templates/>
                </xsl:with-param>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:apply-templates/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:param>
    <fo:inline font-style="italic" xsl:use-attribute-sets="monospace.properties">
      <xsl:call-template name="anchor"/>
      <xsl:if test="@dir">
        <xsl:attribute name="direction">
          <xsl:choose>
            <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
            <xsl:otherwise>rtl</xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
      </xsl:if>
      <xsl:copy-of select="$content"/>
    </fo:inline>
  </xsl:template>

    <!-- Show external URLs in italic font -->
  <xsl:attribute-set name="xref.properties">
    <xsl:attribute name="font-style">
      <xsl:choose>
        <xsl:when test="self::ulink">italic</xsl:when>
        <xsl:otherwise>inherit</xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
  </xsl:attribute-set>

   <!-- Center table title. -->
  <xsl:attribute-set name="formal.title.properties">
    <xsl:attribute name="text-align">
      <xsl:choose>
        <xsl:when test="local-name(.) = 'table'">center</xsl:when>
        <xsl:otherwise>left</xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
  </xsl:attribute-set>

    <!-- table.layout:
           We want all tables centered. Based on a hack posted
           by Ellen Juhlin on docbook-apps mailing list. -->
    <!-- The original template is in {docbook-xsl}/fo/table.xsl -->
  <xsl:template name="table.layout">
    <xsl:param name="table.content" select="NOTANODE"/>
    <fo:table table-layout="fixed" width="100%">
      <fo:table-column column-width ="proportional-column-width(1)"/>
      <fo:table-column>
        <!-- Set center column width equal to table width -->
        <xsl:attribute name="column-width">
          <xsl:call-template name="table.width"/>
        </xsl:attribute>
      </fo:table-column>
      <fo:table-column column-width ="proportional-column-width(1)"/>
      <fo:table-body>
        <fo:table-row>
          <fo:table-cell column-number="2">
            <xsl:copy-of select="$table.content"/>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-body>
    </fo:table>
  </xsl:template>


  <!-- Revision History -->

    <!-- revhistory titlepage:
           Self-made template to add missing support on bookinfo. -->
  <xsl:template match="revhistory" mode="book.titlepage.verso.auto.mode">
    <fo:block space-before.optimum="2em"
              space-before.minimum="1.5em"
              space-before.maximum="2.5em">
      <xsl:apply-templates select="." mode="book.titlepage.verso.mode"/>
    </fo:block>
  </xsl:template>

    <!-- revhitory title properties -->
  <xsl:attribute-set name="revhistory.title.properties">
    <xsl:attribute name="text-align">center</xsl:attribute>
    <xsl:attribute name="font-weight">bold</xsl:attribute>
  </xsl:attribute-set>

    <!-- revhistory/revision mode titlepage.mode:
           Removed authorinitials | author support placing
           revremark | revdescription instead on that table-cell. -->
    <!-- The original template is in {docbook-xsl}/fo/titlepage.xsl -->
  <xsl:template match="revhistory/revision" mode="titlepage.mode">
    <xsl:variable name="revnumber" select="revnumber"/>
    <xsl:variable name="revdate"   select="date"/>
    <xsl:variable name="revremark" select="revremark|revdescription"/>
    <fo:table-row>
      <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
        <fo:block>
          <xsl:if test="$revnumber">
            <xsl:call-template name="gentext">
              <xsl:with-param name="key" select="'Revision'"/>
            </xsl:call-template>
            <xsl:call-template name="gentext.space"/>
            <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
          </xsl:if>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
        <fo:block>
          <xsl:apply-templates select="$revdate[1]"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
        <fo:block>
          <xsl:apply-templates select="$revremark[1]"/>
        </fo:block>
      </fo:table-cell>
    </fo:table-row>
  </xsl:template>


  <!-- Dummy sect1 -->

    <!-- sect1:
           Self-made template to skip dummy sect1 pages generation. -->
  <xsl:template match="sect1">
    <xsl:choose>
      <xsl:when test="@role = 'dummy'"/>
      <xsl:otherwise>
        <xsl:apply-imports/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

    <!-- sect1 mode fop1.outline:
           Self-made template to skip dummy sect1 bookmarks generation. -->
  <xsl:template match="sect1" mode="fop1.outline">
    <xsl:choose>
      <xsl:when test="@role = 'dummy'"/>
      <xsl:otherwise>
        <xsl:apply-imports/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

    <!-- toc.line:
           For dummy sect1 output only the title. -->
    <!-- The original template is in {docbook-xsl}/fo/autotoc.xsl -->
  <xsl:template name="toc.line">
    <xsl:param name="toc-context" select="NOTANODE"/>
    <xsl:variable name="id">
      <xsl:call-template name="object.id"/>
    </xsl:variable>
    <xsl:variable name="label">
      <xsl:apply-templates select="." mode="label.markup"/>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="@role = 'dummy'">
        <fo:block text-align="left">
          <xsl:apply-templates select="." mode="titleabbrev.markup"/>
        </fo:block>
      </xsl:when>
      <xsl:otherwise>
        <fo:block xsl:use-attribute-sets="toc.line.properties">
          <fo:inline keep-with-next.within-line="always">
            <fo:basic-link internal-destination="{$id}">
              <xsl:if test="$label != ''">
                <xsl:copy-of select="$label"/>
                <xsl:value-of select="$autotoc.label.separator"/>
              </xsl:if>
              <xsl:apply-templates select="." mode="titleabbrev.markup"/>
            </fo:basic-link>
          </fo:inline>
          <fo:inline keep-together.within-line="always">
            <xsl:text> </xsl:text>
            <fo:leader leader-pattern="dots"
                       leader-pattern-width="3pt"
                       leader-alignment="reference-area"
                       keep-with-next.within-line="always"/>
            <xsl:text> </xsl:text>
            <fo:basic-link internal-destination="{$id}">
              <fo:page-number-citation ref-id="{$id}"/>
            </fo:basic-link>
          </fo:inline>
        </fo:block>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>