2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
7 <!-- ********************************************************************
8 $Id: refentry.xsl 9647 2012-10-26 17:42:03Z bobstayton $
9 ********************************************************************
11 This file is part of the XSL DocBook Stylesheet distribution.
12 See ../README or http://docbook.sf.net/release/xsl/current/ for
13 copyright and other information.
15 ******************************************************************** -->
17 <!-- ==================================================================== -->
19 <xsl:template match="reference">
20 <!-- If there is a partintro, it triggers the page sequence -->
21 <xsl:if test="not(partintro)">
22 <xsl:variable name="id">
23 <xsl:call-template name="object.id"/>
25 <xsl:variable name="master-reference">
26 <xsl:call-template name="select.pagemaster"/>
29 <fo:page-sequence hyphenate="{$hyphenate}"
30 master-reference="{$master-reference}">
31 <xsl:attribute name="language">
32 <xsl:call-template name="l10n.language"/>
34 <xsl:attribute name="format">
35 <xsl:call-template name="page.number.format">
36 <xsl:with-param name="master-reference" select="$master-reference"/>
40 <xsl:attribute name="initial-page-number">
41 <xsl:call-template name="initial.page.number">
42 <xsl:with-param name="master-reference" select="$master-reference"/>
46 <xsl:attribute name="force-page-count">
47 <xsl:call-template name="force.page.count">
48 <xsl:with-param name="master-reference" select="$master-reference"/>
52 <xsl:attribute name="hyphenation-character">
53 <xsl:call-template name="gentext">
54 <xsl:with-param name="key" select="'hyphenation-character'"/>
57 <xsl:attribute name="hyphenation-push-character-count">
58 <xsl:call-template name="gentext">
59 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
62 <xsl:attribute name="hyphenation-remain-character-count">
63 <xsl:call-template name="gentext">
64 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
68 <xsl:apply-templates select="." mode="running.head.mode">
69 <xsl:with-param name="master-reference" select="$master-reference"/>
70 </xsl:apply-templates>
71 <xsl:apply-templates select="." mode="running.foot.mode">
72 <xsl:with-param name="master-reference" select="$master-reference"/>
73 </xsl:apply-templates>
75 <fo:flow flow-name="xsl-region-body">
76 <xsl:call-template name="set.flow.properties">
77 <xsl:with-param name="element" select="local-name(.)"/>
78 <xsl:with-param name="master-reference" select="$master-reference"/>
82 <xsl:call-template name="reference.titlepage"/>
85 <xsl:variable name="toc.params">
86 <xsl:call-template name="find.path.params">
87 <xsl:with-param name="table"
88 select="normalize-space($generate.toc)"/>
91 <xsl:if test="contains($toc.params, 'toc')">
92 <xsl:call-template name="component.toc">
93 <xsl:with-param name="toc.title.p"
94 select="contains($toc.params, 'title')"/>
96 <xsl:call-template name="component.toc.separator"/>
99 <!-- Create one page sequence if no pagebreaks needed -->
100 <xsl:if test="$refentry.pagebreak = 0">
101 <xsl:apply-templates select="refentry"/>
106 <xsl:apply-templates select="partintro"/>
107 <xsl:if test="$refentry.pagebreak != 0">
108 <xsl:apply-templates select="refentry"/>
112 <xsl:template match="reference" mode="reference.titlepage.mode">
113 <xsl:call-template name="reference.titlepage"/>
116 <xsl:template match="reference/partintro">
117 <xsl:variable name="id">
118 <xsl:call-template name="object.id">
119 <xsl:with-param name="object" select="ancestor::reference"/>
122 <xsl:variable name="master-reference">
123 <xsl:call-template name="select.pagemaster"/>
126 <fo:page-sequence hyphenate="{$hyphenate}"
127 master-reference="{$master-reference}">
128 <xsl:attribute name="language">
129 <xsl:call-template name="l10n.language"/>
131 <xsl:attribute name="format">
132 <xsl:call-template name="page.number.format">
133 <xsl:with-param name="master-reference" select="$master-reference"/>
137 <xsl:attribute name="initial-page-number">
138 <xsl:call-template name="initial.page.number">
139 <xsl:with-param name="master-reference" select="$master-reference"/>
143 <xsl:attribute name="force-page-count">
144 <xsl:call-template name="force.page.count">
145 <xsl:with-param name="master-reference" select="$master-reference"/>
149 <xsl:attribute name="hyphenation-character">
150 <xsl:call-template name="gentext">
151 <xsl:with-param name="key" select="'hyphenation-character'"/>
154 <xsl:attribute name="hyphenation-push-character-count">
155 <xsl:call-template name="gentext">
156 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
159 <xsl:attribute name="hyphenation-remain-character-count">
160 <xsl:call-template name="gentext">
161 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
165 <xsl:apply-templates select="." mode="running.head.mode">
166 <xsl:with-param name="master-reference" select="$master-reference"/>
167 </xsl:apply-templates>
168 <xsl:apply-templates select="." mode="running.foot.mode">
169 <xsl:with-param name="master-reference" select="$master-reference"/>
170 </xsl:apply-templates>
172 <fo:flow flow-name="xsl-region-body">
173 <xsl:call-template name="set.flow.properties">
174 <xsl:with-param name="element" select="local-name(.)"/>
175 <xsl:with-param name="master-reference" select="$master-reference"/>
177 <fo:block id="{$id}">
178 <xsl:apply-templates select=".." mode="reference.titlepage.mode"/>
180 <xsl:if test="title">
181 <xsl:call-template name="partintro.titlepage"/>
183 <xsl:apply-templates/>
185 <!-- switch contexts to generate any toc -->
186 <xsl:for-each select="..">
187 <xsl:variable name="toc.params">
188 <xsl:call-template name="find.path.params">
189 <xsl:with-param name="table"
190 select="normalize-space($generate.toc)"/>
193 <xsl:if test="contains($toc.params, 'toc')">
194 <xsl:call-template name="component.toc">
195 <xsl:with-param name="toc.title.p"
196 select="contains($toc.params, 'title')"/>
198 <xsl:call-template name="component.toc.separator"/>
202 <!-- Create one page sequence if no pagebreaks needed -->
203 <xsl:if test="$refentry.pagebreak = 0">
204 <xsl:apply-templates select="../refentry"/>
210 <xsl:template match="reference/docinfo|refentry/refentryinfo"></xsl:template>
211 <xsl:template match="reference/info"></xsl:template>
212 <xsl:template match="reference/title"></xsl:template>
213 <xsl:template match="reference/subtitle"></xsl:template>
215 <!-- ==================================================================== -->
217 <xsl:template match="refentry">
218 <xsl:variable name="id">
219 <xsl:call-template name="object.id"/>
222 <xsl:variable name="master-reference">
223 <xsl:call-template name="select.pagemaster"/>
226 <xsl:variable name="refentry.content">
227 <fo:block id="{$id}">
228 <xsl:apply-templates/>
233 <xsl:when test="not(parent::*) or
234 (parent::reference and $refentry.pagebreak != 0) or
236 <!-- make a page sequence -->
237 <fo:page-sequence hyphenate="{$hyphenate}"
238 master-reference="{$master-reference}">
239 <xsl:attribute name="language">
240 <xsl:call-template name="l10n.language"/>
242 <xsl:attribute name="format">
243 <xsl:call-template name="page.number.format">
244 <xsl:with-param name="master-reference" select="$master-reference"/>
248 <xsl:attribute name="initial-page-number">
249 <xsl:call-template name="initial.page.number">
250 <xsl:with-param name="master-reference" select="$master-reference"/>
254 <xsl:attribute name="force-page-count">
255 <xsl:call-template name="force.page.count">
256 <xsl:with-param name="master-reference" select="$master-reference"/>
260 <xsl:attribute name="hyphenation-character">
261 <xsl:call-template name="gentext">
262 <xsl:with-param name="key" select="'hyphenation-character'"/>
265 <xsl:attribute name="hyphenation-push-character-count">
266 <xsl:call-template name="gentext">
267 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
270 <xsl:attribute name="hyphenation-remain-character-count">
271 <xsl:call-template name="gentext">
272 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
276 <xsl:apply-templates select="." mode="running.head.mode">
277 <xsl:with-param name="master-reference" select="$master-reference"/>
278 </xsl:apply-templates>
279 <xsl:apply-templates select="." mode="running.foot.mode">
280 <xsl:with-param name="master-reference" select="$master-reference"/>
281 </xsl:apply-templates>
283 <fo:flow flow-name="xsl-region-body">
284 <xsl:call-template name="set.flow.properties">
285 <xsl:with-param name="element" select="local-name(.)"/>
286 <xsl:with-param name="master-reference" select="$master-reference"/>
289 <xsl:copy-of select="$refentry.content"/>
295 <xsl:if test="$refentry.pagebreak != 0">
296 <xsl:attribute name="break-before">page</xsl:attribute>
298 <xsl:copy-of select="$refentry.content"/>
304 <xsl:template match="refmeta">
305 <xsl:apply-templates select=".//indexterm"/>
308 <xsl:template match="manvolnum">
309 <xsl:if test="$refentry.xref.manvolnum != 0">
310 <xsl:text>(</xsl:text>
311 <xsl:apply-templates/>
312 <xsl:text>)</xsl:text>
316 <xsl:template match="refmiscinfo">
319 <xsl:template match="refentrytitle">
320 <xsl:call-template name="inline.charseq"/>
323 <xsl:template match="refnamediv">
324 <xsl:variable name="id">
325 <xsl:call-template name="object.id"/>
328 <fo:block id="{$id}">
330 <!-- if refentry.generate.name is non-zero, then we need to generate a -->
331 <!-- localized "Name" subheading for this refnamdiv (unless it has a -->
332 <!-- preceding sibling that is a refnamediv, in which case we have already -->
333 <!-- generated a "Name" subheading, so we don't need to do it again -->
334 <xsl:if test="$refentry.generate.name != 0">
336 <xsl:when test="preceding-sibling::refnamediv">
337 <!-- no generated title on secondary refnamedivs! -->
340 <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
341 xsl:use-attribute-sets="refnamediv.titlepage.recto.style"
342 font-family="{$title.fontset}">
343 <!-- Contents of what is now the format.refentry.subheading -->
344 <!-- template were formerly intended to be used only to -->
345 <!-- process those subsections of Refentry that have "real" -->
346 <!-- title children. So as a kludge to get around the fact -->
347 <!-- that the template still basically "expects" to be -->
348 <!-- processing that kind of a node, when we call the -->
349 <!-- template to process generated titles, we must call it -->
350 <!-- with values for the "offset" and "section" parameters -->
351 <!-- that are different from the default values in the -->
352 <!-- format.refentry.subheading template itself. Because -->
353 <!-- those defaults are the values appropriate for processing -->
354 <!-- "real" title nodes. -->
355 <xsl:call-template name="format.refentry.subheading">
356 <xsl:with-param name="section" select="self::*"/>
357 <xsl:with-param name="offset" select="1"/>
358 <xsl:with-param name="gentext.key" select="'RefName'"/>
365 <xsl:if test="$refentry.generate.title != 0">
366 <xsl:variable name="section.level">
367 <xsl:call-template name="refentry.level">
368 <xsl:with-param name="node" select="ancestor::refentry"/>
372 <xsl:variable name="reftitle">
374 <xsl:when test="../refmeta/refentrytitle">
375 <xsl:apply-templates select="../refmeta/refentrytitle"/>
378 <xsl:apply-templates select="refname[1]"/>
383 <!-- xsl:use-attribute-sets takes only a Qname, not a variable -->
385 <xsl:when test="preceding-sibling::refnamediv">
386 <!-- no title on secondary refnamedivs! -->
388 <xsl:when test="$section.level = 1">
389 <fo:block xsl:use-attribute-sets="refentry.title.properties">
390 <fo:block xsl:use-attribute-sets="section.title.level1.properties">
391 <xsl:value-of select="$reftitle"/>
395 <xsl:when test="$section.level = 2">
396 <fo:block xsl:use-attribute-sets="refentry.title.properties">
397 <fo:block xsl:use-attribute-sets="section.title.level2.properties">
398 <xsl:value-of select="$reftitle"/>
402 <xsl:when test="$section.level = 3">
403 <fo:block xsl:use-attribute-sets="refentry.title.properties">
404 <fo:block xsl:use-attribute-sets="section.title.level3.properties">
405 <xsl:value-of select="$reftitle"/>
409 <xsl:when test="$section.level = 4">
410 <fo:block xsl:use-attribute-sets="refentry.title.properties">
411 <fo:block xsl:use-attribute-sets="section.title.level4.properties">
412 <xsl:value-of select="$reftitle"/>
416 <xsl:when test="$section.level = 5">
417 <fo:block xsl:use-attribute-sets="refentry.title.properties">
418 <fo:block xsl:use-attribute-sets="section.title.level5.properties">
419 <xsl:value-of select="$reftitle"/>
424 <fo:block xsl:use-attribute-sets="refentry.title.properties">
425 <fo:block xsl:use-attribute-sets="section.title.level6.properties">
426 <xsl:value-of select="$reftitle"/>
434 <xsl:if test="not(following-sibling::refnamediv)">
435 <xsl:attribute name="space-after">1em</xsl:attribute>
437 <xsl:apply-templates/>
442 <xsl:template match="refname">
443 <xsl:if test="not(preceding-sibling::refdescriptor)">
444 <xsl:apply-templates/>
445 <xsl:if test="following-sibling::refname">
446 <xsl:text>, </xsl:text>
451 <xsl:template match="refpurpose">
452 <xsl:if test="node()">
453 <xsl:text> </xsl:text>
454 <xsl:call-template name="dingbat">
455 <xsl:with-param name="dingbat">em-dash</xsl:with-param>
457 <xsl:text> </xsl:text>
458 <xsl:apply-templates/>
462 <xsl:template match="refdescriptor">
463 <xsl:apply-templates/>
466 <xsl:template match="refclass">
467 <xsl:if test="$refclass.suppress = 0">
468 <fo:block font-weight="bold">
469 <xsl:if test="@role">
470 <xsl:value-of select="@role"/>
471 <xsl:text>: </xsl:text>
473 <xsl:apply-templates/>
478 <xsl:template match="refsynopsisdiv">
479 <xsl:variable name="id">
480 <xsl:call-template name="object.id"/>
483 <fo:block id="{$id}">
484 <xsl:if test="not(refsynopsisdivinfo/title|docinfo/title|info/title|title)">
485 <!-- * if we there is no appropriate title for this Refsynopsisdiv, -->
486 <!-- * then we need to call format.refentry.subheading to generate one -->
487 <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
488 xsl:use-attribute-sets="refsynopsisdiv.titlepage.recto.style"
489 font-family="{$title.fontset}">
490 <!-- Contents of what is now the format.refentry.subheading -->
491 <!-- template were formerly intended to be used only to -->
492 <!-- process those subsections of Refentry that have "real" -->
493 <!-- title children. So as a kludge to get around the fact -->
494 <!-- that the template still basically "expects" to be -->
495 <!-- processing that kind of a node, when we call the -->
496 <!-- template to process generated titles, we must call it -->
497 <!-- with values for the "offset" and "section" parameters -->
498 <!-- that are different from the default values in the -->
499 <!-- format.refentry.subheading template itself. Because -->
500 <!-- those defaults are the values appropriate for processing -->
501 <!-- "real" title nodes. -->
502 <xsl:call-template name="format.refentry.subheading">
503 <xsl:with-param name="section" select="parent::*"/>
504 <xsl:with-param name="offset" select="1"/>
505 <xsl:with-param name="gentext.key" select="'RefSynopsisDiv'"/>
509 <xsl:call-template name="refsynopsisdiv.titlepage"/>
510 <xsl:apply-templates/>
514 <xsl:template match="refsection">
515 <xsl:variable name="id">
516 <xsl:call-template name="object.id"/>
519 <fo:block id="{$id}">
520 <xsl:call-template name="refsection.titlepage"/>
521 <xsl:apply-templates/>
525 <xsl:template match="refsect1">
526 <xsl:variable name="id">
527 <xsl:call-template name="object.id"/>
530 <fo:block id="{$id}">
531 <xsl:call-template name="refsect1.titlepage"/>
532 <xsl:apply-templates/>
536 <xsl:template match="refsect2">
537 <xsl:variable name="id">
538 <xsl:call-template name="object.id"/>
541 <fo:block id="{$id}">
542 <xsl:call-template name="refsect2.titlepage"/>
543 <xsl:apply-templates/>
547 <xsl:template match="refsect3">
548 <xsl:variable name="id">
549 <xsl:call-template name="object.id"/>
552 <fo:block id="{$id}">
553 <xsl:call-template name="refsect3.titlepage"/>
554 <xsl:apply-templates/>
558 <xsl:template match="refsynopsisdiv/title
563 <!-- nop; titlepage.mode instead -->
566 <xsl:template match="refsynopsisdiv/title
571 |refsynopsisdiv/info/title
572 |refsection/info/title
575 |refsect3/info/title"
576 mode="titlepage.mode"
578 <xsl:call-template name="format.refentry.subheading"/>
581 <xsl:template name="format.refentry.subheading">
582 <!-- This template is now called to process generated titles for -->
583 <!-- Refnamediv and Refsynopsisdiv, as well as "real" titles for -->
584 <!-- Refsynopsisdiv, Refsection, and Refsect[1-3]. -->
586 <!-- But the contents of this template were formerly intended to be used -->
587 <!-- only to process those subsections of Refentry that have "real" title -->
588 <!-- children. So as a kludge to get around the fact that the template -->
589 <!-- still basically "expects" to be processing that kind of a node, the -->
590 <!-- "offset" parameter was added and the "section" variable was changed to -->
591 <!-- a parameter so that when called for a generated title on a Refnamediv -->
592 <!-- or Refsynopsisdiv, we can call it like this: -->
594 <!-- <xsl:call-template name="format.refentry.subheading"> -->
595 <!-- <xsl:with-param name="section" select="self::*"/> -->
596 <!-- <xsl:with-param name="offset" select="1"/> -->
597 <!-- <xsl:with-param name="gentext.key" select="'RefName'"/> -->
598 <!-- </xsl:call-template> -->
600 <xsl:param name="section"
601 select="(ancestor::refsynopsisdiv
602 |ancestor::refsection
605 |ancestor::refsect3)[last()]"/>
606 <xsl:param name="offset" select="0"/>
607 <xsl:param name="gentext.key"/>
609 <fo:block keep-with-next.within-column="always">
610 <xsl:variable name="id">
611 <xsl:call-template name="object.id">
612 <xsl:with-param name="object" select="$section"/>
616 <xsl:variable name="level">
617 <xsl:call-template name="section.level">
618 <xsl:with-param name="node" select="$section"/>
622 <xsl:variable name="title">
623 <!-- If we have a non-empty value for the $gentext.key param, then we -->
624 <!-- generate an appropriate title here. Otherwise, we have a real -->
625 <!-- title child, so we copy contents of that to the result tree. -->
627 <xsl:when test="$gentext.key != ''">
628 <xsl:call-template name="gentext">
629 <xsl:with-param name="key" select="$gentext.key"/>
633 <xsl:apply-templates select="$section" mode="object.title.markup">
634 <xsl:with-param name="allow-anchors" select="1"/>
635 </xsl:apply-templates>
640 <xsl:if test="$axf.extensions != 0">
641 <xsl:attribute name="axf:outline-level">
642 <xsl:value-of select="count(ancestor::*)-1 + $offset"/>
644 <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
645 <xsl:attribute name="axf:outline-title">
646 <xsl:value-of select="$title"/>
650 <xsl:call-template name="section.heading">
651 <xsl:with-param name="level" select="$level + $offset"/>
652 <xsl:with-param name="title" select="$title"/>
657 <xsl:template match="refsectioninfo|refsection/info"></xsl:template>
658 <xsl:template match="refsect1info|refsect1/info"></xsl:template>
659 <xsl:template match="refsect2info|refsect2/info"></xsl:template>
660 <xsl:template match="refsect3info|refsect3/info"></xsl:template>
662 <!-- ==================================================================== -->