]> granicus.if.org Git - docbook-dsssl/commitdiff
Corrected formatting of generated "Name" title in refentry output
authorMichael Smith <xmldoc@users.sourceforge.net>
Wed, 1 Jun 2005 10:25:17 +0000 (10:25 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Wed, 1 Jun 2005 10:25:17 +0000 (10:25 +0000)
(closes #1212396; thanks to Andreas Lalloo for reporting the
problem).

:Problem::
The "Name" title generated for FO output of Refnamediv in Refentry
is not aligned flush left, as all the other subheadings of
Refentry are, and as the generated Name subheading for Refentry is
in HTML output. Also, the Name title is in a larger font size than
the titles of the other first-level children of Refentry.

:Fix::
The "Name" title generated for FO output of Refnamediv in Refentry
is now handled using the same formatting as that used for all
other first-level children of Refentry.

::Affects:
Along with affecting processing for generated titles for
Refnamediv in FO output, it is possible that this change may have
unanticipated side effects on processing of titles for
Refsynopsisdiv, Refsection, and Refsect1 to Refsect3. The reason
is that part of this change takes the template contents formerly
used only for processing Refsynopsisdiv, Refsection, and Refsect1
to Refsect3, and "repurposes" those template contents for use in
processing the generated title for Refnamediv.

xsl/fo/refentry.xsl
xsl/fo/titlepage.xsl

index 0712d0dc1363fb81ef95f5e6b039a68494177232..78c7061d4cd5647ef432d4f957b58147eb0f4c77 100644 (file)
 </xsl:template>
 
 <xsl:template match="refnamediv">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <fo:block id="{$id}">
+
+    <!-- if refentry.generate.name is non-zero, then we need to generate a -->
+    <!-- localized "Name" subheading for this refnamdiv (unless it has a -->
+    <!-- preceding sibling that is a refnamediv, in which case we have already -->
+    <!-- generated a "Name" subheading, so we don't need to do it again -->
+    <xsl:if test="$refentry.generate.name != 0">
+        <xsl:choose>
+          <xsl:when test="preceding-sibling::refnamediv">
+            <!-- no generated title on secondary refnamedivs! -->
+          </xsl:when>
+          <xsl:otherwise>
+            <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                      xsl:use-attribute-sets="refnamediv.titlepage.recto.style"
+                      font-family="{$title.fontset}">
+              <!-- Contents of what is now the format.refentry.subheading -->
+              <!-- template were formerly intended to be used only to -->
+              <!-- process those subsections of Refentry that have "real" -->
+              <!-- title children. So as a kludge to get around the fact -->
+              <!-- that the template still basically "expects" to be -->
+              <!-- processing that kind of a node, when we call the -->
+              <!-- template to process generated titles, we must call it -->
+              <!-- with values for the "offset" and "section" parameters -->
+              <!-- that are different from the default values in the -->
+              <!-- format.refentry.subheading template itself. Because -->
+              <!-- those defaults are the values appropriate for processing -->
+              <!-- "real" title nodes. -->
+              <xsl:call-template name="format.refentry.subheading">
+                <xsl:with-param name="section" select="self::*"/>
+                <xsl:with-param name="offset" select="1"/>
+                <xsl:with-param name="gentext.key" select="'RefName'"/>
+              </xsl:call-template>
+            </fo:block>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:if>
+
+      <xsl:if test="$refentry.generate.title != 0">
   <xsl:variable name="section.level">
     <xsl:call-template name="refentry.level">
       <xsl:with-param name="node" select="ancestor::refentry"/>
   </xsl:variable>
 
   <xsl:variable name="reftitle">
-    <xsl:choose>
-      <xsl:when test="$refentry.generate.name != 0">
-        <xsl:call-template name="gentext">
-          <xsl:with-param name="key" select="'RefName'"/>
-        </xsl:call-template>
-      </xsl:when>
-      <xsl:when test="$refentry.generate.title != 0">
         <xsl:choose>
           <xsl:when test="../refmeta/refentrytitle">
             <xsl:apply-templates select="../refmeta/refentrytitle"/>
             <xsl:apply-templates select="refname[1]"/>
           </xsl:otherwise>
         </xsl:choose>
-      </xsl:when>
-    </xsl:choose>
   </xsl:variable>
 
   <!-- xsl:use-attribute-sets takes only a Qname, not a variable -->
-  <fo:block>
     <xsl:choose>
       <xsl:when test="preceding-sibling::refnamediv">
        <!-- no title on secondary refnamedivs! -->
         </fo:block>
       </xsl:otherwise>
     </xsl:choose>
+    </xsl:if>
 
     <fo:block>
       <xsl:if test="not(following-sibling::refnamediv)">
                      |refsect3/title"
               mode="titlepage.mode"
               priority="2">
-  <xsl:variable name="section" select="parent::*"/>
+  <xsl:call-template name="format.refentry.subheading"/>
+</xsl:template>
+
+<xsl:template name="format.refentry.subheading">
+<!-- This template is now called to process generated titles for -->
+<!-- Refnamediv and Refsynopsisdiv, as well as "real" titles for -->
+<!-- Refsynopsisdiv, Refsection, and Refsect[1-3]. -->
+<!-- -->
+<!-- But the contents of this template were formerly intended to be used -->
+<!-- only to process those subsections of Refentry that have "real" title -->
+<!-- children. So as a kludge to get around the fact that the template -->
+<!-- still basically "expects" to be processing that kind of a node, the -->
+<!-- "offset" parameter was added and the "section" variable was changed to -->
+<!-- a parameter so that when called for a generated title on a Refnamediv -->
+<!-- or Refsynopsisdiv, we can call it like this: -->
+<!-- -->
+<!--     <xsl:call-template name="format.refentry.subheading"> -->
+<!--       <xsl:with-param name="section" select="self::*"/> -->
+<!--       <xsl:with-param name="offset" select="1"/> -->
+<!--       <xsl:with-param name="gentext.key" select="'RefName'"/> -->
+<!--     </xsl:call-template> -->
+<!-- -->
+  <xsl:param name="section" select="parent::*"/>
+  <xsl:param name="offset" select="0"/>
+  <xsl:param name="gentext.key"/>
+
   <fo:block keep-with-next.within-column="always">
     <xsl:variable name="id">
       <xsl:call-template name="object.id">
     </xsl:variable>
 
     <xsl:variable name="title">
-      <xsl:apply-templates select="$section" mode="object.title.markup">
-        <xsl:with-param name="allow-anchors" select="1"/>
-      </xsl:apply-templates>
+      <!-- If we have a non-empty value for the $gentext.key param, then we -->
+      <!-- generate an appropriate title here. Otherwise, we have a real -->
+      <!-- title child, so we copy contents of that to the result tree. -->
+      <xsl:choose>
+        <xsl:when test="$gentext.key != ''">
+          <xsl:call-template name="gentext">
+            <xsl:with-param name="key" select="$gentext.key"/>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="$section" mode="object.title.markup">
+            <xsl:with-param name="allow-anchors" select="1"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:variable>
 
     <xsl:if test="$passivetex.extensions != 0">
       <fotex:bookmark xmlns:fotex="http://www.tug.org/fotex" 
-                      fotex-bookmark-level="{$level + 2}" 
+                      fotex-bookmark-level="{$level + 2 + $offset}" 
                       fotex-bookmark-label="{$id}">
         <xsl:value-of select="$title"/>
       </fotex:bookmark>
 
     <xsl:if test="$axf.extensions != 0">
       <xsl:attribute name="axf:outline-level">
-        <xsl:value-of select="count(ancestor::*)-1"/>
+        <xsl:value-of select="count(ancestor::*)-1 + $offset"/>
       </xsl:attribute>
       <xsl:attribute name="axf:outline-expand">false</xsl:attribute>
       <xsl:attribute name="axf:outline-title">
-        <xsl:value-of select="normalize-space($title)"/>
+        <xsl:value-of select="$title"/>
       </xsl:attribute>
     </xsl:if>
 
     <xsl:call-template name="section.heading">
-      <xsl:with-param name="level" select="$level"/>
+      <xsl:with-param name="level" select="$level + $offset"/>
       <xsl:with-param name="title" select="$title"/>
     </xsl:call-template>
   </fo:block>
index b7a4f1a3bdd415e684a72e1c9af7a8a8608eb5cc..d28a63d902183d670074c49069ddb9a871a33a39 100644 (file)
 <xsl:attribute-set name="simplesect.titlepage.verso.style"
                    use-attribute-sets="section.titlepage.verso.style"/>
 
+<xsl:attribute-set name="refnamediv.titlepage.recto.style"
+                   use-attribute-sets="section.titlepage.recto.style"/>
+<xsl:attribute-set name="refnamediv.titlepage.verso.style"
+                   use-attribute-sets="section.titlepage.verso.style"/>
+
 <xsl:attribute-set name="refsynopsisdiv.titlepage.recto.style"
                    use-attribute-sets="section.titlepage.recto.style"/>
 <xsl:attribute-set name="refsynopsisdiv.titlepage.verso.style"