XML technologies / DocBook / The DocBook XSL stylesheets / Customizing cross-references / Customizing with the gentext template

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

To customize cross-references throughout a document, create and edit language files (explained in Customizing language files). Cross-references use three types of l:context element:

<l:context name="xref">

Contains cross-references to unnumbered elements, including chapters if the parameter chapter.autolabel is zero. The same applies to appendix, part, preface and section and their corresponding parameters.

<l:context name="xref-number">

Contains cross-references to numbered elements such as appendix, chapter, figure and table. This also applies to numbered sections when xref.with.number.and.title=0 .

<l:context name="xref-number-and-title">

Cross-references to numbered elements, including element name, number and title, when xref.with.number.and.title=1 (the default).

The file common/de.xml contains entries such as:

Example: Cross-reference excerpt from the German language file

<l:context name="xref">
    <l:template name="appendix" text="%t"/>
    <l:template name="chapter" text="%t"/>
    <l:template name="example" text="%t"/>
    ...
</l:context>
<l:context name="xref-number">
    <l:template name="appendix" text="Anhang&#160;%n"/>
    <l:template name="chapter" text="Kapitel&#160;%n"/>
    <l:template name="example" text="Beispiel&#160;%n"/>
    ...
</l:context>
<l:context name="xref-number-and-title">
    <l:template name="appendix" text="Anhang&#160;%n, %t"/>
    <l:template name="chapter" text="Kapitel&#160;%n, %t"/>
    <l:template name="example" text="Beispiel&#160;%n, „%t“"/>
    ...
</l:context>

Here, &#160; represents a non-breaking space (non-breakable space). This keeps the word and number together. To customize cross-references, proceed as follows:

  1. Choose how to reference the language file: directly in the stylesheet (Customizing localized text) or separately (Adding custom entries).

  2. Determine the cross-reference format:

    • If the parameter xref.with.number.and.title has the value 1 (the default), use the context xref-number-and-title.

    • If the parameter xref.with.number.and.title has the value 0 use the context xref-number.

    • For example, if the parameter chapter.autolabel has the value 0 (disabling chapter numbering), use the context xref.

  3. Customize the corresponding context to your requirements.

  

back to top