Next in thread → Next in month →

Re: [docbook-apps] Indents for index entries using DocBook 5 and FOP

From
Bob Stayton <>
Date
2012-03-15T16:22:40+00:00
ID
01c301cd02c7$d37b40f0$6600a8c0@pazu
Thread
Re: [docbook-apps] Indents for index entries using DocBook 5 and FOP
Hi Jeff,

I think the entries are missing because this line 
is missing its namespace prefix:

 

<xsl:value-of select="primary"/>

 

Since that line actually renders the text of the 
indexterm, that's why your entries disappeared.

 

Regarding the page indent, the template named 
'set.flow.properties' in fo/pagesetup.xsl could be customized to do that. That 
template sets the body indent for an entire page-sequence, and that's where the 
index is excluded from that feature.

 

Bob Stayton
Sagehill Enterprises


 

 

  
----- Original Message ----- 

  
From: 
  Jeff 
  Powanda 

  
To:  
  

  
Sent: Wednesday, March 14, 2012 11:04 
  PM

  
Subject: [docbook-apps] Indents for index 
  entries using DocBook 5 and FOP

  

  
 

  
When I upgraded my stylesheet from DocBook 4.5 to 5.0, I 
  added the "d:" namespace prefix where appropriate and tried it out. In the 
  book's index, the index entries vanished. Only the group headings appeared in 
  the index. Weird.

  
 

  
Here are the templates I had updated. I tried deleting the 
  indexterm templates from my stylesheet, and the index now generates with index 
  entries, but the custom indents are gone. All I'm trying to do is indent the 
  index 1.25 inches, the same as the body.start.indent parameter. What's the 
  easiest way to do that?

  
 

  
        <xsl:param name="generate.index">1</xsl:param>

  
        

  
        <!-- Specify number of columns in index. 
  -->

  
        <xsl:param name="column.count.index">1</xsl:param>

  
        

  
        <xsl:attribute-set name="index.div.title.properties">

  
                
  <xsl:attribute name="font-family">

  
                        
  <xsl:value-of select="$title.font.family" 
  />

  
                
  </xsl:attribute>

  
                
  <xsl:attribute name="margin-left">1.25in</xsl:attribute>

  
                
  <xsl:attribute name="start-indent">1.25in</xsl:attribute>

  
                
  <xsl:attribute name="line-height">14pt</xsl:attribute> 

  
                
  <xsl:attribute name="font-size">12pt</xsl:attribute>

  
                
  <xsl:attribute name="font-weight">normal</xsl:attribute>

  
                
  <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>

  
        </xsl:attribute-set>

  
        

  
        <xsl:attribute-set name="index.entry.properties">

  
                
  <xsl:attribute name="font-family">

  
                        
  <xsl:value-of select="$body.font.family" 
  />

  
                
  </xsl:attribute>

  
                
  <xsl:attribute name="margin-left">1.25in</xsl:attribute> 

  
                
  <xsl:attribute name="line-height">12pt</xsl:attribute>

  
                
  <xsl:attribute name="font-size">10pt</xsl:attribute>

  
                
  <xsl:attribute name="font-weight">normal</xsl:attribute>

  
        </xsl:attribute-set>

  
 

  
<xsl:template match="d:indexterm" mode="index-primary">

  
  <xsl:param name="scope" select="."/>

  
  <xsl:param name="role" select="''"/>

  
  <xsl:param name="type" select="''"/>

  
 

  
  <xsl:variable name="key" select="&primary;"/>

  
  <xsl:variable name="refs" select="key('primary', 
  $key)[&scope;]"/>

  
  <fo:block>

  
    <xsl:if test="$axf.extensions != 
  0">

  
      <xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>

  
    </xsl:if>

  
    <xsl:value-of select="primary"/>

  
 

  
    <xsl:choose>

  
      <xsl:when test="$xep.extensions != 
  0">

  
        <xsl:if test="$refs[not(d:see) and 
  not(d:secondary)]">

  
          
  <xsl:text>, </xsl:text>

  
          
  <xsl:variable name="primary" select="&primary;"/>

  
          
  <xsl:variable name="primary.significant" 
  select="concat(&primary;, $significant.flag)"/>

  
          
  <rx:page-index>

  
            
  <xsl:if test="$refs[@significance='preferred'][not(d:see) and 
  not(d:secondary)]">

  
              
  <rx:index-item xsl:use-attribute-sets="index.preferred.page.properties 
  xep.index.item.properties"

  
                
  ref-key="{$primary.significant}"/>

  
            
  </xsl:if>

  
            
  <xsl:if test="$refs[not(@significance) or 
  @significance!='preferred'][not(d:see) and not(d:secondary)]">

  
              
  <rx:index-item xsl:use-attribute-sets="xep.index.item.properties"

  
                
  ref-key="{$primary}"/>

  
            
  </xsl:if>

  
          
  </rx:page-index>        
  

  
        </xsl:if>

  
      </xsl:when>

  
      <xsl:otherwise>

  
        <xsl:variable name="page-number-citations">

  
          
  <xsl:for-each select="$refs[not(d:see) 
  

  
                                
  and not(d:secondary)]">

  
            
  <xsl:apply-templates 
  select="." mode="reference">

  
              
  <xsl:with-param name="scope" select="$scope"/>

  
              
  <xsl:with-param name="role" select="$role"/>

  
              
  <xsl:with-param name="type" select="$type"/>

  
            
  </xsl:apply-templates>

  
          
  </xsl:for-each>

  
        </xsl:variable>

  
 

  
        <xsl:choose>

  
          
  <xsl:when test="$passivetex.extensions != 
  '0'">

  
            
  <fotex:sort xmlns:fotex="http://www.tug.org/fotex">

  
              
  <xsl:copy-of select="$page-number-citations"/>

  
            
  </fotex:sort>

  
          
  </xsl:when>

  
          
  <xsl:otherwise>

  
            
  <xsl:copy-of select="$page-number-citations"/>

  
          
  </xsl:otherwise>

  
        </xsl:choose>

  
      </xsl:otherwise>

  
    </xsl:choose>

  
 

  
    <xsl:if test="$refs[not(d:secondary)]/*[self::d:see]">

  
      <xsl:apply-templates select="$refs[generate-id() = 
  generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, 
  d:see))[&scope;][1])]"

  
                           
  mode="index-see">

  
         <xsl:with-param name="scope" select="$scope"/>

  
         <xsl:with-param name="role" select="$role"/>

  
         <xsl:with-param name="type" select="$type"/>

  
         <xsl:sort select="translate(d:see, 
  &lowercase;, &uppercase;)"/>

  
      </xsl:apply-templates>

  
    </xsl:if>

  
 

  
  </fo:block>

  
 

  
  <xsl:if test="$refs/d:secondary or 
  $refs[not(d:secondary)]/*[self::d:seealso]">

  
  <!-- 
  Customize indent -->

  
<fo:block start-indent="1.5in">

  
      <xsl:apply-templates select="$refs[generate-id() = 
  generate-id(key('see-also', concat(&primary;, &sep;, &sep;, 
  &sep;, d:seealso))[&scope;][1])]"

  
                           
  mode="index-seealso">

  
         <xsl:with-param name="scope" select="$scope"/>

  
         <xsl:with-param name="role" select="$role"/>

  
         <xsl:with-param name="type" select="$type"/>

  
         <xsl:sort select="translate(d:seealso, 
  &lowercase;, &uppercase;)"/>

  
      </xsl:apply-templates>

  
      <xsl:apply-templates select="$refs[d:secondary and 
  count(.|key('secondary', concat($key, &sep;, 
  &secondary;))[&scope;][1]) = 1]"

  
                           
  mode="index-secondary">

  
       
  <xsl:with-param name="scope" select="$scope"/>

  
       
  <xsl:with-param name="role" select="$role"/>

  
       
  <xsl:with-param name="type" select="$type"/>

  
       
  <xsl:sort select="translate(&secondary;, 
  &lowercase;, &uppercase;)"/>

  
      </xsl:apply-templates>

  
    </fo:block>

  
  </xsl:if>

  
</xsl:template>

  
 

  
<xsl:template match="indexterm" mode="index-secondary">

  
  <xsl:param name="scope" select="."/>

  
  <xsl:param name="role" select="''"/>

  
  <xsl:param name="type" select="''"/>

  
 

  
  <xsl:variable name="key" select="concat(&primary;, 
  &sep;, &secondary;)"/>

  
  <xsl:variable name="refs" select="key('secondary', 
  $key)[&scope;]"/>

  
  <!-- 
  Customize indent -->

  
  <fo:block start-indent="1.5in">

  
    <xsl:if test="$axf.extensions != 
  0">

  
      <xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>

  
    </xsl:if>

  
    <xsl:value-of select="secondary"/>

  
 

  
    <xsl:choose>

  
      <xsl:when test="$xep.extensions != 
  0">

  
        <xsl:if test="$refs[not(d:see) and 
  not(d:tertiary)]">

  
          
  <xsl:text>, </xsl:text>

  
          
  <xsl:variable name="primary" select="&primary;"/>

  
          
  <xsl:variable name="secondary" select="&secondary;"/>

  
          
  <xsl:variable name="primary.significant" 
  select="concat(&primary;, $significant.flag)"/>

  
          
  <rx:page-index>

  
            
  <xsl:if test="$refs[@significance='preferred'][not(d:see) and 
  not(d:tertiary)]">

  
              
  <rx:index-item xsl:use-attribute-sets="index.preferred.page.properties 
  xep.index.item.properties">

  
                
  <xsl:attribute name="ref-key">

  
                  
  <xsl:value-of select="$primary.significant"/>

  
                  
  <xsl:text>, </xsl:text>

  
                  
  <xsl:value-of select="$secondary"/>

  
                
  </xsl:attribute>

  
              
  </rx:index-item>

  
            
  </xsl:if>

  
            
  <xsl:if test="$refs[not(@significance) or 
  @significance!='preferred'][not(d:see) and not(d:tertiary)]">

  
              
  <rx:index-item xsl:use-attribute-sets="xep.index.item.properties">

  
                
  <xsl:attribute name="ref-key">

  
                  
  <xsl:value-of select="$primary"/>

  
                  
  <xsl:text>, </xsl:text>

  
                  
  <xsl:value-of select="$secondary"/>

  
                
  </xsl:attribute>

  
              
  </rx:index-item>

  
            
  </xsl:if>

  
          
  </rx:page-index>

  
        </xsl:if>

  
      </xsl:when>

  
      <xsl:otherwise>

  
        <xsl:variable name="page-number-citations">

  
          
  <xsl:for-each select="$refs[not(d:see) 
  

  
                                
  and not(d:tertiary)]">

  
            
  <xsl:apply-templates 
  select="." mode="reference">

  
              
  <xsl:with-param name="scope" select="$scope"/>

  
              
  <xsl:with-param name="role" select="$role"/>

  
              
  <xsl:with-param name="type" select="$type"/>

  
            
  </xsl:apply-templates>

  
          
  </xsl:for-each>

  
          
  <!-- Add a zero-width space -->

  
<!--          
  <xsl:text>&#x200B;</xsl:text>-->

  
        </xsl:variable>

  
 

  
        <xsl:choose>

  
          
  <xsl:when test="$passivetex.extensions != 
  '0'">

  
            
  <fotex:sort xmlns:fotex="http://www.tug.org/fotex">

  
              
  <xsl:copy-of select="$page-number-citations"/>

  
            
  </fotex:sort>

  
          
  </xsl:when>

  
          
  <xsl:otherwise>

  
            
  <xsl:copy-of select="$page-number-citations"/>

  
          
  </xsl:otherwise>

  
        </xsl:choose>

  
      </xsl:otherwise>

  
    </xsl:choose>

  
 

  
    <xsl:if test="$refs[not(d:tertiary)]/*[self::d:see]">

  
      <xsl:apply-templates select="$refs[generate-id() = 
  generate-id(key('see', concat(&primary;, &sep;, &secondary;, 
  &sep;, &sep;, d:see))[&scope;][1])]"

  
                           
  mode="index-see">

  
        <xsl:with-param name="scope" select="$scope"/>

  
        <xsl:with-param name="role" select="$role"/>

  
        <xsl:with-param name="type" select="$type"/>

  
        <xsl:sort select="translate(d:see, 
  &lowercase;, &uppercase;)"/>

  
      </xsl:apply-templates>

  
    </xsl:if>

  
 

  
  </fo:block>

  
 

  
  <xsl:if test="$refs/d:tertiary or 
  $refs[not(d:tertiary)]/*[self::d:seealso]">

  
    <!-- Customize indent -->

  
    <fo:block start-indent="1.75in">

  
      <xsl:apply-templates select="$refs[generate-id() = 
  generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, 
  &sep;, &sep;, d:seealso))[&scope;][1])]"

  
                           
  mode="index-seealso">

  
          
  <xsl:with-param name="scope" select="$scope"/>

  
          
  <xsl:with-param name="role" select="$role"/>

  
          
  <xsl:with-param name="type" select="$type"/>

  
          
  <xsl:sort select="translate(d:seealso, 
  &lowercase;, &uppercase;)"/>

  
      </xsl:apply-templates>

  
      <xsl:apply-templates select="$refs[d:tertiary and 
  count(.|key('tertiary', concat($key, &sep;, 
  &tertiary;))[&scope;][1]) = 1]" 

  
                           
  mode="index-tertiary">

  
          
  <xsl:with-param name="scope" select="$scope"/>

  
          
  <xsl:with-param name="role" select="$role"/>

  
          
  <xsl:with-param name="type" select="$type"/>

  
          
  <xsl:sort select="translate(&tertiary;, 
  &lowercase;, &uppercase;)"/>

  
      </xsl:apply-templates>

  
    </fo:block>

  
  </xsl:if>

  
</xsl:template>

  
 

  
Sorry if a solution has been posted previously. I searched 
  the forum and didn't see one, other than modifying index.entry.properties, 
  which hasn't worked for me.

  
 

  
Regards,

  
Jeff
Next in thread → Next in month →