The advent of hypertext technology gives us the opportunity to make it much easier for the reader to jump around when looking for information. However, DocBook's ability to create both Web pages and paper copy complicates the task of linking. We want the Web versions to be hot-clickable, but keep in mind that the paper version must still be useful even though we can't click on it.
The paper equivalent of a hyperlink is a cross-reference. A cross-reference within the same work might say something like “See the section on frog identification below.” If you phrase your document in this way and use the right tags carefully, this will read normally in the print version and the Web version will read the same way and also be a link.
For cross-references to other locations in the same
document, refer to Section 8.1, “The
tags: Linking within your document”.
For references to a Web page outside the document, see Section 8.2, “Linking to a Web page”.
Both Web and paper documents may refer to external
works: printed books or documents. For this kind of
linking, use the
citetitle element; see
Section 7, “Inline markup”.
To refer to another location in the same document:
Invent a unique identifier name for the location to
which you want to refer. The first character must be
a letter, and the rest letters,
numbers, hyphens, and the underscore (
For example, you might use the identifier
flute-tuning for a section on how to tune a
Find the start tag for the element to which you want to
refer, and attach an
xml:id=' attribute to that tag, where
identifier name you invented in the previous step. Any
DocBook start tag can carry an
For example, to refer to a main section, add the
xsl:id attribute to the
At the location where you want to cross-refer, use a tag of the form:
I is the identifier
defined in the previous step and
T is the text of the link.
<section xml:id='thule-history'> <title>The History of Thule</title> ... <section> ... <para>For more amusing folk traditions of Greenland, see <link linkend='thule-history'>History of Thule</link> above. </para>
In the HTML output, this will produce a clickable link.
In the PDF output, the content of the
element will also be clickable, although it will not
appear any differently than the surrounding text.
You can also use the empty element
xml:id=' to define a
target location, where
is the same unique identifier.
There are three ways to use this element. All three require
that you assign a unique
xml:id attribute to the
element to which you are linking:
Just encode it as
<xref linkend=', where
I is the target identifier. The link text
will depend on the type of element. For example, a
reference to a
chapter element will generate
link text containing the chapter number and title.
If there is an element somewhere near the target identifier whose content you would like to use as the link text, use this construct:
identifier of the element you want to link to, and the
link text will be taken from the content of the element
For example, suppose a chapter starts like this:
<chapter xml:id='ch11'> <info> <title>The <emphasis xml:id='ch11-abbr'>Last Chapter<emphasis></title> </info>
Then this reference would use “Last Chapter” as the link text:
<xref linkend='ch11' endterm='ch11-abbr'/>
You can specify what link text you want to use for a
specific target by adding an
attribute to the target element. Any
element that refers to that target will automatically use
that attribute's value as its link text.
For example, suppose you start a chapter like this:
<chapter xml:id='ch14' xreflabel="The Silly Chapter">...
then any reference of the form
xml:id='ch14'/> would use “The Silly
Chapter” as its link text.
You may use any inline element as a link: simply add a
For example, to mark up the word “Smashilator”
as an application, and to make this word a link to a section