← Prev in month ← Prev in thread

Re: [docbook-apps] Auto-numbering in tables

From
Bob Stayton <>
Date
2008-08-05T16:33:56+00:00
ID
01f201c8f719$0723d110$6a00a8c0@pazu
Thread
Re: [docbook-apps] Auto-numbering in tables
Title: Auto-numbering in tables

Hi,

Here is an example of customizing the profiling 
stylesheet:

 

<?xml version="1.0"?>
<xsl:stylesheet 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                
version='1.0'>

<xsl:import 
href="../docbook-xsl-1.74.0/profiling/profile.xsl"/>

 

<xsl:template mode="profile" match="table[@role = 
'autonumbered']/tgroup/tbody/row/entry[1]">
  
<xsl:copy>
    <xsl:copy-of 
select="@*"/>
    <xsl:number count="row" level="single" 
from="tbody"/>
  </xsl:copy>
</xsl:template>

 

</xsl:stylesheet>

You need to use the two-step profiling method, where you process your 
document with this stylesheet first, and then process the result with your 
formatting stylesheet.

 

Bob Stayton
Sagehill Enterprises


 

 

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

  
From: 
   

  
To:  
  

  
Sent: Wednesday, July 30, 2008 9:38 
  AM

  
Subject: [docbook-apps] Auto-numbering in 
  tables

  

  
Hi people, 
  
        I found 
  the thread below using google, and it describes exactly what I need to do for 
  generating PDF files using docbook-xsl-1.73.2.

  
        However, 
  I can't get the numbers to appear in tables. I've put the xsl:template code in 
  both fo/profile-docbook.xsl and fo/table.xsl but with no luck. (And yes I've 
  replaced the [EMAIL PROTECTED] with table[atrole=). Any suggestions as to 
  why?

  
        My table 
  in the .xml looks like this: 

  
<table role="autonumbered"> 
  
        <title>Blah</title> 
  
        <tgroup cols='5' align='left' colsep='1' rowsep='1'> 
  
        <thead> 
        
          <row> 
  
                
          
  <entry>ID</entry> 
  
                
          
  <entry>Blah</entry> 
  
                
          
  <entry>Blah</entry> 
  
                
          
  <entry>Blah</entry> 
  
                
          
  <entry>Blah</entry> 
  
        
          </row> 
        
  </thead> 
  
        <tbody> 
        
          <row> 
        
          
          <entry></entry> 
  
                
          
  <entry>ditto</entry> 
  
                
          
  <entry>ditto</entry> 
  
                
          
  <entry>ditto</entry> 
  
                
          
  <entry>ditto</entry> 
  
        
          </row> 
        
          <row> 
        
          
          <entry></entry> 
  
                
          
  <entry>ditto</entry> 
  
                
          
  <entry>ditto</entry> 
  
                
          
  <entry>ditto</entry> 
  
                
          
  <entry>ditto</entry> 
  
        
          </row> 
        
  </tbody> 
  
        </tgroup> 
</table> 

  
        Can 
  someone maybe elaborate where Jirka says "Simply create stylesheet 
  customization based on profiling stylesheet (like fo/profile-docbook.xsl or 
  html/profile-chunk.xsl)"? 

  
Dave Cushman wrote: 

  
> Instead of manually entering the item number 
  in the first column, I'd 
> like to be 
  able to have that generated during conversion so that it 
> stays accurate as I add and remove items.  What is 
  a good method to 
> accomplish 
  this? 

  
It's kind of a hack but you can attach this 
  autonumbering functionality 
to profiling 
  code in stylesheets. Simply create stylesheet customization 
based on profiling stylesheet (like fo/profile-docbook.xsl 
  or 
html/profile-chunk.xsl) and then add 
  special role to tables that should 
have 
  this functionality, like: 

  
<table role="autonumbered"> 

  
and in your customized stylesheet use the following 
  template: 

  
<xsl:template 
match="[EMAIL 
  PROTECTED]'autonumbered']/tgroup/tbody/row/entry[1]" 
mode="profile"> 
  
  <xsl:copy> 
    
  <xsl:copy-of select="@*"/> 
    <xsl:number count="row" level="single" 
  from="tbody"/> 
  
  </xsl:copy> 
</xsl:template> 

  
Regards 
James
← Prev in month ← Prev in thread