XML technologies / DocBook / Cross-references and links / Internal cross-references / Advanced cross-references

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

As mentioned earlier, further customize the reference text with the attributes endterm and xrefstyle in <xref/>.

Example: A DocBook document with cross-references (xref02.xml)

<chapter ANKER="chap.xmldtd">
  <title>XML, DTDs und Schemata</title>
  <para>XML finden Sie in <xref linkend="sec.xml"/></para>
  <para>Mehr zu Document Type Definitions finden Sie in <xref linkend="sec.dtd"/></para>
  <para>Etwas zu Schemata finden Sie in <xref linkend="sec.xsd" endterm="sec.xsd.abbrev"/></para>
  <section ANKER="sec.xml">
    <title>Was ist XML</title>
    <para>... </para>
  </section>
  <section ANKER="sec.dtd" xreflabel="DTDs">
    <title>Was ist eine DTD?</title>
    <para>...</para>
  </section>
  <section ANKER="sec.xsd">
    <title>Was sind W3C-Schemata?</title>
    <titleabbrev ANKER="sec.xsd.abbrev">W3C-Schemata</titleabbrev>
    <para>...</para>
  </section>
</chapter>

Replace the placeholder ANKER with id in DocBook 4 and xml:id in DocBook 5.

Line 3: This cross-reference points to the first section (sec.xml).
Line 4: This cross-reference points to the second section (sec.dtd). The second section also has an attribute xreflabel, used as the reference text.
Line 5: A cross-reference with the additional attribute endterm. Here, the value of endterm points to an element whose content supplies the reference text.
Line 6: A section with an anchor.
Line 10: A section with an additional xreflabel. References use this attribute’s content instead of the title.
Line 16: This section contains an element titleabbrev. Referencing it through endterm provides another way to specify the reference text.

The xref element is resolved by the publishing system. The DocBook stylesheets generate the following text:

XML finden Sie in Abschnitt 1.1, "Was ist XML"
Mehr zu Document Type Definitions finden Sie in DTDs
Etwas zu Schemata finden Sie in W3C-Schemata

The highlighted text replaces xref. The additional word Abschnitt is localized and generated by the DocBook stylesheets by default. Numbering is added automatically.

The attribute endterm is rarely needed. Use it when the title must differ from the reference text.

  

back to top