Next in thread → Next in month →

Re: [docbook-apps] Applying emphasis to indexterms

From
Bob Stayton <>
Date
2012-03-12T16:31:20+00:00
ID
004401cd006d$8c00a460$6600a8c0@pazu
Thread
Re: [docbook-apps] Applying emphasis to indexterms
Hi Dave,

First of all, congratuations on finding the correct 
template to customize.  The autoidx templates are the most complicated in 
DocBook XSL, IMHO.

 

The templates in autoidx.xsl make use of some 
entity references such as "&primary;"  to keep the code readable.  
The entities are declared in common/entities.ent.  If you look at the top 
of the fo/autoidx.xsl file, you will see a parameter entity declaration and 
reference that you need to include in your customization layer.  Then your 
stylesheet should at least compile without errors.

 

Your change is close, but not quite there.  
The context node for this template is d:indexterm, so the condition needs to 
have a more complete XPath:

 

  <xsl:when 
test="d:primary/d:emphasis">

 

Your change makes the entire primary text italic 
even if emphasis is used for only one word in the primary, but I guess you are 
only using it for whole entries.

 

Bob Stayton
Sagehill Enterprises


 

 

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

  
From: 
  Xmplar 

  
To:  
  

  
Sent: Monday, March 12, 2012 3:02 
AM

  
Subject: [docbook-apps] Applying emphasis 
  to indexterms

  

  X-NONE
  X-NONE
  
   
   
   
   
   
   
   
   
   
   
   
  
  
   
   
   
   
   
   
   
   
   
   
   
  

  
I?m trying to ensure that any primary, secondary or 
  tertiary entries in the indexterm element, and which have a nested emphasis 
  element, are generated in the index with an italic font style. I?m using the 
  basic indexing method with 1.76.1ns. I?ve tried to track the coding to 
  customise, and from autoidx.xsl I thought that the template <xsl:template 
  match="d:indexterm" mode="index-primary">  would be the most likely (I?m looking 
  for an fo:block where the primary term is applied).

  
Here is my customisation from that template:

  
    <xsl:for-each select="$refs/d:primary">
        
  <xsl:if test="@id or 
  @xml:id">
          
  <fo:inline id="{(@id|@xml:id)[1]}"/>
        
  </xsl:if>
      </xsl:for-each>
      <!--modified 
  12/3/12:-->
      <xsl:choose>
        
  <xsl:when test="d:emphasis">
          
  <fo:inline 
  font-style="italic">
            
  <xsl:value-of select="d:primary"/>      
          
  </fo:inline>
        
  </xsl:when>
        
  <xsl:otherwise>
          
  <xsl:value-of 
  select="d:primary"/>
        
  </xsl:otherwise>
      </xsl:choose>

  
? and obviously not working (this template in my 
  customisation -  and seemingly any 
  from autoidx - gives me error messages about variables not declared ? so it 
  won?t transform). Where do I need to customise? Typical markup in a chunk (to 
  format primary entries with <emphasis>) is:

  
<entry><indexterm>
                
  <primary><emphasis>European 
  carp</emphasis></primary>
                
  <secondary>Cyprinus 
  carpio</secondary>
              
  </indexterm>

  
Where should I be looking so that <emphasis> is 
  applied?

  
  
  
  

  
-- 
Dave 
Gardiner
Next in thread → Next in month →