OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook] Customizing table of contents in HTML output


No, I didn't intend to respond only to you.  I simply forgot to CC the mailing list.

Below is the solution I came up with, thanks to your help:

<xsl:template match="part">
  <h2><xsl:value-of select="title"/></h2>
  <table class="toc">
      <td><strong>DOCUMENT</strong><hr /></td>
      <td><strong>REVISION</strong><hr /></td>
    <xsl:for-each select="chapter">
          <xsl:attribute name="href">
            <xsl:call-template name=" href.target">
              <xsl:with-param name="object" select="."/>
          <xsl:value-of select="chapterinfo/title"/>
        <td><xsl:value-of select="chapterinfo/revhistory/revision[position()=last()]/revnumber"/></td>

This allows me to make a separate HTML table for each DocBook Part.  Each table has two columns, the first of which lists the Title of the document (and since I am chunking the output, this field is hyperlinked), and the second lists the last RevNumber.

- Colin

On 10/26/06, Camille Bégnis <camille@neodoc.biz> wrote:
Hash: SHA1

[Was this meant to my eyes only? You can forward answer to list if useful]

Hi Colin,

Oh OK sorry I misunderstood.

This is the template you might try, adapt the "match" value depending on
where you want the table to appear in your document

- ------------------------------------------------------------
<xsl:template match="//chapter[1]">
<title>Table of Contents</title>
<tgroup cols="5">
<xsl:for-each select="//chapter/chapterinfo">
  <entry><xsl:apply-templates select="title"/></entry>
- ------------------------------------------------------------

Disclaimer: untested :-)


Colin Shapiro a écrit :
> Camille,
> Thanks for your input.  However, I don't think I made it clear enough
> that I'd like my table of contents to be in an actual table format.
> The example in Bob Stayton's book (which I've looked at before) does
> indeed describe how to customize the listitem entries in a table of
> contents, but that assumes you'd want to keep the table of contents in
> its standard list form.
> Instead, I want it to be an actual table, like this crude example (which
> I realize may look funny in various fonts / email clients, but I think
> you'll get the idea):
> ----------------------------------------------
> ----------------------------------------------
> |  Chapter 1: title |  20061107   |
> ----------------------------------------------
> |  Chapter 2: title |  20060514   |
> ----------------------------------------------
> ...etc.  The idea here is for it to actually appear in a table format,
> so I can style the borders and whatnot.
> The DocBook table that I wrote at the beginning of this thread would
> give me the output I want (never mind the couple of typos in it), but if
> I used that solution, I'd have to update the table of contents manually
> as I add/remove/change chapters.  I'd really like to find a way to do
> this with XSL.
> Thanks,
> Colin
> On 10/25/06, *Camille Bégnis* < camille@neodoc.biz
> <mailto:camille@neodoc.biz>> wrote:
> Hi Colin,
> I believe the answer is here:
> http://www.sagehill.net/docbookxsl/TOCcontrol.html
> Check the last example: just need to change appendix for chapter, and
> then  add the xsl:value of your revnumber instead of the gentext string.
> I think :-)
> Camille.
> Colin Shapiro a écrit :
>> I'd like to generate a table of contents in my HTML output that
> contains
>> extra information about each chapter of my book.  Specifically,
> I'd like
>> the table of contents to list not only the titles of each chapter,
> but
>> each chapter's revision.
>> Something resembling the following:
>> ----------------------------------------------
>> chapter1title     20061012
>> chapter2title     20050617
>> chapter3title     20060205
>> So, if I were to create the table of contents manually, I'd stick the
>> following table into a preface of my book:
>> <table>
>> <title>Table of Contents</title>
>> <tgroup cols="5">
>> <thead>
>> <row>
>>   <entry>DOCUMENT</entry>
>>   <entry>REVISION</entry>
>> </row>
>> </thead>
>> <tbody>
>> <row>
>>   <entry><xi:xinclude
>>     href=""" chapter1.xml"
>>     xpointer="xpointer(/chapter/chapterinfo/title/text())"
>>     xmlns:xi=" http://www.w3.org/2001/XInclude" /></entry>
>>   <entry><xi:xinclude
>>     href=""chapter1.xml">
> xpointer="xpointer(/chapter/chapterinfo/revhistory/revision[position=last()]/revnumber/text())"
>>     xmlns:xi="http://www.w3.org/2001/XInclude
>> < http://www.w3.org/2001/XInclude>" /></entry>
>> </row>
>> </tbody>
>> </tgroup>
>> </table>
>> In this manner, I could manually create a table of contents in the
>> format I wanted.  But what if I'd rather do this with an XSL
>> customization layer, so that the whole table of contents would be
>> generated automatically?
>> Can anyone point me in the right direction?  I understand how to make
>> basic customization layers, but I've never done anything this complex.
>> Thanks for any input you may offer.
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]