Re: [docbook-apps] formatting for paragraphs with xsl stylesheets

From
Bob Stayton <>
Date
2012-03-02T17:35:26+00:00
ID
022f01ccf89a$d7288230$0601a8c0@pazu
Thread
Re: [docbook-apps] formatting for paragraphs with xsl stylesheets
Hi Paul,

I think the normal.para.spacing attribute-set was 
originally for para, but has since been used for other purposes to give uniform 
spacing for several similar elements. There should be a dedicated attribute-set 
for para which has a use-attribute-sets="normal.para.spacing" attribute so it 
can use those properties but provide an opportunity for further customization 
for just para.

 

Looking at some of my previous 
cusotmization, I have used the normal.para.properties attribute set 
and add an xsl:choose to test for the para context, something like 
this:

 

<xsl:attribute-set 
name="normal.para.properties">

  <xsl:attribute 
name="text-indent">

    <xsl:choose>

      <xsl:when 
test="self::d:para">

          para 
value

      
</xsl:when>

      
</xsl:otherwise>

          non-para 
value

      
</xsl:otherwise>

    </xsl:choose>

  </xsl:attribute>

</xsl:attribute-set>

 

Since attribute-sets of the same name are merged, 
you will still get the spacing and add this property.

 

Bob Stayton
Sagehill Enterprises


 

 

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

  
From: 
  Paul 
  Tremblay 

  
To: DocBook Apps 

  
Sent: Friday, March 02, 2012 7:21 
AM

  
Subject: [docbook-apps] formatting for 
  paragraphs with xsl stylesheets

  

It seems that the xsl stylesheets have a shortcoming for 
  formatting paragraphs. Whereas all other elements have an attribute set, para 
  does not. 

In order to set formatting properties, one has to use the 
  section.properties attribute set. But then titles inherit this property as 
  well. For example:

    <xsl:attribute-set 
  name="section.properties">
      
  <xsl:attribute 
  name="text-indent">12pt</attribute>
    
  </xsl:attribute-set name>

Ends up indenting the title as 
  well. In order to get around that, I have to set the text-indent on the title 
  properties to 0; that seems like a clumsy workaround. In addition, the lack of 
  formatting for paragraphs does not allow you to indent paragraphs in certain 
  situations. For example, some styles don't indent the first paragraph after a 
  title. 

The code below is my workaround. Is there a better way? If not, 
  I would consider submitting a patch (in which case the code would be more 
  sophisticated to handle more complicated situations)

  
  
 <!--indent first paragraph-->
    
  <xsl:template 
  match="d:para">
        
  <xsl:variable 
  name="keep.together">
            
  <xsl:call-template 
  name="pi.dbfo_keep-together"/>
        
  </xsl:variable>
        
  <fo:block 
  xsl:use-attribute-sets="normal.para.spacing">
            
  <xsl:if test="$keep.together != 
  ''">
                
  <xsl:attribute 
  name="keep-together.within-column">
                    
  <xsl:value-of 
  select="$keep.together"/>
                
  </xsl:attribute>
            
  </xsl:if>
            
  <xsl:if 
  test="preceding-sibling::d:para">
                
  <xsl:attribute 
  name="text-indent">
                    
  <xsl:value-of 
  select="$text-indent"/>
                
  </xsl:attribute>
            
  </xsl:if>
            
  <xsl:call-template 
  name="anchor"/>
            
  <xsl:apply-templates/>
        
  </fo:block>
    
</xsl:template>

Paul