Altova StyleVision 2025 Basic Edition

The hierarchical structure you wish to design for the TOC is specified as a set of nested levels. As such it is a hierarchical structure which, although related to the XML document structure, is separate from it. This structure is specified in the SPS document design. The TOC template that you construct will use a structure corresponding to this hierarchical structure. In the case of a TOC with a flat structure (one level only), the design document must have at least one level. If more than one level exists in the document, a flat TOC can then be created for any of these levels or for multiple levels (aggregated together as one level).

 

In the design, levels can be created in the main template, in global templates, or in a combination of main template and global templates. The important thing to note is that, wherever created, these levels must together, in combination, define a clear hierarchical structure.

 

Creating levels

Each level in the design is created separately. A level can be created on a template or around a component. In the screenshot below, one level has been created on the topic template (indicated by tag_TOCLevelOnTemplate ) and another around the topics element (indicated by tag_TOCLevelTags ). The essential difference between these two ways of creating levels is that the enclose-within-a-level option tag_TOCLevelTags enables levels to be created around components other than templates.

 

TOC_Levels

 

To create a level, do the following:

 

1.Select the component (template or other).

2.Right-click, and from the context menu select Template Serves As Level (enabled when a template is selected) or Enclose With | TOC Level. Both these options are also available in the Insert | Insert Table of Contents menu: TOC Level or Template Serves as Level.

 

Levels in global templates

Levels can also be set in global templates. In these cases, care must be taken to ensure that the levels created in various global templates, as well as those in the main template, together define a hierarchical structure when the SPS is executed. The screenshot below shows two levels, one in the main template (on the topic template) and one in the global template for topic (on the topic template).

 

TOCStructureDesign

 

In the content model represented by the screenshot above, topic is a recursive element, that is, a topic element can itself contain a descendant topic element. In the main template (the end of which is indicated by the tag_closemaintemplates tag), a level has been set on the first level of topic tag_TOCLevelOnTemplate. The rest-of-contents instruction in the main template specifies that templates will be applied for all child elements of topic/body except header. This means that the global template for topic children of topic/body will be processed.

 

In the global template for topic, a level has been set on the topic template (indicated by tag_TOCLevelOnTemplate ). This second level of the TOC hierarchy, which occurs on the second level of topic elements, is nested within the first level of the TOC hierarchy. Since this global template also has a rest-of-contents instruction, the global template for topic will be applied to all recursive topic elements, thus creating additional nested levels in the TOC hierarchy: third level, fourth level, and so on.

 

As a designer, you should be aware of the number of levels created in the design, because when the TOC template is constructed, you will need to explicitly specify how TOC items for each level will be selected and formatted.

 

Levels in flat TOCs

In a flat TOC hierarchy, TOC items will be output at a single level: for example, a simple list of the images in a document.

 

A flat hierarchy can be obtained in a number of ways.

 

The design document can be structured with just a single TOC level. The TOC template will then have a single levelref with a single TOC reference (TOCref) within it.

If the design document has more than one TOC level, then the TOC template could have a number of levelrefs equal to the sequential position of the TOC level being referenced. The levelref corresponding to the targeted TOC level will contain the single TOCref in the TOC template.

If the design document has more than one TOC level, then the single TOCref in the TOC template must have a scope that covers all the targeted document levels, which, in effect, will be flattened into a single level.

 

Let us say that we wish to gather all the images in a document in a single flat-hierarchy TOC. The document design must therefore contain at least one level, and this level must contain all the required TOC bookmarks. In the TOC template, the images to be listed are referenced in the usual way: (i) by creating a corresponding number of levelrefs; and (ii) creating a TOCref within the levelref corresponding to the targeted TOC level. The TOCref will have the name of TOC bookmarks in the targeted TOC level.

 

In the TOC template shown below, there is one levelref containing a TOCref that references TOC bookmarks named images. The scope of the TOCref has been set to Current level and below. As a result, all TOC bookmarks named images in the first level and below (that is, in the whole document) will be referenced.

 

TOCFlatTemplate

 

If the design contains more than one level, and a flat TOC is required, say, for items in the second level, then the TOC template could have two levelrefs with a TOCref only within the second level (no TOCref within the first level). Alternatively, the scope property of TOCrefs can be used to specify what level/s in the design document should be looked up for bookmarks of a given name.

 

 

© 2018-2024 Altova GmbH