[xsl] Creating a Table of Contents from an HTML file being transformed using XSL to FO

Subject: [xsl] Creating a Table of Contents from an HTML file being transformed using XSL to FO
From: "Kenneth Aitken" <kenneth_aitken@xxxxxxxxxx>
Date: Wed, 29 Sep 2004 09:43:07 +0200
Has anyone successfully created a Table of Contents (TOC) using XSLT to
transform HTML files to FO files (and, ultimately, to PDF, e.g. with XEP),
with the HTML structure:
<h1>Chapter 1</h1>
<h2>Section 1</h2>
<h3>Paragraph 1</h3>
<p>...........</p>
<h3>Paragraph 2</h3>
<p>...........</p>
<h3>Paragraph 3</h3>
<p>...........</p>
<h2>Section 2</h2>
<h3>Paragraph 1</h3>
<p>...........</p>
<h3>Paragraph 2</h3>
<h2>Section 3</h2>
<p>...........</p>
<h2>Section 4</h2>
<p>...........</p>

<h1>Chapter 2</h1>
<h2>Section 1</h2>
<h3>Paragraph 1</h3>
<p>...........</p>
<h3>Paragraph 2</h3>
<p>...........</p>
<h3>Paragraph 3</h3>
<p>...........</p>
<h2>Section 2</h2>
<h3>Paragraph 1</h3>
<p>...........</p>
<h3>Paragraph 2</h3>
<h2>Section 3</h2>
...........
<h2>Section 4</h2>
..........
<h1>Chapter 3</h1>
...........

This should generate a TOC structure in PDF via XSL-FO as follows:
Chapter 1..................................1
Section 1..................................1
Paragraph 1
Paragraph 2
Paragraph 3
Section 2..................................3
Paragraph 1
Paragraph 2
Section 3..................................5
Section 4..................................5
Chapter 2..................................7
Section 1..................................7
Paragraph 1
Paragraph 2
Paragraph 3
Section 2..................................9
Paragraph 1
Paragraph 2
Section 3..................................11
..........
Section 4..................................12
.........
Chapter 3..................................14
We have already tried using <div class="first">...</div> to create a nested
structure in HTML, and this succeeded in creating a TOC with 2 levels (i.e.
h1, h2), but we need help with three levels (i.e. also with h3).Can anyone
give us an example with some XSLT code?

Current Thread