Karakas Online

7.1.11. Index

Before you can process your document, you must make sure that index.sgml exists. This is a chicken and egg problem, but it can be solved with the collateindex.pl command:

perl collateindex.pl -N -o index.sgml 

or, as in lyxtox:

$PERL $COLLATEINDEX -N -o index.sgml

The -N option creates a new index; -o indentifies the name of the output file. This name must be the same as the name you specified in the preample (see Section 4.6). The collateindex.pl script is part of the docbook-dsssl-stylesheets package (see Section 3.2). There are a multitude of options to collateindex.pl; see the reference page for more information.

Creating an index is a multi-step, two-pass process (see Automatic Indexing with the DocBook DSSSL Stylesheets):

Tip Tip
 

Whether an index has to be created or not, can be controlled by setting html-index to "#t" in the stylesheets (see Section 4.2 and Section 7.1.5) as follows (original code is in dbparam.dsl, but it is better not to touch it):

(define html-index
  ;; REFENTRY html-index
  ;; PURP HTML indexing?
  ;; DESC
  ;; Turns on HTML indexing.  If true, then index data will be written
  ;; to the file defined by 'html-index-filename'.  This data can be
  ;; collated and turned into a DocBook index with bin/collateindex.pl.
  ;; /DESC
  ;; AUTHOR N/A
  ;; /REFENTRY
  #t)
Default is false ("#f"). I preferred to let the default untouched and insert the external entity "index" at the end of the document using runsed and sedscr, see Section 7.1.4.1. If you decide to set html-index you will have to comment this in sedscr.
Tip Tip
 

You can change the name of the file to which index data will be written by setting html-index-filename in the stylesheets (see Section 4.2 and Section 7.1.5) as follows (original code is in dbparam.dsl, but it is better not to touch it):

(define html-index-filename
  ;; REFENTRY html-index-filename
  ;; PURP Name of HTML index file
  ;; DESC
  ;; The name of the file to which index data will be written if
  ;; 'html-index' is not '#f'.
  ;; /DESC
  ;; AUTHOR N/A
  ;; /REFENTRY
  "HTML.index")
Default is HTML.index. I preferred to let the default untouched. If you decide to set html-index-filename, you will have to adapt lyxtox to reflect the name change.
Last updated Mon Sep 24 01:19:25 CEST 2007 Permalink: http://www.karakas-online.de/mySGML/explain-index.html All contents © 2002-2007 Chris Karakas