aboutsummaryrefslogtreecommitdiff
path: root/share/xml/freebsd-fo.xsl
blob: 102e4dba317e0e78cf4776e9dc6f5cb3edd1a967 (plain) (blame)
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
<?xml version='1.0'?>

<!-- $FreeBSD$ -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:fo="http://www.w3.org/1999/XSL/Format"
		xmlns:db="http://docbook.org/ns/docbook"
		exclude-result-prefixes="db"
		version="1.0">

  <!-- Pull in the base stylesheets -->
  <xsl:import href="http://docbook.sourceforge.net/release/xsl-ns/current/fo/docbook.xsl"/>

  <xsl:import href="http://www.FreeBSD.org/XML/share/xml/freebsd-common.xsl"/>

  <xsl:import href="http://www.FreeBSD.org/XML/lang/share/xml/freebsd-common.xsl"/>
  <!-- Include customized FO titlepage -->
  <xsl:import href="freebsd-fo-titlepage.xsl"/>

  <!-- The localization layer is the same preference level of this file -->
  <xsl:include href="http://www.FreeBSD.org/XML/lang/share/xml/freebsd-fo.xsl"/>

  <xsl:param name="print">0</xsl:param>

  <xsl:variable name="link.color">
    <xsl:choose>
      <xsl:when test="$print = 1">black</xsl:when>
      <xsl:otherwise>blue</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <!--
	FO-SPECIFIC PARAMETER SETTINGS
  -->

  <!-- We use FOP -->
  <xsl:param name="fop1.extensions" select="1"/>

  <!-- Paper settings -->
  <xsl:param name="paper.type">A4</xsl:param>
  <xsl:param name="double.sided" select="1"/>
  <xsl:param name="force.blank.pages" select="1"/>

  <!-- Page margins and spacing -->
  <xsl:param name="page.margin.bottom">2cm</xsl:param>
  <xsl:param name="page.margin.inner">3cm</xsl:param>
  <xsl:param name="page.margin.outer">2.5cm</xsl:param>
  <xsl:param name="page.margin.top">2.13cm</xsl:param>
  <xsl:param name="body.margin.bottom">1cm</xsl:param>
  <xsl:param name="body.margin.top">1.0cm</xsl:param>
  <xsl:param name="body.margin.inner">0</xsl:param>
  <xsl:param name="body.margin.outer">0</xsl:param>
  <xsl:param name="body.start.indent">0</xsl:param>
  <xsl:param name="body.end.indent">0</xsl:param>
  <xsl:param name="region.after.extent">2cm</xsl:param>
  <xsl:param name="region.before.extent">2.2cm</xsl:param>

  <!-- Headers and footers -->
  <xsl:param name="headers.on.blank.pages" select="0"/>
  <xsl:param name="footers.on.blank.pages" select="0"/>
  <xsl:param name="footer.rule" select="0"/>
  <xsl:param name="header.column.widths">500 1 500</xsl:param>
  <xsl:param name="footer.column.widths">500 1 500</xsl:param>

  <!-- Sections and numbering -->
  <xsl:param name="section.autolabel" select="1"/>
  <xsl:param name="section.autolabel.max.depth" select="5"/>
  <xsl:param name="section.label.includes.component.label" select="1"/>
  <xsl:param name="bibliography.numbered" select="1"/>
  <xsl:param name="formal.title.placement">
    figure after
    example before
    equation after
    table before
    procedure before</xsl:param>

  <!-- Admonitions -->
  <xsl:param name="admon.graphics" select="1"/>
  <xsl:param name="admon.graphics.path">/usr/local/share/xsl/docbook-ns/images/</xsl:param>
  <xsl:param name="admon.graphics.extension">.svg</xsl:param>

  <!-- Tables -->
  <xsl:param name="default.table.frame">hsides</xsl:param>
  <xsl:param name="default.table.rules">rows</xsl:param>

  <!-- Lists -->
  <xsl:param name="variablelist.as.blocks" select="1"/>

  <!-- Q & A -->
  <xsl:param name="qanda.defaultlabel">qanda</xsl:param>

  <!-- Graphics -->
  <xsl:param name="callout.graphics.path">imagelib/callouts/</xsl:param>
  <xsl:param name="callout.graphics.extension">.png</xsl:param>
  <xsl:param name="default.image.width">300px</xsl:param>
  <xsl:template name="image.scalefit">1</xsl:template>

  <!-- Hyphenation -->
  <xsl:param name="hyphenate">true</xsl:param>
  <!-- Disable due to too long verbatim string in pgpkeys -->
  <xsl:param name="hyphenate.verbatim" select="0"/>
  <xsl:param name="hyphenate.verbatim.characters"> </xsl:param>

  <!-- Base Fonts -->
  <xsl:param name="body.font.master">9.5</xsl:param>
  <xsl:param name="body.font.family">Gentium Plus</xsl:param>
  <xsl:param name="sans.font.family">Droid Sans</xsl:param>
  <xsl:param name="title.font.family">Droid Sans</xsl:param>
  <xsl:param name="monospace.font.family">DejaVu Sans Mono</xsl:param>

  <!-- Linking -->
  <xsl:param name="ulink.show" select="$print"/>
  <xsl:param name="ulink.footnotes" select="$print"/>
  <xsl:param name="email.mailto.enabled">
    <xsl:choose>
      <xsl:when test="$print = 1">0</xsl:when>
      <xsl:otherwise>1</xsl:otherwise>
    </xsl:choose>
  </xsl:param>

  <!-- Property sets -->
  <xsl:attribute-set name="chapter.title.properties">
  <xsl:attribute name="font-size">24pt</xsl:attribute>
  <xsl:attribute name="space-before">6pt</xsl:attribute>
  <xsl:attribute name="space-after">36pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="section.title.level1.properties">
  <xsl:attribute name="font-size">14pt</xsl:attribute>
  <xsl:attribute name="space-before">24pt</xsl:attribute>
  <xsl:attribute name="space-after">12pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="section.title.level2.properties">
  <xsl:attribute name="font-size">11pt</xsl:attribute>
  <xsl:attribute name="space-before">12pt</xsl:attribute>
  <xsl:attribute name="space-after">6pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="section.title.level3.properties">
  <xsl:attribute name="font-size">10pt</xsl:attribute>
  <xsl:attribute name="space-before">6pt</xsl:attribute>
  <xsl:attribute name="space-after">3pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="section.title.properties">
  <xsl:attribute name="font-family">
  <xsl:value-of select="$title.fontset"></xsl:value-of>
  </xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
  <xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
  <xsl:attribute name="text-align">start</xsl:attribute>
  <xsl:attribute name="start-indent"><xsl:value-of select="$title.margin.left"></xsl:value-of></xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="section.properties">
  <xsl:attribute name="font-size">9.5pt</xsl:attribute>
  <xsl:attribute name="line-height">12pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="normal.para.spacing">
  <xsl:attribute name="space-before">12pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="abstract.title.properties">
  <xsl:attribute name="font-size">
  <xsl:value-of select="$body.font.master * 2.0736"></xsl:value-of>
  <xsl:text>pt</xsl:text>
  </xsl:attribute>
  <xsl:attribute name="text-align">left</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="abstract.properties">
  <xsl:attribute name="margin-left">0</xsl:attribute>
  <xsl:attribute name="margin-right">0</xsl:attribute>
  <xsl:attribute name="padding-left">0</xsl:attribute>
  <xsl:attribute name="padding-right">0</xsl:attribute>
  </xsl:attribute-set>

<xsl:attribute-set name="toc.margin.properties">
  <xsl:attribute name="margin-left">
    <xsl:value-of select="'0'"/>
  </xsl:attribute>
  <xsl:attribute name="margin-right">
    <xsl:value-of select="'0'"/>
  </xsl:attribute>
  <xsl:attribute name="padding-left">
    <xsl:value-of select="'0'"/>
  </xsl:attribute>
  <xsl:attribute name="padding-right">
    <xsl:value-of select="'0'"/>
  </xsl:attribute>
</xsl:attribute-set>

  <xsl:attribute-set name="monospace.properties">
  <xsl:attribute name="font-family">
  <xsl:value-of select="$monospace.font.family"></xsl:value-of>
  </xsl:attribute>
  <xsl:attribute name="font-size">8pt</xsl:attribute>
  <xsl:attribute name="letter-spacing">-0.3pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="monospace.verbatim.properties">
  <xsl:attribute name="font-size">8pt</xsl:attribute>
  <xsl:attribute name="line-height">10pt</xsl:attribute>
  <xsl:attribute name="space-before">12pt</xsl:attribute>
  <xsl:attribute name="space-after">0</xsl:attribute>
  <xsl:attribute name="hyphenate">false</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 name="background-color">rgb(192,192,192)</xsl:attribute>
  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
  <xsl:attribute name="hyphenation-character">&#x21BA;</xsl:attribute>
  <xsl:attribute name="padding-right">3pt</xsl:attribute>
  <xsl:attribute name="padding-top">1pt</xsl:attribute>
  <xsl:attribute name="padding-left">3pt</xsl:attribute>
  <xsl:attribute name="padding-bottom">1pt</xsl:attribute>
  <xsl:attribute name="margin-right">0pt</xsl:attribute>
  <xsl:attribute name="margin-left">0pt</xsl:attribute>
  <xsl:attribute name="letter-spacing">0pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.caption.properties">
  <xsl:attribute name="font-size">8pt</xsl:attribute>
  <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  <xsl:attribute name="line-height">13pt</xsl:attribute>
  <xsl:attribute name="space-before">12pt</xsl:attribute>
  <xsl:attribute name="space-after">3pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="table.table.properties">
  <xsl:attribute name="font-size">9.5pt</xsl:attribute>
  <xsl:attribute name="border-before-width.conditionality">retain</xsl:attribute>
  <xsl:attribute name="border-collapse">collapse</xsl:attribute>
  <xsl:attribute name="margin-top">0</xsl:attribute>
  <xsl:attribute name="margin-bottom">0</xsl:attribute>
  <xsl:attribute name="margin-left">0</xsl:attribute>
  <xsl:attribute name="margin-right">0</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="formal.title.properties" use-attribute-sets="normal.para.spacing">
  <xsl:attribute name="font-size">8pt</xsl:attribute>
  <xsl:attribute name="font-weight">normal</xsl:attribute>
  <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  <xsl:attribute name="line-height">13pt</xsl:attribute>
  <xsl:attribute name="hyphenate">false</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="graphical.admonition.properties">
  <xsl:attribute name="border-style">solid</xsl:attribute>
  <xsl:attribute name="border-width">1px</xsl:attribute>
  <xsl:attribute name="margin-right">0</xsl:attribute>
  <xsl:attribute name="margin-top">12pt</xsl:attribute>
  <xsl:attribute name="margin-left">0</xsl:attribute>
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
  <xsl:attribute name="padding-right">0.5cm</xsl:attribute>
  <xsl:attribute name="padding-top">0.5cm</xsl:attribute>
  <xsl:attribute name="padding-left">0.5cm</xsl:attribute>
  <xsl:attribute name="padding-bottom">0.5cm</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="list.item.spacing">
  <xsl:attribute name="space-before">6pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="list.block.spacing">
  <xsl:attribute name="space-before">6pt</xsl:attribute>
  <xsl:attribute name="space-after">6pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="list.block.properties">
  <xsl:attribute name="provisional-label-separation">0.2em</xsl:attribute>
  <xsl:attribute name="provisional-distance-between-starts">1.5em</xsl:attribute>
  <xsl:attribute name="line-height">12pt</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="example.properties" use-attribute-sets="formal.object.properties">
  <xsl:attribute name="keep-together.within-column">auto</xsl:attribute>
  <xsl:attribute name="border-style">solid</xsl:attribute>
  <xsl:attribute name="border-width">1px</xsl:attribute>
  <xsl:attribute name="margin-right">0</xsl:attribute>
  <xsl:attribute name="margin-top">12pt</xsl:attribute>
  <xsl:attribute name="margin-left">0</xsl:attribute>
  <xsl:attribute name="margin-bottom">12pt</xsl:attribute>
  <xsl:attribute name="padding-right">0.5cm</xsl:attribute>
  <xsl:attribute name="padding-top">0.3cm</xsl:attribute>
  <xsl:attribute name="padding-left">0.5cm</xsl:attribute>
  <xsl:attribute name="padding-bottom">0.5cm</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="xref.properties">
    <xsl:attribute name="color">
      <xsl:value-of select="$link.color"/>
    </xsl:attribute>
  </xsl:attribute-set>

  <!--
	FO-SPECIFIC TEMPLATE CUSTOMIZATIONS
  -->

  <!-- Gray background for headers of HTML tables -->
  <xsl:template match="db:thead" mode="htmlTable">
    <fo:table-header start-indent="0pt" end-indent="0pt"
      background-color="rgb(192,192,192)">
      <xsl:apply-templates mode="htmlTable"/>
    </fo:table-header>
  </xsl:template>

  <!-- Gray background for headers of CALS tables -->
  <xsl:template match="db:thead">
    <xsl:variable name="tgroup" select="parent::*"/>

    <fo:table-header start-indent="0pt" end-indent="0pt" background-color="rgb(192,192,192)">
      <xsl:choose>
	<!-- Use recursion if @morerows is used -->
	<xsl:when test="db:row/db:entry/@morerows|db:row/db:entrytbl/@morerows">
	  <xsl:apply-templates select="db:row[1]">
	    <xsl:with-param name="spans">
	      <xsl:call-template name="blank.spans">
		<xsl:with-param name="cols" select="../@cols"/>
	      </xsl:call-template>
	    </xsl:with-param>
	    <xsl:with-param name="browserows" select="'recurse'"/>
	  </xsl:apply-templates>
	</xsl:when>

	<xsl:otherwise>
	  <xsl:apply-templates select="db:row">
	    <xsl:with-param name="spans">
	      <xsl:call-template name="blank.spans">
		<xsl:with-param name="cols" select="../@cols"/>
	      </xsl:call-template>
	    </xsl:with-param>
	    <xsl:with-param name="browserows" select="'loop'" />
	  </xsl:apply-templates>
	</xsl:otherwise>
      </xsl:choose>
    </fo:table-header>
  </xsl:template>

  <xsl:template match="db:guibutton">
    <fo:inline background-color="rgb(192,192,192)">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>

  <!-- Adjust spacing according to where the title is placed -->
  <xsl:template name="formal.object.heading">
    <xsl:param name="object" select="."/>
    <xsl:param name="placement" select="'before'"/>

    <fo:block xsl:use-attribute-sets="formal.title.properties">
      <xsl:choose>
	<xsl:when test="$placement = 'before' and local-name($object) != 'example'">
	  <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
	  <xsl:attribute name="space-before.minimum">12pt</xsl:attribute>
	  <xsl:attribute name="space-before.optimum">12pt</xsl:attribute>
	  <xsl:attribute name="space-before.maximum">12pt</xsl:attribute>
	  <xsl:attribute name="space-after.minimum">0</xsl:attribute>
	  <xsl:attribute name="space-after.optimum">0</xsl:attribute>
	  <xsl:attribute name="space-after.maximum">0</xsl:attribute>
	</xsl:when>

	<xsl:when test="$placement = 'after'">
	  <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
	  <xsl:attribute name="space-before.minimum">0</xsl:attribute>
	  <xsl:attribute name="space-before.optimum">0</xsl:attribute>
	  <xsl:attribute name="space-before.maximum">0</xsl:attribute>
	  <xsl:attribute name="space-after.minimum">12pt</xsl:attribute>
	  <xsl:attribute name="space-after.optimum">12pt</xsl:attribute>
	  <xsl:attribute name="space-after.maximum">12pt</xsl:attribute>
	</xsl:when>

	<xsl:otherwise>
	  <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
	  <xsl:attribute name="font-weight">bold</xsl:attribute>
	  <xsl:attribute name="font-size">14pt</xsl:attribute>
	</xsl:otherwise>
      </xsl:choose>
      <xsl:apply-templates select="$object" mode="object.title.markup">
	<xsl:with-param name="allow-anchors" select="1"/>
      </xsl:apply-templates>
    </fo:block>
  </xsl:template>

  <xsl:template match="db:citerefentry">
    <xsl:variable name="xhref">
      <xsl:text>https://www.FreeBSD.org/cgi/man.cgi?query=</xsl:text>
      <xsl:value-of select="db:refentrytitle"/>
      <xsl:text>&amp;sektion=</xsl:text>
      <xsl:value-of select="db:manvolnum"/>
      <xsl:text>&amp;manpath=freebsd-release-ports</xsl:text>
    </xsl:variable>

    <fo:basic-link external-destination="url({$xhref})">
      <fo:inline color="{$link.color}">
	<xsl:value-of select="concat(db:refentrytitle, '(', db:manvolnum, ')')"/>
      </fo:inline>
    </fo:basic-link>
  </xsl:template>

  <xsl:template match="db:package">
    <xsl:variable name="xhref" select="concat('https://www.freebsd.org/cgi/url.cgi?ports/', ., '/pkg-descr')"/>

    <fo:basic-link external-destination="url({$xhref})">
      <fo:inline color="{$link.color}">
	<xsl:apply-templates/>
      </fo:inline>
    </fo:basic-link>
  </xsl:template>

<!-- Customize header content -->
<xsl:template name="header.content">
  <xsl:param name="pageclass" select="''"/>
  <xsl:param name="sequence" select="''"/>
  <xsl:param name="position" select="''"/>
  <xsl:param name="gentext-key" select="''"/>

  <fo:block>
    <xsl:choose>
      <xsl:when test="$pageclass = 'lot' and $sequence='odd' and $position='left' ">
	<xsl:call-template name="gentext">
	  <xsl:with-param name="key" select="$gentext-key"/>
	</xsl:call-template>
      </xsl:when>

      <xsl:when test="$pageclass = 'lot' and $sequence='even' and $position='right' ">
	<xsl:call-template name="gentext">
	  <xsl:with-param name="key" select="$gentext-key"/>
	</xsl:call-template>
      </xsl:when>

      <xsl:when test="$pageclass = 'back' and $sequence='odd' and $position='left' ">
	<xsl:apply-templates select="."  mode="object.title.markup"/>
      </xsl:when>

      <xsl:when test="$pageclass = 'back' and $sequence='even' and $position='right' ">
	<xsl:apply-templates select="."  mode="object.title.markup"/>
      </xsl:when>

      <xsl:when test="$pageclass = 'index' and $sequence='odd' and $position='left' ">
	<xsl:call-template name="gentext">
	  <xsl:with-param name="key" select="$gentext-key"/>
	</xsl:call-template>
      </xsl:when>

      <xsl:when test="$pageclass = 'index' and $sequence='even' and $position='right' ">
	<xsl:call-template name="gentext">
	  <xsl:with-param name="key" select="$gentext-key"/>
	</xsl:call-template>
      </xsl:when>

      <xsl:when test="$sequence='odd' and $position='left'">
	<xsl:if test="$pageclass != 'titlepage'">
	  <xsl:apply-templates select="."  mode="object.title.markup"/>
	</xsl:if>
      </xsl:when>

      <xsl:when test="$sequence='even' and $position='right'">
	<xsl:if test="$pageclass != 'titlepage'">
	  <fo:retrieve-marker
	    retrieve-class-name="section.head.marker"
	    retrieve-position="first-including-carryover"
	    retrieve-boundary="page-sequence"/>
	</xsl:if>
      </xsl:when>
    </xsl:choose>
  </fo:block>
</xsl:template>

<!-- Customize footer content -->
<xsl:template name="footer.content">
  <xsl:param name="pageclass" select="''"/>
  <xsl:param name="sequence" select="''"/>
  <xsl:param name="position" select="''"/>
  <xsl:param name="gentext-key" select="''"/>

  <fo:block>
    <xsl:choose>
      <xsl:when test="$sequence = 'odd' and $position='right'">
	<fo:page-number/>
      </xsl:when>

      <xsl:when test="$sequence = 'even' and $position='left'">
	<fo:page-number/>
      </xsl:when>
    </xsl:choose>
  </fo:block>
</xsl:template>

<!-- Customize header separator -->
<xsl:template name="head.sep.rule">
  <xsl:param name="pageclass"/>
  <xsl:param name="sequence"/>
  <xsl:param name="gentext-key"/>

  <xsl:if test="$header.rule != 0 and $sequence != 'first' and
    $pageclass != 'front' and $pageclass != 'titlepage'">
    <xsl:attribute name="border-bottom-width">0.5pt</xsl:attribute>
    <xsl:attribute name="border-bottom-style">solid</xsl:attribute>
    <xsl:attribute name="border-bottom-color">black</xsl:attribute>
  </xsl:if>
</xsl:template>

  <!-- FOP hyphenation bug workaround -->
  <xsl:template match="db:anchor">
    <xsl:variable name="id">
      <xsl:call-template name="object.id"/>
    </xsl:variable>
    <fo:inline id="{$id}">&#x200b;</fo:inline>
  </xsl:template>

  <!-- Suppress list titles -->
  <xsl:template match="db:title" mode="list.title.mode"/>

  <!-- Soft-hyphen workaround for verbatim hyphenation -->
  <xsl:template name="hyphenate.verbatim">
    <xsl:param name="content"/>
    <xsl:variable name="apos" select='"&apos;"'/>
    <xsl:variable name="head" select="substring($content, 1, 1)"/>
    <xsl:variable name="tail" select="substring($content, 2)"/>
    <xsl:variable name="next" select="substring($tail, 1, 1)"/>
    <xsl:choose>
      <!-- Place soft-hyphen after space or non-breakable space. -->
      <xsl:when test="$next = '&#xA;' or $next = '' or $next = '&quot;' or
	$next = '.' or $next = ',' or $next = '-' or $next = '/' or
	$next = $apos or $next = ':' or $next = '!' or $next = '|' or
	$next = '?' or $next = ')'">
	<xsl:value-of select="$head"/>
      </xsl:when>
      <xsl:when test="($head = ' ' or $head = '&#160;') and $next != '.' and
	$next != '}' and $next != ' ' and $next != '&#160;'">
	<xsl:text>&#160;</xsl:text>
	<xsl:text>&#x00AD;</xsl:text>
      </xsl:when>
      <xsl:when test="$head = '.' and translate($next, '0123456789', '') != ''">
	<xsl:text>.</xsl:text>
	<xsl:text>&#x00AD;</xsl:text>
      </xsl:when>
      <xsl:when test="$hyphenate.verbatim.characters != '' and
	translate($head, $hyphenate.verbatim.characters, '') = '' and
	translate($next, $hyphenate.verbatim.characters, '') != ''">
	<xsl:value-of select="$head"/>
	<xsl:text>&#x00AD;</xsl:text>
      </xsl:when>
      <xsl:when test="$next = '('">
	<xsl:value-of select="$head"/>
	<xsl:text>&#x00AD;</xsl:text>
      </xsl:when>
      <xsl:otherwise>
	<xsl:value-of select="$head"/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:if test="$tail">
      <xsl:call-template name="hyphenate.verbatim">
	<xsl:with-param name="content" select="$tail"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

<!--
	TITLEPAGE TEMPLATES
-->

  <xsl:template name="svnref.genlink">
    <xsl:param name="rev" select="."/>
    <xsl:param name="repo" select="'base'"/>
    <xsl:variable name="href">
      <xsl:call-template name="svnweb.link">
	<xsl:with-param name="repo" select="$repo"/>
	<xsl:with-param name="rev" select="$rev"/>
      </xsl:call-template>
    </xsl:variable>

    <fo:basic-link external-destination="url({$href})">
      <fo:inline color="blue">
	<xsl:value-of select="$rev"/>
      </fo:inline>
    </fo:basic-link>
  </xsl:template>

  <xsl:template name="gitref.genlink">
    <xsl:param name="rev" select="."/>
    <xsl:param name="repo" select="'src'"/>
    <xsl:variable name="href">
      <xsl:call-template name="cgit.link">
	<xsl:with-param name="repo" select="$repo"/>
	<xsl:with-param name="rev" select="$rev"/>
      </xsl:call-template>
    </xsl:variable>

    <fo:basic-link external-destination="url({$href})">
      <fo:inline color="blue">
	<xsl:value-of select="$rev"/>
      </fo:inline>
    </fo:basic-link>
  </xsl:template>

  <xsl:template name="chapter.authorgroup">
    <fo:inline font-style="italic">
      <xsl:call-template name="freebsd.authorgroup"/>
    </fo:inline>
  </xsl:template>

  <xsl:template name="chapter.author">
    <fo:inline font-style="italic">
      <xsl:call-template name="freebsd.author"/>
    </fo:inline>
  </xsl:template>

  <xsl:template match="db:title" mode="title.markup">
    <xsl:apply-templates mode="titlepage.mode"/>
  </xsl:template>

  <xsl:template match="db:replaceable" mode="titlepage.mode">
    <fo:inline font-style="italic">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>

  <xsl:template match="db:citerefentry" mode="titlepage.mode">
    <xsl:variable name="xhref">
      <xsl:text>https://www.FreeBSD.org/cgi/man.cgi?query=</xsl:text>
      <xsl:value-of select="db:refentrytitle"/>
      <xsl:text>&#38;amp;sektion=</xsl:text>
      <xsl:value-of select="db:manvolnum"/>
    </xsl:variable>

    <fo:basic-link external-destination="url({$xhref})">
      <xsl:value-of select="concat(db:refentrytitle, '(', db:manvolnum, ')')"/>
    </fo:basic-link>
  </xsl:template>

  <xsl:template match="db:filename" mode="titlepage.mode">
    <fo:inline font-family="{$monospace.font.family}">
      <xsl:apply-templates/>
    </fo:inline>
  </xsl:template>
</xsl:stylesheet>