Links are also in-line elements. To show a URI without creating a link, see 節 9.6.9, “統一資源識別碼 (URI)”.
Most DocBook elements accept an xml:id
attribute to give that part of the document a unique name.
The xml:id
can be used as a target for a
crossreference or link.
Any portion of the document that will be a link target
must have an xml:id
attribute. Assigning
an xml:id
to all chapters and sections,
even if there are no current plans to link to them, is a good
idea. These xml:id
s can be used as unique
reference points by anyone referring to the
HTML version of the document.
xml:id
的範例<chapter xml:id="introduction">
<title>
Introduction</title>
<para>
This is the introduction. It contains a subsection,
which is identified as well.</para>
<sect1 xml:id="introduction-moredetails">
<title>
More Details</title>
<para>
This is a subsection.</para>
</sect1>
</chapter>
Use descriptive values for xml:id
names. The values must be unique within the entire document,
not just in a single file. In the example, the subsection
xml:id
is constructed by appending text to
the chapter xml:id
. This ensures that the
xml:id
s are unique. It also helps both
reader and anyone editing the document to see where the link
is located within the document, similar to a directory path to
a file.
xref
provides the reader with a link to jump to
another section of the document. The target
xml:id
is specified in the
linkend
attribute, and xref
generates the link text automatically.
xref
範例Assume that this fragment appears somewhere in a
document that includes the xml:id
example shown above:
<para>
More information can be found
in <xref linkend="introduction"/>
.</para>
<para>
More specific information can be found
in <xref linkend="introduction-moredetails"/>
.</para>
The link text will be generated automatically, looking like (emphasized text indicates the link text):
More information can be found in Chapter 1, Introduction.
More specific information can be found in Section 1.1, “More Details”.
The link text is generated automatically from the chapter
and section number and title
elements.
The link element described here allows the writer to define the link text. When link text is used, it is very important to be descriptive to give the reader an idea of where the link goes. Remember that DocBook can be rendered to multiple types of media. The reader might be looking at a printed book or other form of media where there are no links. If the link text is not descriptive enough, the reader might not be able to locate the linked section.
The xlink:href
attribute
is the URL of the page,
and the content of the element is the text that
will be displayed for the user to activate.
In many situations, it is preferable to show the actual URL rather than text. This can be done by leaving out the element text entirely.
link
到 FreeBSD 說明文件網頁範例Link to the book or article URL
entity. To link to a specific chapter in a book, add a
slash and the chapter file name, followed by an optional
anchor within the chapter. For articles, link to the
article URL entity, followed by an
optional anchor within the article.
URL entities can be found in
doc/share/xml/urls.ent
.
Usage for FreeBSD book links:
<para>
Read the <link
xlink:href="&url.books.handbook;/svn.html#svn-intro">
SVN
introduction</link>
, then pick the nearest mirror from
the list of <link
xlink:href="&url.books.handbook;/svn.html#svn-mirrors">
Subversion
mirror sites</link>
.</para>
輸出結果:
Read the SVN introduction, then pick the nearest mirror from the list of Subversion mirror sites.
Usage for FreeBSD article links:
<para>
Read this
<link xlink:href="&url.articles.bsdl-gpl;">
article
about the BSD license</link>
, or just the
<link xlink:href="&url.articles.bsdl-gpl;#intro">
introduction</link>
.</para>
輸出結果:
Read this article about the BSD license, or just the introduction.
link
到 FreeBSD 網頁範例用法:
<para>
Of course, you could stop reading this document and go to the
<link xlink:href="&url.base;/index.html">
FreeBSD home page</link>
instead.</para>
輸出結果:
Of course, you could stop reading this document and go to the FreeBSD home page instead.
link
到外部網頁範例用法:
<para>
Wikipedia has an excellent reference on
<link
xlink:href="http://en.wikipedia.org/wiki/GUID_Partition_Table">
GUID
Partition Tables</link>
.</para>
輸出結果:
Wikipedia has an excellent reference on GUID Partition Tables.
The link text can be omitted to show the actual URL:
<para>
Wikipedia has an excellent reference on
GUID Partition Tables: <link
xlink:href="http://en.wikipedia.org/wiki/GUID_Partition_Table">
</link>
.</para>
The same link can be entered using shorter notation instead of a separate ending tag:
<para>
Wikipedia has an excellent reference on
GUID Partition Tables: <link
xlink:href="http://en.wikipedia.org/wiki/GUID_Partition_Table"/>
.</para>
The two methods are equivalent. Appearance:
Wikipedia has an excellent reference on GUID Partition
Tables: http://en.wikipedia.org/wiki/GUID_Partition_Table
.
本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。
若有 FreeBSD 方面疑問,請先閱讀
FreeBSD 相關文件,如不能解決的話,再洽詢
<questions@FreeBSD.org>。
關於本文件的問題,請洽詢
<doc@FreeBSD.org>。