Home | Libraries | People | FAQ | More |
How one links to another element in BoostBook depends greatly on the nature of the element linked and how the link should appear. There are three general linking elements: <xref>, <link>, and <ulink>. Additionally, there are linking elements for referencing specific types of entities, such as classes (<classname>), functions (<functionname>), or libraries (<libraryname>).
The <xref> element references elements that have an
id
attribute and a title. The actual link text is
composed from title and type of the element referenced. To link to
a particular ID, create an <xref> element with the
linkend
attribute set to the ID of the intended
target. For instance, this section's ID is
boostbook.linking
, so we create a reference it to
with <xref linkend="boostbook.linking"/>
, which
will look like this in the text: the section called “Linking in BoostBook”.
The <link> element references an ID in the same way as
<xref>, except that <link> does not generate any text
for the link, so text must be supplied within the element. For
instance, we can again link to this chapter but this time specify
our own text with <link
linkend="boostbook.linking">like this</link>
. This
markup will result in a link to this chapter that looks like this.
The <ulink> element references a URL that is outside
of the DocBook document. The url
attribute contains
the URL to link to, and the element data provides the link
text.For instance, we can link to the the Boost web site with
<ulink
url="http://www.boost.org">Boost</ulink>,
which
appears in the document like this: Boost.
In BoostBook, <ulink> supports a custom url schema for
linking to files within the boost distribution. This is formed by
setting the url
attribute to boost:
followed by the file's path. For example, we can link to the
flyweight library with
<ulink
url="boost:/libs/flyweight/index.html">Boost.Flyweight</ulink>
,
which will appear like this: Boost.Flyweight.
This schema is only supported for BoostBook <ulink> elements.
It isn't available for any other elements or in Docbook.
The <classname>, <functionname>,
<methodname>, and <libraryname> link to classes,
functions, methods, and libraries, respectively. The text of each
element gives both the name of the element to link to and the link
text. For instance, we can link to the Function library with
<libraryname>Function</libraryname>
,
which results in the following:
Function. In cases where the displayed
text is different from the actual name, the alt
attribute can be specified. For instance, the following XML
element references the boost::function
class template but displays the text function
: <classname
alt="boost::function">function</classname>
.