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 8598 2010-03-20 09:59:03Z 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">
 
 271   <xsl:apply-templates select=".//indexterm"/>
 
 274 <xsl:template match="manvolnum">
 
 275   <xsl:if test="$refentry.xref.manvolnum != 0">
 
 276     <xsl:text>(</xsl:text>
 
 277     <xsl:apply-templates/>
 
 278     <xsl:text>)</xsl:text>
 
 282 <xsl:template match="refmiscinfo">
 
 285 <xsl:template match="refentrytitle">
 
 286   <xsl:call-template name="inline.charseq"/>
 
 289 <xsl:template match="refnamediv">
 
 290   <xsl:variable name="id">
 
 291     <xsl:call-template name="object.id"/>
 
 294   <fo:block id="{$id}">
 
 296     <!-- if refentry.generate.name is non-zero, then we need to generate a -->
 
 297     <!-- localized "Name" subheading for this refnamdiv (unless it has a -->
 
 298     <!-- preceding sibling that is a refnamediv, in which case we have already -->
 
 299     <!-- generated a "Name" subheading, so we don't need to do it again -->
 
 300     <xsl:if test="$refentry.generate.name != 0">
 
 302           <xsl:when test="preceding-sibling::refnamediv">
 
 303             <!-- no generated title on secondary refnamedivs! -->
 
 306             <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
 
 307                       xsl:use-attribute-sets="refnamediv.titlepage.recto.style"
 
 308                       font-family="{$title.fontset}">
 
 309               <!-- Contents of what is now the format.refentry.subheading -->
 
 310               <!-- template were formerly intended to be used only to -->
 
 311               <!-- process those subsections of Refentry that have "real" -->
 
 312               <!-- title children. So as a kludge to get around the fact -->
 
 313               <!-- that the template still basically "expects" to be -->
 
 314               <!-- processing that kind of a node, when we call the -->
 
 315               <!-- template to process generated titles, we must call it -->
 
 316               <!-- with values for the "offset" and "section" parameters -->
 
 317               <!-- that are different from the default values in the -->
 
 318               <!-- format.refentry.subheading template itself. Because -->
 
 319               <!-- those defaults are the values appropriate for processing -->
 
 320               <!-- "real" title nodes. -->
 
 321               <xsl:call-template name="format.refentry.subheading">
 
 322                 <xsl:with-param name="section" select="self::*"/>
 
 323                 <xsl:with-param name="offset" select="1"/>
 
 324                 <xsl:with-param name="gentext.key" select="'RefName'"/>
 
 331       <xsl:if test="$refentry.generate.title != 0">
 
 332   <xsl:variable name="section.level">
 
 333     <xsl:call-template name="refentry.level">
 
 334       <xsl:with-param name="node" select="ancestor::refentry"/>
 
 338   <xsl:variable name="reftitle">
 
 340           <xsl:when test="../refmeta/refentrytitle">
 
 341             <xsl:apply-templates select="../refmeta/refentrytitle"/>
 
 344             <xsl:apply-templates select="refname[1]"/>
 
 349   <!-- xsl:use-attribute-sets takes only a Qname, not a variable -->
 
 351       <xsl:when test="preceding-sibling::refnamediv">
 
 352         <!-- no title on secondary refnamedivs! -->
 
 354       <xsl:when test="$section.level = 1">
 
 355         <fo:block xsl:use-attribute-sets="refentry.title.properties">
 
 356           <fo:block xsl:use-attribute-sets="section.title.level1.properties">
 
 357             <xsl:value-of select="$reftitle"/>
 
 361       <xsl:when test="$section.level = 2">
 
 362         <fo:block xsl:use-attribute-sets="refentry.title.properties">
 
 363           <fo:block xsl:use-attribute-sets="section.title.level2.properties">
 
 364             <xsl:value-of select="$reftitle"/>
 
 368       <xsl:when test="$section.level = 3">
 
 369         <fo:block xsl:use-attribute-sets="refentry.title.properties">
 
 370           <fo:block xsl:use-attribute-sets="section.title.level3.properties">
 
 371             <xsl:value-of select="$reftitle"/>
 
 375       <xsl:when test="$section.level = 4">
 
 376         <fo:block xsl:use-attribute-sets="refentry.title.properties">
 
 377           <fo:block xsl:use-attribute-sets="section.title.level4.properties">
 
 378             <xsl:value-of select="$reftitle"/>
 
 382       <xsl:when test="$section.level = 5">
 
 383         <fo:block xsl:use-attribute-sets="refentry.title.properties">
 
 384           <fo:block xsl:use-attribute-sets="section.title.level5.properties">
 
 385             <xsl:value-of select="$reftitle"/>
 
 390         <fo:block xsl:use-attribute-sets="refentry.title.properties">
 
 391           <fo:block xsl:use-attribute-sets="section.title.level6.properties">
 
 392             <xsl:value-of select="$reftitle"/>
 
 400       <xsl:if test="not(following-sibling::refnamediv)">
 
 401         <xsl:attribute name="space-after">1em</xsl:attribute>
 
 403       <xsl:apply-templates/>
 
 408 <xsl:template match="refname">
 
 409   <xsl:if test="not(preceding-sibling::refdescriptor)">
 
 410     <xsl:apply-templates/>
 
 411     <xsl:if test="following-sibling::refname">
 
 412       <xsl:text>, </xsl:text>
 
 417 <xsl:template match="refpurpose">
 
 418   <xsl:if test="node()">
 
 419     <xsl:text> </xsl:text>
 
 420     <xsl:call-template name="dingbat">
 
 421       <xsl:with-param name="dingbat">em-dash</xsl:with-param>
 
 423     <xsl:text> </xsl:text>
 
 424     <xsl:apply-templates/>
 
 428 <xsl:template match="refdescriptor">
 
 429   <xsl:apply-templates/>
 
 432 <xsl:template match="refclass">
 
 433   <xsl:if test="$refclass.suppress = 0">
 
 434   <fo:block font-weight="bold">
 
 435     <xsl:if test="@role">
 
 436       <xsl:value-of select="@role"/>
 
 437       <xsl:text>: </xsl:text>
 
 439     <xsl:apply-templates/>
 
 444 <xsl:template match="refsynopsisdiv">
 
 445   <xsl:variable name="id">
 
 446     <xsl:call-template name="object.id"/>
 
 449   <fo:block id="{$id}">
 
 450     <xsl:if test="not(refsynopsisdivinfo/title|docinfo/title|info/title|title)">
 
 451       <!-- * if we there is no appropriate title for this Refsynopsisdiv, -->
 
 452       <!-- * then we need to call format.refentry.subheading to generate one -->
 
 453       <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
 
 454                 xsl:use-attribute-sets="refsynopsisdiv.titlepage.recto.style"
 
 455                 font-family="{$title.fontset}">
 
 456         <!-- Contents of what is now the format.refentry.subheading -->
 
 457         <!-- template were formerly intended to be used only to -->
 
 458         <!-- process those subsections of Refentry that have "real" -->
 
 459         <!-- title children. So as a kludge to get around the fact -->
 
 460         <!-- that the template still basically "expects" to be -->
 
 461         <!-- processing that kind of a node, when we call the -->
 
 462         <!-- template to process generated titles, we must call it -->
 
 463         <!-- with values for the "offset" and "section" parameters -->
 
 464         <!-- that are different from the default values in the -->
 
 465         <!-- format.refentry.subheading template itself. Because -->
 
 466         <!-- those defaults are the values appropriate for processing -->
 
 467         <!-- "real" title nodes. -->
 
 468         <xsl:call-template name="format.refentry.subheading">
 
 469           <xsl:with-param name="section" select="parent::*"/>
 
 470           <xsl:with-param name="offset" select="1"/>
 
 471           <xsl:with-param name="gentext.key" select="'RefSynopsisDiv'"/>
 
 475     <xsl:call-template name="refsynopsisdiv.titlepage"/>
 
 476     <xsl:apply-templates/>
 
 480 <xsl:template match="refsection">
 
 481   <xsl:variable name="id">
 
 482     <xsl:call-template name="object.id"/>
 
 485   <fo:block id="{$id}">
 
 486     <xsl:call-template name="refsection.titlepage"/>
 
 487     <xsl:apply-templates/>
 
 491 <xsl:template match="refsect1">
 
 492   <xsl:variable name="id">
 
 493     <xsl:call-template name="object.id"/>
 
 496   <fo:block id="{$id}">
 
 497     <xsl:call-template name="refsect1.titlepage"/>
 
 498     <xsl:apply-templates/>
 
 502 <xsl:template match="refsect2">
 
 503   <xsl:variable name="id">
 
 504     <xsl:call-template name="object.id"/>
 
 507   <fo:block id="{$id}">
 
 508     <xsl:call-template name="refsect2.titlepage"/>
 
 509     <xsl:apply-templates/>
 
 513 <xsl:template match="refsect3">
 
 514   <xsl:variable name="id">
 
 515     <xsl:call-template name="object.id"/>
 
 518   <fo:block id="{$id}">
 
 519     <xsl:call-template name="refsect3.titlepage"/>
 
 520     <xsl:apply-templates/>
 
 524 <xsl:template match="refsynopsisdiv/title
 
 529   <!-- nop; titlepage.mode instead -->
 
 532 <xsl:template match="refsynopsisdiv/title
 
 537                      |refsynopsisdiv/info/title
 
 538                      |refsection/info/title
 
 541                      |refsect3/info/title"
 
 542               mode="titlepage.mode"
 
 544   <xsl:call-template name="format.refentry.subheading"/>
 
 547 <xsl:template name="format.refentry.subheading">
 
 548 <!-- This template is now called to process generated titles for -->
 
 549 <!-- Refnamediv and Refsynopsisdiv, as well as "real" titles for -->
 
 550 <!-- Refsynopsisdiv, Refsection, and Refsect[1-3]. -->
 
 552 <!-- But the contents of this template were formerly intended to be used -->
 
 553 <!-- only to process those subsections of Refentry that have "real" title -->
 
 554 <!-- children. So as a kludge to get around the fact that the template -->
 
 555 <!-- still basically "expects" to be processing that kind of a node, the -->
 
 556 <!-- "offset" parameter was added and the "section" variable was changed to -->
 
 557 <!-- a parameter so that when called for a generated title on a Refnamediv -->
 
 558 <!-- or Refsynopsisdiv, we can call it like this: -->
 
 560 <!--     <xsl:call-template name="format.refentry.subheading"> -->
 
 561 <!--       <xsl:with-param name="section" select="self::*"/> -->
 
 562 <!--       <xsl:with-param name="offset" select="1"/> -->
 
 563 <!--       <xsl:with-param name="gentext.key" select="'RefName'"/> -->
 
 564 <!--     </xsl:call-template> -->
 
 566   <xsl:param name="section" 
 
 567              select="(ancestor::refsynopsisdiv 
 
 568                      |ancestor::refsection
 
 571                      |ancestor::refsect3)[last()]"/>
 
 572   <xsl:param name="offset" select="0"/>
 
 573   <xsl:param name="gentext.key"/>
 
 575   <fo:block keep-with-next.within-column="always">
 
 576     <xsl:variable name="id">
 
 577       <xsl:call-template name="object.id">
 
 578         <xsl:with-param name="object" select="$section"/>
 
 582     <xsl:variable name="level">
 
 583       <xsl:call-template name="section.level">
 
 584         <xsl:with-param name="node" select="$section"/>
 
 588     <xsl:variable name="title">
 
 589       <!-- If we have a non-empty value for the $gentext.key param, then we -->
 
 590       <!-- generate an appropriate title here. Otherwise, we have a real -->
 
 591       <!-- title child, so we copy contents of that to the result tree. -->
 
 593         <xsl:when test="$gentext.key != ''">
 
 594           <xsl:call-template name="gentext">
 
 595             <xsl:with-param name="key" select="$gentext.key"/>
 
 599           <xsl:apply-templates select="$section" mode="object.title.markup">
 
 600             <xsl:with-param name="allow-anchors" select="1"/>
 
 601           </xsl:apply-templates>
 
 606     <xsl:if test="$passivetex.extensions != 0">
 
 607       <fotex:bookmark xmlns:fotex="http://www.tug.org/fotex" 
 
 608                       fotex-bookmark-level="{$level + 2 + $offset}" 
 
 609                       fotex-bookmark-label="{$id}">
 
 610         <xsl:value-of select="$title"/>
 
 614     <xsl:if test="$axf.extensions != 0">
 
 615       <xsl:attribute name="axf:outline-level">
 
 616         <xsl:value-of select="count(ancestor::*)-1 + $offset"/>
 
 618       <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
 
 619       <xsl:attribute name="axf:outline-title">
 
 620         <xsl:value-of select="$title"/>
 
 624     <xsl:call-template name="section.heading">
 
 625       <xsl:with-param name="level" select="$level + $offset"/>
 
 626       <xsl:with-param name="title" select="$title"/>
 
 631 <xsl:template match="refsectioninfo|refsection/info"></xsl:template>
 
 632 <xsl:template match="refsect1info|refsect1/info"></xsl:template>
 
 633 <xsl:template match="refsect2info|refsect2/info"></xsl:template>
 
 634 <xsl:template match="refsect3info|refsect3/info"></xsl:template>
 
 636 <!-- ==================================================================== -->