docbook-apps

  • 1.  Table Row Counting

    Posted 12-20-2007 01:33
    I'd like to create a table in which the first column is a sequential
    number to indicate the item number. For example:


    <tgroup cols="3">
    <colspec colname="1" align="center" colwidth="3pc"/>
    <colspec colname="2" align="left" colwidth="25pc"/>
    <colspec colname="3" align="left" colwidth="10pc"/>

    <row>
    <entry align="center">Item #</entry>
    <entry align="center">Software Program</entry>
    <entry align="center">Version</entry>
    </row>


    <row>
    <entry>1</entry>
    <entry>Windows</entry>
    <entry>XP</entry>
    </row>

    </tgroup>


    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?

    Thanks,
    Dave





  • 2.  Re: [docbook-apps] Table Row Counting

    Posted 12-20-2007 08:00
    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="table[@role='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>


    Jirka

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML consulting and training services
    DocBook customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
    ------------------------------------------------------------------