This page looks best with JavaScript enabled

Docbook - Creating Indexes

 ·  ☕ 1 min read

    I’ve been doing a bit of Docbook work recently - converting a paper based manual into a Docbook one that can then be used to generate all kinds of different output from the same input file. Very useful.

    I needed to create an index that correctly reflected the contents of the new format rather than simply copying the old one - where the pages would no longer have matched up.

    I found a couple of good articles, namely:

    http://www.xml.com/pub/a/2004/07/14/dbndx.html

    and, of course, this one:

    http://www.sagehill.net/docbookxsl/GenerateIndex.html

    UPDATE: Of all the people you would expect to get it right, Bob Stayton is the one. Except he got it wrong. In the link above to www.sagehill.net, there is an example thus:

    1
    2
    3
    4
    5
    6
    7
    
    <indexterm class="startofrange" id="makestuff"\>
       <primary>Makefiles</primary>
    </indexterm>
     ... 
    <indexterm class="endofrange" startref="makestuff"\>
       <primary>Makefiles</primary>
    </indexterm>
    

    It should be as follows without the <primary> on the endofrange indexterm.

    1
    2
    3
    4
    5
    6
    
    <indexterm class="startofrange" id="makestuff"\>
       <primary>Makefiles</primary>
    </indexterm>
     ... 
    <indexterm class="endofrange" startref="makestuff"\>
    </indexterm>
    

    If you do it with a primary, you get the page range as expected, but with the final page duplicated, as in:

    1
    
    Subject matter 123-127, 127
    

    Remove the primary and it just works.

    Share on

    Norman Dunbar
    WRITTEN BY
    Norman Dunbar
    Oracle DBA & developer. (Retired). Now a published book author!