| 1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
| 2 |
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd"> |
| 4 |
<section id="sec-index" xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 5 |
<title>Creating an Index</title> |
| 6 |
|
| 7 |
<para> |
| 8 |
An index is automatically generated if some index entries (<sgmltag>indexterm</sgmltag>), telling the terms to put in the index, are written in the document. The <sgmltag>keyword</sgmltag> elements are not printed but are also added to the index. |
| 9 |
</para> |
| 10 |
<example><title>Index Entry</title> |
| 11 |
<programlisting language="XML"> |
| 12 |
<![CDATA[<para>In this paragraph is described the function |
| 13 |
<function>strcpy</function><indexterm><primary>strcpy</primary></indexterm>. |
| 14 |
</para> |
| 15 |
]]> </programlisting> |
| 16 |
</example> |
| 17 |
<para> |
| 18 |
The index is put at the end of the document. It is not possible to put it somewhere else. |
| 19 |
</para> |
| 20 |
|
| 21 |
<section id="sec-index-locale"><title>Internationalized Indexes</title> |
| 22 |
|
| 23 |
<section id="sec-index-tools"><title>Indexing Tools</title> |
| 24 |
<para><command>Makeindex</command> is used by default to build the index. It works fine for latin charset but it is not |
| 25 |
suited for other charsets and UTF-8 encoding. Moreover its sorting rule is |
| 26 |
not suited for many languages.</para> |
| 27 |
|
| 28 |
<para>Therefore dblatex gives the possibility to use |
| 29 |
<command>xindy</command> that allows internationalized indexing. When xindy |
| 30 |
is used, the sorting language used is deduced from the Docbook document lang. |
| 31 |
If the document lang has no correspondance for xindy, or if you want to force |
| 32 |
the use of a specific sorting language, you can specify the sorting language |
| 33 |
to use. With Xindy you can |
| 34 |
also provide your own sort rules, but see the official Xindy documentation |
| 35 |
for more details.</para> |
| 36 |
|
| 37 |
<para>A parameter is provided to use xindy instead of makeindex: |
| 38 |
<itemizedlist> |
| 39 |
<listitem><para><parameter>latex.index.tool</parameter>=xindy tells dblatex |
| 40 |
to use xindy instead of makeindex (default).</para> |
| 41 |
</listitem> |
| 42 |
</itemizedlist> |
| 43 |
</para> |
| 44 |
|
| 45 |
<para>A typical use is then: |
| 46 |
<screen> |
| 47 |
dblatex -P latex.index.tool=xindy file.xml |
| 48 |
</screen> |
| 49 |
</para> |
| 50 |
|
| 51 |
</section> |
| 52 |
|
| 53 |
<section><title>Index Sorting</title> |
| 54 |
<para><command>Makeindex</command> has very few methods to change its |
| 55 |
index sorting rules, except the <option>-g</option> and <option>-L</option> options which are not very hepfull in a DocBook context. On the contrary <command>xindy</command> can sort the index according to |
| 56 |
a specific language.</para> |
| 57 |
|
| 58 |
<para>When xindy is used as index tool, <command>dblatex</command> passes to |
| 59 |
xindy through the xindy <option>-L</option> option |
| 60 |
the language name corresponding to the <literal>lang</literal> attribute of the |
| 61 |
document. If the document has no language or if <command>xindy</command> |
| 62 |
does not support the document language, the default sorting is applied. In this |
| 63 |
case you can use the following parameter: |
| 64 |
|
| 65 |
<itemizedlist> |
| 66 |
<listitem><para><parameter>latex.index.language</parameter> specifies the |
| 67 |
language used to sort the indexes. Currently this parameter is relevant |
| 68 |
only for xindy. The language set must be known by xindy (see the xindy |
| 69 |
documentation). When not set (or empty) the sorting language to apply |
| 70 |
is deduced from the document lang.</para> |
| 71 |
</listitem> |
| 72 |
</itemizedlist> |
| 73 |
</para> |
| 74 |
|
| 75 |
<para>The parameter can be used like any other like this: |
| 76 |
<screen> |
| 77 |
dblatex -P latex.index.language=german-din file.xml |
| 78 |
</screen> |
| 79 |
|
| 80 |
But it can also be used through an XSL configuration file to provide new mapping |
| 81 |
rules between ISO lang codes and known xindy languages, or override the current |
| 82 |
mapping done by dblatex as shown in <xref linkend="xsl-index-lang"/>. |
| 83 |
</para> |
| 84 |
|
| 85 |
<example id="xsl-index-lang"><title>XSL Index Language Setup</title> |
| 86 |
<para>By default dblatex maps the <literal>de</literal> lang |
| 87 |
code to the language named <literal>german-din</literal>, and has no |
| 88 |
correspondance to map <literal>cy</literal> (Welsh) or <literal>eu</literal> |
| 89 |
(Basque). The following setup provides a mapping for these cases: |
| 90 |
</para> |
| 91 |
|
| 92 |
<programlisting language="XML"> |
| 93 |
<![CDATA[<xsl:param name="latex.index.tool">xindy</xsl:param> |
| 94 |
|
| 95 |
<xsl:param name="latex.index.language"> |
| 96 |
<xsl:variable name="lang"> |
| 97 |
<xsl:call-template name="l10n.language"> |
| 98 |
<xsl:with-param name="target" select="(/set|/book|/article)[1]"/> |
| 99 |
<xsl:with-param name="xref-context" select="true()"/> |
| 100 |
</xsl:call-template> |
| 101 |
</xsl:variable> |
| 102 |
|
| 103 |
<!-- Define Xindy lang to use in specific cases --> |
| 104 |
<xsl:choose> |
| 105 |
<xsl:when test="$lang='de'">german-duden</xsl:when> |
| 106 |
<xsl:when test="$lang='cy'">english</xsl:when> |
| 107 |
<xsl:when test="$lang='eu'">french</xsl:when> |
| 108 |
</xsl:choose> |
| 109 |
</xsl:param> |
| 110 |
]]> </programlisting> |
| 111 |
</example> |
| 112 |
|
| 113 |
</section> |
| 114 |
</section> |
| 115 |
</section> |