docbook-apps

  • 1.  Auto-numbering in tables

    Posted 07-30-2008 16:38
    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:



    <tgroup cols='5' align='left' colsep='1' rowsep='1'>

    <row>
    <entry>ID</entry>
    <entry>Blah</entry>
    <entry>Blah</entry>
    <entry>Blah</entry>
    <entry>Blah</entry>
    </row>


    <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>

    </tgroup>


    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:



    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