[simon: this is another docbook example]

[non member submission, pleas use registered address]

>Hello,
>
>I'm typesetting a Docbook document with ConTeXt and I cannot get it to
>typeset the index correctly. The index is generated automatically with
>this code:
>
>\defineXMLenvironment[book]{\starttext}{\completeindex\stoptext}
>
>\defineXMLargument[indexterm]{\index}
>\defineXMLcommand[primary]{}
>\defineXMLcommand[secondary]{+}
>
>Index entries in DocBook are coded through the text as:
>
><indexterm><primary>animals</primary></indexterm>
>
>or
>
><indexterm><primary>animals</primary><secondary>dogs</secondary></indexterm>

since you need to distinguish between primary and secondary index entries, 
you can best save/flush them, as in:

\defineXMLenvironment [book]
   {\starttext}
   {\placeindex
    \stoptext}

\defineXMLenvironment [indexterm]
   {\defineXMLenvironmentsave[primary]   \ignorespaces \ignorespaces
    \defineXMLenvironmentsave[secondary] \ignorespaces \ignorespaces}
   {\doifelseXMLdata{secondary}
      {\expanded{\index{\XMLflushdata{primary}+\XMLflushdata{secondary}}}}
      {\expanded{\index{\XMLflushdata{primary}}}}}

\enableXMLelements

<book>
   So we have primary<indexterm> <primary>animals</primary>
   animals </indexterm> as well as secondary<indexterm>
   <primary>animals</primary> <secondary>dogs</secondary>
   </indexterm> ones, at least in the Czech republic.
</book>

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | [EMAIL PROTECTED]
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                                   fall-back web server: 
www.pragma-pod.nl
-------------------------------------------------------------------------

Reply via email to