Next in thread → Next in month →

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

From
Bob Stayton <>
Date
2012-03-02T22:45:35+00:00
ID
028001ccf8c6$27ddc480$0601a8c0@pazu
Thread
Re: [docbook-apps] formatting for paragraphs with xsl stylesheets
I just checked in a new param 'para.properties' 
that does as I described for the para element.  It is in the latest 
snapshot release, and will be in the next official release.

 

Bob Stayton
Sagehill Enterprises


 

 

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

  
From: 
  Bob Stayton 
  

  
To: Paul Tremblay 

  
Cc: DocBook Apps 

  
Sent: Friday, March 02, 2012 10:11 
  AM

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

  

  
Generally we try to maintain backwards 
  compatibility with previous stylesheet releases so that existing 
  customizations are not broken with a new release,  so changing the name 
  of it would not be appropriate.  But adding a new  'para.properties' 
  attribute set that includes normal.para.spacing would be.

  
 

  
Bob Stayton
Sagehill Enterprises


  
 

  
 

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

    
From: 
    Paul 
    Tremblay 

    
To: Bob Stayton 

    
Cc: DocBook Apps 

    
Sent: Friday, March 02, 2012 10:08 
    AM

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

    

I think normal.para.properties is a better name. 
    normal.para.spacing seems misleading, since the attribute set can set all 
    sorts of different properties. Would it be too much work to change this, or 
    would it introduce incompatibilities? 

Thanks 
    again

Paul

    
On Fri, Mar 2, 2012 at 12:59 PM, Bob Stayton <> wrote:

    
      

      
Actually, the name of the attribute set is 
      'normal.para.spacing', not normal.para.properties.  I used the 
      correct name in the paragraph but not the example.  And indeed, 
      it  does not appear in the index, an oversight I will correct in the 
      next edition.

      

      
 

      
Bob Stayton
Sagehill Enterprises


      
 

      
 

      
        

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

        
From: Paul Tremblay 

        

        

        
To: Bob Stayton 

        
Cc: DocBook 
        Apps 

        
Sent: Friday, March 02, 2012 9:52 
        AM

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

        

Thanks Bob,

When I look at this page:

http://docbook.sourceforge.net/release/xsl/1.76.1/doc/fo/index.html

I 
        don't see the normal.para.properties attribute set at all. Is the 
        documentation not accurate? 

Paul

        
On Fri, Mar 2, 2012 at 12:35 PM, Bob Stayton 
        <> wrote:

        
          

          
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
Next in thread → Next in month →