List Info

Thread: Customizing table of contents in HTML output




Customizing table of contents in HTML output
user name
2006-10-30 16:04:05
Camille,

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=&quot;part";>
 ; <h2><xsl:value-of select=&quot;title&quot;/><;/h2>
&nbsp; <table class=&quot;toc">
   ; <tr>
 &nbsp; &nbsp;  <td><strong&gt;DOCUMENT</strong><hr /></td>
&nbsp; &nbsp; &nbsp; <td><strong&gt;REVISION</strong><hr /></td>
&nbsp; &nbsp; </tr>;
 &nbsp;  <xsl:for-each select=&quot;chapter&quot;>
&nbsp;   ;  <tr>
 &nbsp; &nbsp; &nbsp;  <td><a>
&nbsp;   ; &nbsp; &nbsp;  <xsl:attribute name=";href">
   ; &nbsp; &nbsp; &nbsp; &nbsp; <xsl:call-template name="; href.target">;
 &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; <xsl:with-param name=";object&quot; select=&quot;."/>
   ; &nbsp; &nbsp; &nbsp; &nbsp; </xsl:call-template>
 ; &nbsp; &nbsp; &nbsp; &nbsp; </xsl:attribute>;
 &nbsp; &nbsp; &nbsp;   ; <xsl:value-of select=&quot;chapterinfo/title&quot;/>
  ; &nbsp; &nbsp;  </a></td>
 &nbsp; &nbsp; &nbsp;  <td><xsl:value-of select="chapterinfo/revhistory/revision[position()=last()]/revnumber"/&gt;</td&gt;
 &nbsp; &nbsp;  </tr>;
 &nbsp;  </xsl:for-each>
  </table>
  <xsl:apply-templates/>
<;/xsl:template>

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 < camilleneodoc.biz">camilleneodoc.biz> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
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=&quot;//chapter[1]"&gt;
<table>
<title>Table of Contents&lt;/title>;
<tgroup cols=";5">;
<thead>
<row>
 ; <entry>DOCUMENT</entry>
&nbsp; <entry&gt;REVISION&lt;/entry&gt;
</row>
</thead>
&lt;tbody>
<xsl:for-each select=&quot;//chapter/chapterinfo">;
<row&gt;
 &nbsp;<entry><xsl:apply-templates select=&quot;title&quot;/><;/entry>
 &nbsp;<entry><xsl:apply-templates
select="revhistory/revision[position=last()]/revnumber&quot;/>&lt;/entry&gt;
</row>
</xsl:for-each>
</tbody>
&lt;/tgroup&gt;
</table>
<;xsl:apply-imports>
</xsl:template>
- ------------------------------------------------------------

Disclaimer: untested

Camille.


Colin Shapiro a écrit :
> Camille,
&gt;
> Thanks for your input.&nbsp; 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.
&gt;
> 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):
&gt;
> ----------------------------------------------
> | &nbsp;DOCUMENT  ; &nbsp;| &nbsp;REVISION &nbsp;|
> ----------------------------------------------
> | &nbsp;Chapter 1: title | &nbsp;20061107  ; |
> ----------------------------------------------
> | &nbsp;Chapter 2: title | &nbsp;20060514  ; |
> ----------------------------------------------
>
&gt; ...etc.&nbsp; The idea here is for it to actually appear in a table format,
&gt; 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.&nbsp; I'd really like to find a way to do
> this with XSL.
>
> Thanks,
&gt; Colin
>
>
> On 10/25/06, *Camille Bégnis* < camilleneodoc.biz"> camilleneodoc.biz
> <mailto: camilleneodoc.biz">camilleneodoc.biz>> wrote:
>;
> Hi Colin,
>;
> I believe the answer is here:
> http://www.sagehill.net/docbookxsl/TOCcontrol.html
&gt;
> 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.
&gt;
> I think
>
> Camille.
&gt;
> Colin Shapiro a écrit :
>> I'd like to generate a table of contents in my HTML output that
> contains
&gt;> extra information about each chapter of my book. ; Specifically,
> I'd like
>&gt; the table of contents to list not only the titles of each chapter,
&gt; but
>&gt; each chapter's revision.
>
>&gt; Something resembling the following:
>
>&gt; DOCUMENT&nbsp; &nbsp; REVISION
&gt;> ----------------------------------------------
>>; chapter1title &nbsp; &nbsp; 20061012
&gt;> chapter2title &nbsp; &nbsp; 20050617
&gt;> chapter3title &nbsp; &nbsp; 20060205
&gt;
>
&gt;> So, if I were to create the table of contents manually, I'd stick the
>&gt; following table into a preface of my book:
>
>
>&gt; <table&gt;
>>; <title&gt;Table of Contents&lt;/title>;
>> <tgroup cols=";5">;
>> <thead&gt;
>&gt; <row>;
>>&nbsp;  <entry&gt;DOCUMENT</entry&gt;
>>; &nbsp; <entry&gt;REVISION</entry&gt;
>>; </row&gt;
>> </thead>
>&gt; <tbody&gt;
>>; <row>;
>>  ; <entry&gt;<xiinclude
&gt;> ; &nbsp;  href="; chapter1.xml"
&gt;> ; &nbsp;  xpointer=&quot;xpointer(/chapter/chapterinfo/title/text())"
>>&nbsp; &nbsp;  xmlnsi=" http://www.w3.org/2001/XInclude" /></entry>
&gt;>&nbsp;  <entry&gt;<xiinclude
&gt;> ; &nbsp;  href=";chapter1.xml"
&gt;
>
>; xpointer=&quot;xpointer(/chapter/chapterinfo/revhistory/revision[position=last()]/revnumber/text())"
&gt;> ; &nbsp;  xmlnsi="http://www.w3.org/2001/XInclude
>> < http://www.w3.org/2001/XInclude>" /></entry>
>> </row&gt;
>> </tbody>
>&gt; </tgroup>
>&gt; </table>
>
&gt;
>>; In this manner, I could manually create a table of contents in the
>&gt; format I wanted.&nbsp; But what if I'd rather do this with an XSL
>&gt; customization layer, so that the whole table of contents would be
>>; generated automatically?
>
&gt;> Can anyone point me in the right direction?  ;I understand how to make
>&gt; basic customization layers, but I've never done anything this complex.
>
>&gt; Thanks for any input you may offer.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org

iD8DBQFFQHUgjv9P65BfOUMRAtAqAJ90I03lf4fkDNCOf/02nz93OL4oeACfUVOi
CjeYmF1szi006nfc/eHasIQ=
=Khmv
-----END PGP SIGNATURE-----



[1]

about | contact  Other archives ( Real Estate discussion Medical topics )