User`s guide
Create a Table of Contents
13-81
Create an HTML TOC Placeholder
An HTML TOC placeholder element is an HTML div element with an id attribute set to
toc.
<div id="toc"/>
You can create a TOC placeholder in any of the following ways.
• “Use a Template That Contains a Placeholder” on page 13-81
• “Insert a Placeholder Programmatically Using a Custom Element” on page 13-81
• “Insert a Placeholder Programmatically Using a Document Part” on page 13-82
Use a Template That Contains a Placeholder
1
Create a copy of the DOM default HTML template.
2
Unzip the template using the unzipTemplate command.
3
In a text or HTML editor, open the template main document (typically named
root.html).
4
In the root document, in the report location you want the TOC to appear, insert the
following HTML markup:
<div id="toc"></div>
5
Save the main document.
6
Zip the template, using the unzipTemplate command.
7
Set the outline levels of the section heads that you want to appear in the table of
contents. See “Set Outline Levels of Section Heads” on page 13-82 .
8
Use the template to generate the report.
Next,
Insert a Placeholder Programmatically Using a Custom Element
If you use the DOM default HTML template (or a template based on the default
template), you can create a placeholder programmatically in your report. For example:
import mlreportgen.dom.*;
d = Document('MyReport','html');
append(d,'My Report');