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 7564 2007-11-19 18:38:43Z mzjn $
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 <xsl:if test="not(partintro)">
21 <xsl:variable name="id">
22 <xsl:call-template name="object.id"/>
24 <xsl:variable name="master-reference">
25 <xsl:call-template name="select.pagemaster"/>
28 <fo:page-sequence hyphenate="{$hyphenate}"
29 master-reference="{$master-reference}">
30 <xsl:attribute name="language">
31 <xsl:call-template name="l10n.language"/>
33 <xsl:attribute name="format">
34 <xsl:call-template name="page.number.format">
35 <xsl:with-param name="master-reference" select="$master-reference"/>
39 <xsl:attribute name="initial-page-number">
40 <xsl:call-template name="initial.page.number">
41 <xsl:with-param name="master-reference" select="$master-reference"/>
45 <xsl:attribute name="force-page-count">
46 <xsl:call-template name="force.page.count">
47 <xsl:with-param name="master-reference" select="$master-reference"/>
51 <xsl:attribute name="hyphenation-character">
52 <xsl:call-template name="gentext">
53 <xsl:with-param name="key" select="'hyphenation-character'"/>
56 <xsl:attribute name="hyphenation-push-character-count">
57 <xsl:call-template name="gentext">
58 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
61 <xsl:attribute name="hyphenation-remain-character-count">
62 <xsl:call-template name="gentext">
63 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
67 <xsl:apply-templates select="." mode="running.head.mode">
68 <xsl:with-param name="master-reference" select="$master-reference"/>
69 </xsl:apply-templates>
70 <xsl:apply-templates select="." mode="running.foot.mode">
71 <xsl:with-param name="master-reference" select="$master-reference"/>
72 </xsl:apply-templates>
74 <fo:flow flow-name="xsl-region-body">
75 <xsl:call-template name="set.flow.properties">
76 <xsl:with-param name="element" select="local-name(.)"/>
77 <xsl:with-param name="master-reference" select="$master-reference"/>
81 <xsl:call-template name="reference.titlepage"/>
83 <!-- Create one page sequence if no pagebreaks needed -->
84 <xsl:if test="$refentry.pagebreak = 0">
85 <xsl:apply-templates select="refentry"/>
90 <xsl:apply-templates select="partintro"/>
91 <xsl:if test="$refentry.pagebreak != 0">
92 <xsl:apply-templates select="refentry"/>
96 <xsl:template match="reference" mode="reference.titlepage.mode">
97 <xsl:call-template name="reference.titlepage"/>
100 <xsl:template match="reference/partintro">
101 <xsl:variable name="id">
102 <xsl:call-template name="object.id">
103 <xsl:with-param name="object" select="ancestor::reference"/>
106 <xsl:variable name="master-reference">
107 <xsl:call-template name="select.pagemaster"/>
110 <fo:page-sequence hyphenate="{$hyphenate}"
111 master-reference="{$master-reference}">
112 <xsl:attribute name="language">
113 <xsl:call-template name="l10n.language"/>
115 <xsl:attribute name="format">
116 <xsl:call-template name="page.number.format">
117 <xsl:with-param name="master-reference" select="$master-reference"/>
121 <xsl:attribute name="initial-page-number">
122 <xsl:call-template name="initial.page.number">
123 <xsl:with-param name="master-reference" select="$master-reference"/>
127 <xsl:attribute name="force-page-count">
128 <xsl:call-template name="force.page.count">
129 <xsl:with-param name="master-reference" select="$master-reference"/>
133 <xsl:attribute name="hyphenation-character">
134 <xsl:call-template name="gentext">
135 <xsl:with-param name="key" select="'hyphenation-character'"/>
138 <xsl:attribute name="hyphenation-push-character-count">
139 <xsl:call-template name="gentext">
140 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
143 <xsl:attribute name="hyphenation-remain-character-count">
144 <xsl:call-template name="gentext">
145 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
149 <xsl:apply-templates select="." mode="running.head.mode">
150 <xsl:with-param name="master-reference" select="$master-reference"/>
151 </xsl:apply-templates>
152 <xsl:apply-templates select="." mode="running.foot.mode">
153 <xsl:with-param name="master-reference" select="$master-reference"/>
154 </xsl:apply-templates>
156 <fo:flow flow-name="xsl-region-body">
157 <xsl:call-template name="set.flow.properties">
158 <xsl:with-param name="element" select="local-name(.)"/>
159 <xsl:with-param name="master-reference" select="$master-reference"/>
161 <fo:block id="{$id}">
162 <xsl:apply-templates select=".." mode="reference.titlepage.mode"/>
164 <xsl:if test="title">
165 <xsl:call-template name="partintro.titlepage"/>
167 <xsl:apply-templates/>
168 <!-- Create one page sequence if no pagebreaks needed -->
169 <xsl:if test="$refentry.pagebreak = 0">
170 <xsl:apply-templates select="../refentry"/>
176 <xsl:template match="reference/docinfo|refentry/refentryinfo"></xsl:template>
177 <xsl:template match="reference/info"></xsl:template>
178 <xsl:template match="reference/title"></xsl:template>
179 <xsl:template match="reference/subtitle"></xsl:template>
181 <!-- ==================================================================== -->
183 <xsl:template match="refentry">
184 <xsl:variable name="id">
185 <xsl:call-template name="object.id"/>
188 <xsl:variable name="master-reference">
189 <xsl:call-template name="select.pagemaster"/>
192 <xsl:variable name="refentry.content">
193 <fo:block id="{$id}">
194 <xsl:apply-templates/>
199 <xsl:when test="not(parent::*) or
200 (parent::reference and $refentry.pagebreak != 0) or
202 <!-- make a page sequence -->
203 <fo:page-sequence hyphenate="{$hyphenate}"
204 master-reference="{$master-reference}">
205 <xsl:attribute name="language">
206 <xsl:call-template name="l10n.language"/>
208 <xsl:attribute name="format">
209 <xsl:call-template name="page.number.format">
210 <xsl:with-param name="master-reference" select="$master-reference"/>
214 <xsl:attribute name="initial-page-number">
215 <xsl:call-template name="initial.page.number">
216 <xsl:with-param name="master-reference" select="$master-reference"/>
220 <xsl:attribute name="force-page-count">
221 <xsl:call-template name="force.page.count">
222 <xsl:with-param name="master-reference" select="$master-reference"/>
226 <xsl:attribute name="hyphenation-character">
227 <xsl:call-template name="gentext">
228 <xsl:with-param name="key" select="'hyphenation-character'"/>
231 <xsl:attribute name="hyphenation-push-character-count">
232 <xsl:call-template name="gentext">
233 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
236 <xsl:attribute name="hyphenation-remain-character-count">
237 <xsl:call-template name="gentext">
238 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
242 <xsl:apply-templates select="." mode="running.head.mode">
243 <xsl:with-param name="master-reference" select="$master-reference"/>
244 </xsl:apply-templates>
245 <xsl:apply-templates select="." mode="running.foot.mode">
246 <xsl:with-param name="master-reference" select="$master-reference"/>
247 </xsl:apply-templates>
249 <fo:flow flow-name="xsl-region-body">
250 <xsl:call-template name="set.flow.properties">
251 <xsl:with-param name="element" select="local-name(.)"/>
252 <xsl:with-param name="master-reference" select="$master-reference"/>
255 <xsl:copy-of select="$refentry.content"/>
261 <xsl:if test="$refentry.pagebreak != 0">
262 <xsl:attribute name="break-before">page</xsl:attribute>
264 <xsl:copy-of select="$refentry.content"/>
270 <xsl:template match="refmeta">
273 <xsl:template match="manvolnum">
274 <xsl:if test="$refentry.xref.manvolnum != 0">
275 <xsl:text>(</xsl:text>
276 <xsl:apply-templates/>
277 <xsl:text>)</xsl:text>
281 <xsl:template match="refmiscinfo">
284 <xsl:template match="refentrytitle">
285 <xsl:call-template name="inline.charseq"/>
288 <xsl:template match="refnamediv">
289 <xsl:variable name="id">
290 <xsl:call-template name="object.id"/>
293 <fo:block id="{$id}">
295 <!-- if refentry.generate.name is non-zero, then we need to generate a -->
296 <!-- localized "Name" subheading for this refnamdiv (unless it has a -->
297 <!-- preceding sibling that is a refnamediv, in which case we have already -->
298 <!-- generated a "Name" subheading, so we don't need to do it again -->
299 <xsl:if test="$refentry.generate.name != 0">
301 <xsl:when test="preceding-sibling::refnamediv">
302 <!-- no generated title on secondary refnamedivs! -->
305 <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
306 xsl:use-attribute-sets="refnamediv.titlepage.recto.style"
307 font-family="{$title.fontset}">
308 <!-- Contents of what is now the format.refentry.subheading -->
309 <!-- template were formerly intended to be used only to -->
310 <!-- process those subsections of Refentry that have "real" -->
311 <!-- title children. So as a kludge to get around the fact -->
312 <!-- that the template still basically "expects" to be -->
313 <!-- processing that kind of a node, when we call the -->
314 <!-- template to process generated titles, we must call it -->
315 <!-- with values for the "offset" and "section" parameters -->
316 <!-- that are different from the default values in the -->
317 <!-- format.refentry.subheading template itself. Because -->
318 <!-- those defaults are the values appropriate for processing -->
319 <!-- "real" title nodes. -->
320 <xsl:call-template name="format.refentry.subheading">
321 <xsl:with-param name="section" select="self::*"/>
322 <xsl:with-param name="offset" select="1"/>
323 <xsl:with-param name="gentext.key" select="'RefName'"/>
330 <xsl:if test="$refentry.generate.title != 0">
331 <xsl:variable name="section.level">
332 <xsl:call-template name="refentry.level">
333 <xsl:with-param name="node" select="ancestor::refentry"/>
337 <xsl:variable name="reftitle">
339 <xsl:when test="../refmeta/refentrytitle">
340 <xsl:apply-templates select="../refmeta/refentrytitle"/>
343 <xsl:apply-templates select="refname[1]"/>
348 <!-- xsl:use-attribute-sets takes only a Qname, not a variable -->
350 <xsl:when test="preceding-sibling::refnamediv">
351 <!-- no title on secondary refnamedivs! -->
353 <xsl:when test="$section.level = 1">
354 <fo:block xsl:use-attribute-sets="refentry.title.properties">
355 <fo:block xsl:use-attribute-sets="section.title.level1.properties">
356 <xsl:value-of select="$reftitle"/>
360 <xsl:when test="$section.level = 2">
361 <fo:block xsl:use-attribute-sets="refentry.title.properties">
362 <fo:block xsl:use-attribute-sets="section.title.level2.properties">
363 <xsl:value-of select="$reftitle"/>
367 <xsl:when test="$section.level = 3">
368 <fo:block xsl:use-attribute-sets="refentry.title.properties">
369 <fo:block xsl:use-attribute-sets="section.title.level3.properties">
370 <xsl:value-of select="$reftitle"/>
374 <xsl:when test="$section.level = 4">
375 <fo:block xsl:use-attribute-sets="refentry.title.properties">
376 <fo:block xsl:use-attribute-sets="section.title.level4.properties">
377 <xsl:value-of select="$reftitle"/>
381 <xsl:when test="$section.level = 5">
382 <fo:block xsl:use-attribute-sets="refentry.title.properties">
383 <fo:block xsl:use-attribute-sets="section.title.level5.properties">
384 <xsl:value-of select="$reftitle"/>
389 <fo:block xsl:use-attribute-sets="refentry.title.properties">
390 <fo:block xsl:use-attribute-sets="section.title.level6.properties">
391 <xsl:value-of select="$reftitle"/>
399 <xsl:if test="not(following-sibling::refnamediv)">
400 <xsl:attribute name="space-after">1em</xsl:attribute>
402 <xsl:apply-templates/>
407 <xsl:template match="refname">
408 <xsl:if test="not(preceding-sibling::refdescriptor)">
409 <xsl:apply-templates/>
410 <xsl:if test="following-sibling::refname">
411 <xsl:text>, </xsl:text>
416 <xsl:template match="refpurpose">
417 <xsl:if test="node()">
418 <xsl:text> </xsl:text>
419 <xsl:call-template name="dingbat">
420 <xsl:with-param name="dingbat">em-dash</xsl:with-param>
422 <xsl:text> </xsl:text>
423 <xsl:apply-templates/>
427 <xsl:template match="refdescriptor">
428 <xsl:apply-templates/>
431 <xsl:template match="refclass">
432 <xsl:if test="$refclass.suppress = 0">
433 <fo:block font-weight="bold">
434 <xsl:if test="@role">
435 <xsl:value-of select="@role"/>
436 <xsl:text>: </xsl:text>
438 <xsl:apply-templates/>
443 <xsl:template match="refsynopsisdiv">
444 <xsl:variable name="id">
445 <xsl:call-template name="object.id"/>
448 <fo:block id="{$id}">
449 <xsl:if test="not(refsynopsisdivinfo/title|docinfo/title|info/title|title)">
450 <!-- * if we there is no appropriate title for this Refsynopsisdiv, -->
451 <!-- * then we need to call format.refentry.subheading to generate one -->
452 <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
453 xsl:use-attribute-sets="refsynopsisdiv.titlepage.recto.style"
454 font-family="{$title.fontset}">
455 <!-- Contents of what is now the format.refentry.subheading -->
456 <!-- template were formerly intended to be used only to -->
457 <!-- process those subsections of Refentry that have "real" -->
458 <!-- title children. So as a kludge to get around the fact -->
459 <!-- that the template still basically "expects" to be -->
460 <!-- processing that kind of a node, when we call the -->
461 <!-- template to process generated titles, we must call it -->
462 <!-- with values for the "offset" and "section" parameters -->
463 <!-- that are different from the default values in the -->
464 <!-- format.refentry.subheading template itself. Because -->
465 <!-- those defaults are the values appropriate for processing -->
466 <!-- "real" title nodes. -->
467 <xsl:call-template name="format.refentry.subheading">
468 <xsl:with-param name="section" select="parent::*"/>
469 <xsl:with-param name="offset" select="1"/>
470 <xsl:with-param name="gentext.key" select="'RefSynopsisDiv'"/>
474 <xsl:call-template name="refsynopsisdiv.titlepage"/>
475 <xsl:apply-templates/>
479 <xsl:template match="refsection">
480 <xsl:variable name="id">
481 <xsl:call-template name="object.id"/>
484 <fo:block id="{$id}">
485 <xsl:call-template name="refsection.titlepage"/>
486 <xsl:apply-templates/>
490 <xsl:template match="refsect1">
491 <xsl:variable name="id">
492 <xsl:call-template name="object.id"/>
495 <fo:block id="{$id}">
496 <xsl:call-template name="refsect1.titlepage"/>
497 <xsl:apply-templates/>
501 <xsl:template match="refsect2">
502 <xsl:variable name="id">
503 <xsl:call-template name="object.id"/>
506 <fo:block id="{$id}">
507 <xsl:call-template name="refsect2.titlepage"/>
508 <xsl:apply-templates/>
512 <xsl:template match="refsect3">
513 <xsl:variable name="id">
514 <xsl:call-template name="object.id"/>
517 <fo:block id="{$id}">
518 <xsl:call-template name="refsect3.titlepage"/>
519 <xsl:apply-templates/>
523 <xsl:template match="refsynopsisdiv/title
528 <!-- nop; titlepage.mode instead -->
531 <xsl:template match="refsynopsisdiv/title
536 |refsynopsisdiv/info/title
537 |refsection/info/title
540 |refsect3/info/title"
541 mode="titlepage.mode"
543 <xsl:call-template name="format.refentry.subheading"/>
546 <xsl:template name="format.refentry.subheading">
547 <!-- This template is now called to process generated titles for -->
548 <!-- Refnamediv and Refsynopsisdiv, as well as "real" titles for -->
549 <!-- Refsynopsisdiv, Refsection, and Refsect[1-3]. -->
551 <!-- But the contents of this template were formerly intended to be used -->
552 <!-- only to process those subsections of Refentry that have "real" title -->
553 <!-- children. So as a kludge to get around the fact that the template -->
554 <!-- still basically "expects" to be processing that kind of a node, the -->
555 <!-- "offset" parameter was added and the "section" variable was changed to -->
556 <!-- a parameter so that when called for a generated title on a Refnamediv -->
557 <!-- or Refsynopsisdiv, we can call it like this: -->
559 <!-- <xsl:call-template name="format.refentry.subheading"> -->
560 <!-- <xsl:with-param name="section" select="self::*"/> -->
561 <!-- <xsl:with-param name="offset" select="1"/> -->
562 <!-- <xsl:with-param name="gentext.key" select="'RefName'"/> -->
563 <!-- </xsl:call-template> -->
565 <xsl:param name="section"
566 select="(ancestor::refsynopsisdiv
567 |ancestor::refsection
570 |ancestor::refsect3)[last()]"/>
571 <xsl:param name="offset" select="0"/>
572 <xsl:param name="gentext.key"/>
574 <fo:block keep-with-next.within-column="always">
575 <xsl:variable name="id">
576 <xsl:call-template name="object.id">
577 <xsl:with-param name="object" select="$section"/>
581 <xsl:variable name="level">
582 <xsl:call-template name="section.level">
583 <xsl:with-param name="node" select="$section"/>
587 <xsl:variable name="title">
588 <!-- If we have a non-empty value for the $gentext.key param, then we -->
589 <!-- generate an appropriate title here. Otherwise, we have a real -->
590 <!-- title child, so we copy contents of that to the result tree. -->
592 <xsl:when test="$gentext.key != ''">
593 <xsl:call-template name="gentext">
594 <xsl:with-param name="key" select="$gentext.key"/>
598 <xsl:apply-templates select="$section" mode="object.title.markup">
599 <xsl:with-param name="allow-anchors" select="1"/>
600 </xsl:apply-templates>
605 <xsl:if test="$passivetex.extensions != 0">
606 <fotex:bookmark xmlns:fotex="http://www.tug.org/fotex"
607 fotex-bookmark-level="{$level + 2 + $offset}"
608 fotex-bookmark-label="{$id}">
609 <xsl:value-of select="$title"/>
613 <xsl:if test="$axf.extensions != 0">
614 <xsl:attribute name="axf:outline-level">
615 <xsl:value-of select="count(ancestor::*)-1 + $offset"/>
617 <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
618 <xsl:attribute name="axf:outline-title">
619 <xsl:value-of select="$title"/>
623 <xsl:call-template name="section.heading">
624 <xsl:with-param name="level" select="$level + $offset"/>
625 <xsl:with-param name="title" select="$title"/>
630 <xsl:template match="refsectioninfo|refsection/info"></xsl:template>
631 <xsl:template match="refsect1info|refsect1/info"></xsl:template>
632 <xsl:template match="refsect2info|refsect2/info"></xsl:template>
633 <xsl:template match="refsect3info|refsect3/info"></xsl:template>
635 <!-- ==================================================================== -->