There are three types of links we will cover here. They are <ulink>, <link>, and <xref>. Here is an example of all three:
<para> In this sentence <link linkend="admon-docbook-guide">this</link> word is hot and points to the following section. </para> <para> There is also a link to the <ulink url="http://www.debian.org">Debian home page</ulink> in this sentence. </para> <para> Of course, we must cross-reference the <xref linkend="admon-docbook-guide"> section. </para> |
Below is how they look formatted and an explanation of the code.
In this sentence this word is hot and points to the following section.
There is also a link to the Debian home page in this sentence.
Of course, we must cross-reference the Admonitions section.
The <link> is the easiest and the most common. You can use it for hyperlinks within the document and "off-site", however, <ulink> is the proper tag for "off-site" links. The attribute "linkend" points to the "id" attribute of another element. In this case, the linkend points to a later section, Admonitions. If you were to look at the admonitions section it's code would look like this:
<sect1 id="admon-docbook-guide" xreflabel="Admonitions"> |
As you can see, the "linkend" points directly at the Admonition <sect1>'s "id" attribute.
The "url" attribute of <ulink> points to Debian's web site. It is proper to include the "http://" prior to the web site. Some browsers may not handle this well if you leave that out.
<xref>'s are a little more complicated. You'll notice that they have no ending tag. They get the text they are represented as from the targets "xreflabel" attribute if it has one. If it doesn't have one, the parser will guess at what it should be. It usually guesses correctly, however, it may not be totally correct. If you use the <xref> tag in your documents it's a good idea to use the xreflabel liberally on all elements within your document. If you look at the Admonitions SGML code you'll see it has an "xreflabel" attribute.