XML technologies / DocBook / Block elements / Index entries / Index ranges

(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)

For topics spanning several paragraphs or sections, index ranges help readers locate the coverage. Print output shows starting and ending pages; online output uses the sections containing the endpoints. DocBook offers two methods:

startofrange, startref and endofrange

At the start of a range, insert an indexterm with the attribute class with the value startofrange. Give this indexterm an anchor. At the end of the range, insert a second, empty <indexterm/>. Add the attribute startref with the anchor of the first indexterm.

zone

First add anchors to the elements to index. At a suitable position, usually the start of a chapter, insert an indexterm. Also use the attribute zone, containing the space-separated anchor values of the indexed elements. The type of zone is IDREFS, allowing references to several anchors.

The following example illustrates this initially complex-looking mechanism:

Example: Index ranges using startofrange, endofrange and startref

<chapter>
 <title>DocBook</title>
 <indexterm ANKER="id.chap.xml"class="startofrange">
   <primary>DocBook</primary>
 </indexterm>
 <!-- weiterer Inhalt -->
 <indexterm startref="id.chap.xml"class="endofrange"/>
</chapter>

Replace the placeholder ANKER with id in DocBook 4 and xml:id in DocBook 5.

Note: Placing the empty <indexterm/>
Place empty <indexterm/> elements carefully. If a chapter or appendix contains sections, place the <indexterm/> element in the last section to avoid validation errors.

This method creates a from-to range in the index. Printed documents use page numbers.

The second method uses the zone attribute, useful for collecting all index entries in one place:

Example: Index ranges using zone

<chapter>
  <title>DocBook</title>
  <indexterm zone="sec.install sec.config">
    <primary>DocBook</primary>
  </indexterm>
  <sect1 ANKER="sec.install">
    <title>Installation</title>
    <para>...</para>
  </sect1>
  <sect1 ANKER="sec.config">
    <title>Konfiguration</title>
    <para>...</para>
  </sect1>
</chapter>

Replace the placeholder ANKER with id in DocBook 4 and xml:id in DocBook 5.

The example creates the main entry "DocBook" with two subentries, "Installation" and "Konfiguration".

  

back to top