DocBook XML 标记 XML 标记 XML 标记 请仔细阅读这一章。这一章描述了 Docs Project 使用的标记。一些规则是 Docs Project 特定的。 如果这些标记运用合适,搜索文档时可以得到有意义的结果。这些标记帮助搜索引擎确认与搜索条件相关的信息。另一个好处是使 &PROJECT; 文档拥有相同的外观。(不过,由于输出格式不同,外观仍然会有一些区别。) XML 标记概要 XML 中所有标记必须有开标记和闭标记。另外,按照惯例,章、节、图象、表格等必须有唯一的标识符,这样可以被正确标识,需要的话也可以交叉引用。 尽管 XML 可以处理很多文档形式,这里介绍的只是 article 一种。 本章只介绍 &PROJECT; 文档使用的标记,并不是所有可用的 DocBook XML 标记。完整的列表请参考: http://www.docbook.org/tdg/en/html/docbook.html 标记和实体警告 xml 标记 警告 应当牢记本节的警告。它们比有效的 DocBook XML 更加严格,这些规则的存在,是为了使 HTML 和 PDF 输出看起来更合适。 不要使用商标实体 不要使用商标实体 &trade;, &copy;, 或 &reg; 因为它们无法为所有字符集产生 HTML 输出。这些实体产生的 HTML 输出定义在 DTD 中,无法通过样式表改变。 应当使用 trademark 标记以及相关类别,如下所示: <trademark>其后是商标符号</trademark> <trademark class="registered">其后是注册商标符号</trademark> <trademark class="copyright">其后是版权符号</trademark> para 标记中的内容 除非是文本段落,否则不要使用 para。这个标记在 PDF 中,会使其间的文本包含多余的空白。 特别的,在下列标记之外不要使用 para (换句话说,不要把下列标记包含在 para 中): <screen> <itemizedlist> <orderedlist> <variablelist> <table> 包含在 para 标记中的 listitem 包含在 para 中的 listitem 标记 必须 紧挨 <para> 的开始标记,以避免 PDF 中的多余空白。 包含在 screen 标记中的内容 XML 文件中,screen 标记 (<screen> 和 </screen>) 必须 靠左对齐,screen 包含的内容必须同样靠左对齐,除非有意留出空白。否则,多余的空白将出现在 HTML 中。 <command>application</command> XML 标记 application application 是图形界面应用程序的名字。command 是一个可执行的程序,或者运行应用程序的命令。 <application></application> 标记使您可以引用应用程序。例如,下面的 XML: 要在 Linux 中访问 Web,您可以使用 <application>Mozilla</application> 或 <application>lynx</application>,如果您只需要字符界面的话。 产生如下输出: 要在 Linux 中访问 Web,您可以使用 Mozillalynx,如果您只需要字符界面的话。 <command>chapter</command> XML 标记 chapter 一篇 DocBook 文档可以划分为多章,类似: <chapter id="ch-sample"> <title>示例章</title> <para>这是示例章,显示了用于创建章、节和小节的 XML 标记。</para> </chapter> chapter 还可以进一步划分为节 (sect1, sect2, sect3 等等)。请参考 <command>citetitle</command> XML 标记 citetitle <citetitle>标记用来格式化一个特别的引用 (引用标题可以自行输入,也可以使用实体实体是引用其他手册或教程的快捷方式。它可以在主控文档中定义,对于特定的文档集合,也可以在 DTD 引用的文件中定义。,如果在文档中已经定义的话)。 例如: <citetitle>IG;</citetitle>. 输出类似于 &IG;,因为 &IG; 是已定义的实体。 <command>command</command> XML 标记 command application 是图形界面应用程序的名字。command 是一个可执行的程序,或者运行应用程序的命令。任何命令行程序,或是只有字符界面的工具都应以 command 标记。 如果某些文本是一个命令,那就用 <command></command> 标记: 要在安装后改变键盘设置,切换为 root 并使用 <command>redhat-config-keyboard</command> 命令,或者在 root 提示符下输入 <command>setup</command>。 输出: 要在安装后改变键盘设置,切换为 root 并使用 redhat-config-keyboard 命令,或者在 root 提示符下输入 setup 另一个例子: <command>MAILNOVIOLATIONS</command> — 如果设置为 <command>true</command>,这个选项使得 Tripwire 定时发送邮件报告,无论是否出现了越权操作。默认值是 <command>true</command>。 输出: MAILNOVIOLATIONS — 如果设置为 true,这个选项使得 Tripwire 定时发送邮件报告,无论是否出现了越权操作。默认值是 true 注意 本例中,选项值 (true) 被标记为 <command>。由于选项是出现在配置文件中的,(命令行选项应当使用 <option> 标记,)并且由于没有为配置文件选项定义什么标记,我们约定使用 <command> 标记配置文件中的选项。 名词也标记为 command,因为没有其他合适的标记: 配置文件中的选项,类似 Apache 指令 守护进程名称 <command>computeroutput</command> XML 标记 computeroutput 要显示屏幕输出,使用这个标记: <computeroutput>您是否要删除文件? y n</computeroutput> 输出: 您是否要删除文件? y n <command>emphasis</command> XML 标记 emphasis 要强调的内容,使用 <emphasis></emphasis> 标记。例如: 安装过程将 <emphasis>删除所有</emphasis> 硬盘上的 <emphasis>所有</emphasis> 已有 Linux 分区,非 Linux 分区不会被删除。 输出: 安装过程将 删除所有 硬盘上的 所有 已有 Linux 分区,非 Linux 分区不会被删除。 <command>example</command> XML 标记 example <example></example> 标记用来格式化某个文档中的文本,适于显示代码示例等。 <example> 标记应当有一个 ID 和标题: <example id="static-ip"> <title>使用 DHCP 的静态 IP 地址</title> <screen width=60> <computeroutput> host apex { option host-name "apex.example.com"; hardware ethernet 00:A0:78:8E:9E:AA; fixed-address 192.168.1.4; } <computeroutput> </screen> </example> 输出: 使用 DHCP 的静态 IP 地址 host apex { option host-name "apex.example.com"; hardware ethernet 00:A0:78:8E:9E:AA; fixed-address 192.168.1.4; } <command>filename</command> XML 标记 filename <filename></filename> 标记定义文件名和路径。由于目录是特殊的文件,因此也使用 filename 标记。例如: 编辑 <filename>/home/smoore/sam.xml</filename> 文件,修改它或加注释。 输出: 编辑 /home/smoore/sam.xml 文件,修改它或加注释。 它们也用来标记 RPM 软件包名称。例如: 要使用 <application>Keyboard Configuration Tool</application>,必须安装 <filename>system-config-keyboard</filename> 软件包。 输出: 要使用 Keyboard Configuration Tool,必须安装 redhat-config-keyboard 软件包。 注意 目录名必须以斜线 (/) 结尾,以与文件名区分。 <command>firstterm</command> XML 标记 firstterm <firstterm></firstterm> 标记用来定义一个用户不熟悉,但将频繁出现的词。例如: 几乎所有现代操作系统都使用 <firstterm>disk partitions</firstterm>(磁盘分区),&FC; 也不例外。 输出: 几乎所有现代操作系统都使用 disk partitions(磁盘分区),&FC; 也不例外。 <command>footnote</command> XML 标记 footnote 如果您需要添加脚注,可以这样: 如果您想进行服务器级 <footnote> <para> 服务器级安装用于安装典型的服务器环境。注意,服务器级安装不会安装图形界面。 </para> </footnote> 安装,请参考 <citetitle>Installation Guide</citetitle>。 输出: 如果您想进行服务器级 服务器级安装用于安装典型的服务器环境。注意,服务器级安装不会安装图形界面。 安装,请参考 Installation Guide <command>figure</command> XML 标记 figure 注意 顺序很重要!EPS 文件 必须 首先声明。 示例图象声明: <figure id="fig-ksconfig-basic"> <title>基本设置</title> <mediaobject> <imageobject> <imagedata fileref="./figs/ksconfig/ksconfig-basic.eps" format="EPS"/> </imageobject> <imageobject> <imagedata fileref="./figs/ksconfig/ksconfig-basic.png" format="PNG"/> </imageobject> <textobject> <phrase> 一些关于图象的文本描述 </phrase> </textobject> </mediaobject> </figure> 下面列出了需要修改的内容: <figure id="fig-ksconfig-basic"> ==> id="" 可以修改 <title>基本设置</title> ==> 标题可以修改 fileref="./figs/ksconfig/ksconfig-basics.eps"> ==> .eps 位置可以修改 fileref="./figs/ksconfig/ksconfig-basics.png"> ==> .png 位置可以修改 <phrase>一些关于图象的文本描述</phrase> ==> "一些关于..." 可以修改 关于获取屏幕截图,请参考 图形用户界面标记 XML 标记 GUI 标记 <command>guilabel</command> XML 标记 GUI 标记 guilabel XML 标记 guilabel 使用 <guilabel></guilabel> 作为描述 GUI 时的默认标记,类似窗体名称或窗体标题。例如: <guilabel>Authentication Configuration</guilabel> 屏幕指引您如何配置更安全的系统。 输出: Authentication Configuration 屏幕指引您如何配置更安全的系统。 <command>guibutton</command> XML 标记 GUI 标记 guibutton XML 标记 guibutton 使用 <guibutton></guibutton> 标记表示屏幕或菜单中的按钮。例如: 选择 <guibutton>Activate on boot</guibutton> 按钮,配置 X 窗口系统自动启动。 输出: 选择 Activate on boot 按钮,配置 X 窗口系统自动启动。 <command>guiicon</command> XML 标记 GUI 标记 guiicon XML 标记 guiicon <guiicon></guiicon> 标记用来表示面板或桌面图标。例如: 双击桌面上的 <guiicon>Start Here</guiicon> 图标。 输出: 双击桌面上的 Start Here 图标。 <command>guimenu</command> 和 <command>guimenuitem</command> XML 标记 GUI 标记 guimenu XML 标记 guimenu XML 标记 GUI 标记 guimenuitem XML 标记 guimenuitem 要表示一个菜单 (安装程序或控制面板中的菜单),使用 <guimenu></guimenu> 标记。 要表示子菜单,使用 <guimenuitem></guimenuitem> 标记。(请注意示例中为了输出需要,插入了一些换行。)例如: 选择 <guimenu>Main Menu</guimenu> => <guimenuitem>Programming</guimenuitem> => <guimenuitem>Emacs</guimenuitem> 来启动 <application>Emacs</application> 编辑器。 输出: 选择 Main Menu => Programming => Emacs 来启动 Emacs 编辑器。 <command>keycap</command> XML 标记 keycap 要表示某个按键,应当使用 <keycap></keycap> 标记。按键会自动加上尖括号,因此不要在 XML 代码中再加一次。例如: 要作出选择,按下 <keycap>Enter</keycap> 键。 输出: 要作出选择,按下 Enter 键。 <command>menuchoice</command> XML 标记 menuchoice 通常,使用鼠标对于频繁的操作过于繁琐。因此,程序员在程序中设置了快捷键来简化使用。应当使用 shortcut 标记包含 keycap 标记,然后再整个包含在 menuchoice 标记中,来表示快捷键。例如: 打开菜单并选择: <menuchoice> <shortcut> <keycombo><keycap>Ctrl</keycap><keycap>s</keycap></keycombo> </shortcut> <guimenu><accel>F</accel>ile</guimenu> <guimenuitem><accel>S</accel>ave</guimenuitem> </menuchoice>. 输出: 打开菜单并选择:CtrlsFileSave. <command>keycombo</command> XML 标记 keycombo 要描述按键组合,使用 <keycombo></keycombo>, <keycap></keycap> 标记。例如: 要重启系统,按下 <keycombo> <keycap>Ctrl</keycap><keycap>Alt</keycap><keycap>Del</keycap> </keycombo>. 输出: 要重启系统,按下 CtrlAltDel. 列表 列表 创建 您可以用 XML 创建多种列表。您可以创建无序的枚举,有序的编号列表,或是变量表 (先是一个词,然后是单独的一段话)。 还有一种列表适于表格,最后一种是用于定义词汇解释的列表。 下面各节描述了各种列表,以及如何创建。 <command>itemizedlist</command> XML 标记 itemizedlist XML 标记 列表 itemizedlist 列表 itemizedlist itemizedlist 适于向读者呈现重要的信息,而信息是无序的。它比 variablelist 更短,也简单一点。 要创建 itemizedlist (也称为枚举列表),可以这样: 注意 下面列表中的文本是直接包含在 para 标记中的。如果您使用列表,不要用这个标记,否则列表中会包含多余空白,无法对齐。如果多个列表项是多行文本,空白会更加明显。HTML 版本不会像 PDF 版本那样明显。 <itemizedlist> <listitem> <para>熟悉安装程序的界面</para> </listitem> <listitem> <para>开始安装程序</para> </listitem> <listitem> <para>选择安装方法</para> </listitem> </itemizedlist> 输出: 熟悉安装程序的界面 开始安装程序 选择安装方法 <command>orderedlist</command> XML 标记 orderedlist 列表 orderedlist XML 标记 列表 orderedlist orderedlist 适于向读者显示必须以一定顺序出现的信息。orderedlist 用来向读者描述一步一步的场景转换很不错。 要创建 orderedlist (有序列表) 可以这样: 注意 下面列表中的文本是直接包含在 para 标记中的。如果您使用列表,不要用这个标记,否则列表中会包含多余空白,无法对齐。如果多个列表项是多行文本,空白会更加明显。HTML 版本不会像 PDF 版本那样明显。 <orderedlist> <listitem> <para>在线 &mdash; http://www.redhat.com/support/errata; 提供 可以在线阅读的更正,您也可以下载光盘镜像。 </para> </listitem> <listitem> <para>电子邮件 &mdash; 发送空白邮件到 errata@redhat.com, 您将收到完整的包含安装程序和相关软件 (如果有的话) 的更正说明。 同时还包括软件更新以及光盘镜像的 URL。通过这些 URL 来下载 镜像。请注意:下载时使用二进制模式。</para> </listitem> </orderedlist> 输出: 在线 — http://www.redhat.com/support/errata; 提供可以在线阅读的更正,您也可以下载光盘镜像。 电子邮件 — 发送空白邮件到 errata@redhat.com, 您将收到完整的包含安装程序和相关软件 (如果有的话) 的更正说明。同时还包括软件更新以及的光盘镜像的 URL。通过这些 URL 来下载镜像。请注意:下载时使用二进制模式。 <command>variablelist</command> XML 标记 variablelist XML 标记 列表 variablelist 列表 variablelist variablelist 适于表现一个词以及相关的解释和描述。 要创建 variablelist 可以这样: 注意 下面列表中的文本是直接包含在 para 标记中的。如果您使用列表,不要用这个标记,否则列表中会包含多余空白,无法对齐。如果多个列表项是多行文本,空白会更加明显。HTML 版本不会像 PDF 版本那样明显。 <variablelist> <varlistentry> <term> 新的多介质安装过程 </term> <listitem> <para>由于安装程序越来越大,RedHat 开发了 可以处理多张 CD-ROM 介质的安装程序。</para> </listitem> </varlistentry> <varlistentry> <term>XFree 4.0 </term> <listitem> <para>X 窗口系统的配置从来没有如此简单。 从选择显示器及其设置,到显卡探测,以及测试您期望的 X 窗口设置, Xconfigurator 可以搞定一切。</para> </listitem> </varlistentry> </variablelist> 输出: 新的多介质安装过程 由于安装程序越来越大,RedHat 开发了可以处理多张 CD-ROM 介质的安装程序。 XFree 4.0 X 窗口系统的配置从来没有如此简单。从选择显示器及其设置,到显卡探测,以及测试您期望的 X 窗口设置,Xconfigurator 可以搞定一切。 警告 不要 设置表格的 frame 属性,否则 PDF 生成会失败。 在表格中创建列表,使用 <command>simplelist</command> XML 标记 simplelist XML 标记 列表 simplelist 列表 simplelist 表格 在表格中创建列表 simplelist simplelist 是无修饰的列表。simplelist 可以内联或按列对齐。 使用 simplelist 在表格内添加分离的文本段落。通常的列表,例如 itemizedlist,不能嵌入在表格内。 XML 代码如下: <table id="tb-hwinfo-hostbus"> <title>主机总线适配器特性及配置要求</title> <tgroup cols="3"> <colspec colnum="1" colname="HostBus" colwidth="33"/> <colspec colnum="2" colname="Features" colwidth="34"/> <colspec colnum="3" colname="Single" colwidth="33"/> <thead> <row> <entry>主机总线适配器</entry> <entry>特性</entry> <entry>Single-Initiator 配置</entry> </row> </thead> <tbody> <row> <entry>Adaptec 2940U2W</entry> <entry><simplelist> <member>Ultra2, wide, LVD.</member> <member>HD68 external connector.</member> <member>One channel, with two bus segments.</member> <member>Set the onboard termination by using the BIOS utility.</member> <member>Onboard termination is disabled when the power is off.</member> </simplelist></entry> <entry><simplelist> <member>Set the onboard termination to automatic (the default).</member> <member>Use the internal SCSI connector for private (non-cluster) storage.</member> </simplelist></entry> </row> <row> <entry>Qlogic QLA1080</entry> <entry><simplelist> <member>Ultra2, wide, LVD</member> <member>VHDCI external connector</member> <member>One channel</member> <member>Set the onboard termination by using the BIOS utility.</member> <member>Onboard termination is disabled when the power is off, unless jumpers are used to enforce termination.</member> </simplelist></entry> <entry><simplelist> <member>Set the onboard termination to automatic (the default).</member> <member>Use the internal SCSI connector for private (non-cluster) storage.</member> </simplelist></entry> </row> </tbody> </tgroup> </table> 输出: 主机总线适配器特性及配置要求 主机总线适配器 特性 Single-Initiator 配置 Adaptec 2940U2W Ultra2, wide, LVD. HD68 external connector. One channel, with two bus segments. Set the onboard termination by using the BIOS utility. Onboard termination is disabled when the power is off. Set the onboard termination to automatic (the default). Use the internal SCSI connector for private (non-cluster) storage. Qlogic QLA1080 Ultra2, wide, LVD VHDCI external connector One channel Set the onboard termination by using the BIOS utility. Onboard termination is disabled when the power is off, unless jumpers are used to enforce termination. Set the onboard termination to automatic (the default). Use the internal SCSI connector for private (non-cluster) storage.
注意 注意 simplelist 标记的用法。<entry> 和 <simplelist> 标记必须靠紧,否则将产生解析错误。 每个要加入 simplelist 的段落或列表项应当包含在 <member> 标记中。
<command>glosslist</command> XML 标记 glosslist XML 标记 列表 glosslist 列表 glosslist 使用 glosslist 来创建词汇表和解释。 XML 代码如下: <glosslist> <glossentry> <glossterm>applet</glossterm> <glossdef> <para>一个小程序,通常是实用工具或简单程序。</para> </glossdef> </glossentry> <glossentry> <glossterm>architecture</glossterm> <glossdef> <para>计算机或计算机系统中, 组件的组织和整合的设计。</para> </glossdef> </glossentry> <glossentry> <glossterm>archive</glossterm> <glossdef> <para>将文件传送到存储设备,以节省空间和/或 加以组织。</para> </glossdef> </glossentry> </glosslist> 输出: applet 一个小程序,通常是实用工具或简单程序。 architecture 计算机或计算机系统中,组件的组织和整合的设计。 archive 将文件传送到存储设备,以节省空间和/或加以组织。
<command>option</command> XML 标记 option 如果您的命令需要选项或设置标志,使用 <option></option> 标记。 注意 <option> 标记只用于命令行选项,不用于配置文件。 指定选项的 XML 代码如下: 例如,运行命令 <command>ls</command> 时可以指定选项 <option>-la</option>。 输出: 例如,运行命令 ls 时可以指定选项 索引节点 创建索引 XML 标记 创建索引 下面的命令序列展示了如何向文档中添加一个索引项的代码: <indexterm> <-- 这是要在索引中添加的词汇 <primary>foo</primary> <-- 表示 "foo" 是首要条目 <secondary>bar</secondary> <-- "bar" 将列在 "foo" 条目之下 </indexterm> <-- 关闭索引项 foo bar <seealso> 标记允许您引用另一个索引项或其他手册。应确保您指向的 <seealso> 引用有自己的节点。例如: 创建索引 seealso 标记 <indexterm> <primary>SWAK</primary> <seealso>salutations</seealso> </indexterm> <indexterm> <primary>salutations</primary> </indexterm> SWAK Salutations Salutations <see> 标记允许您引用一个完整的索引节点。例如: 创建索引 see 标记 <indexterm> <primary>Guinness</primary> <see>beer</see> <-- "beer" 将被列在 "Guinness" 条目下,但是应确保所引用的 "beer" 有自己的索引节点。 </indexterm> <indexterm> <primary>beer</primary> </indexterm> Guinness Beer Beer 要查看这里的索引节点的 HTML 输出,请参考文档最后的 generated-index.html 文件。 索引是如何生成的? 如果文档中包含 indexterm,并且开标记和闭标记出现在文档或文章的结束标记之前,就创建索引,因为样式表参数 generate.index 的默认值是真。 <command>para</command> XML 标记 para 对于任意一段,<para></para> 标记必须作为这一段的开始和结束。 不要在除了简单段落之外使用 para 标记。否则,文本内部会产生多余的空白。 在下列标记周围不要使用 <para> (换句话说,不要把下列标记放在 <para> 标记中): <screen> <itemizedlist> <orderedlist> <variablelist> <table> <command>part</command> parts XML 标记 part 在主控文件中,可以将章划分为部,以表示逻辑分组。例如,在主控文件中,以 part 标签包含章的实体: <part id="pt-foo"> <partintro> <para>一些文本,对这一部分的介绍</para> &CHAPTER; &ANOTHER-CHAPTER; </part> 如果您创建了一个 part,应当对内容作一些介绍。例如: <part id="pt-setup"> <title>设置环境</title> <partintro> <para>本节讲述当您刚加入 Docs Group 时需要的信息。 您也许会再参考本节中,有关安装 &FC; 的信息。</para> </partintro> 在 HTML 输出中,会生成单独的 HTML 页面,包含这一部的编号、标题、介绍和目录。在 PDF 输出中,这些信息会出现在单独的一页上。 <command>prompt</command> XML 标记 prompt 要显示提示符,类似 root 提示符或 DOS 提示符,使用 <prompt></prompt> 标记。例如: 在 <prompt>LILO:</prompt> 启动提示符下,输入 linux 来启动到 Linux 分区。 在 <prompt>C:\></prompt> 提示符下,输入... 输出: LILO: 启动提示符下,输入 linux 来启动到 Linux 分区。 C:\> 提示符下,输入... 注意 在显示计算机输出的范例时 (通常是在 screen 标记中),不要包含提示符或命令 (除非命令或提示符是您意图显示的计算机输出)。 <command>replaceable</command> XML 标记 replaceable 要创建可替换的文本,使用 <replaceable></replaceable> 标记包围您用作可变值的文本。 这个例子演示了在引用 RPM 文件时如何使用 replaceable 标记。 foo-<replaceable>version-number</replaceable>.<replaceable>arch</replaceable>.rpm 输出: foo-version-number.arch.rpm <command>screen</command> XML 标记 screen <screen> 标记用来格式化文档中的文本,适于用来添加代码示例,计算机输出等等。在 HTML 中,使用 Fedora CSS 文件,可以显示为灰色背景的方框。需要这种效果时,只要将开标记 <screen> 和闭标记 </screen> 包围在需要强调的文本前后。 注意 使用 <screen> 标记时,必须设置所包含的所有内容,包括 <screen> 标记本身为左对齐。这样,在转化为 HTML 时,在灰色背景内部文字之前不会出现多余的空白。 <screen> 标记可能包含其他内联标记,类似 <computeroutput>, <userinput>, 或 <replaceable> 等等。其他内联标记未作要求。<screen> 标记本身可以提供足够的上下文,尤其对于简单的范例或列举文件而言。考虑范例的上下文,如果内联标记有助于阅读,那么就使用它。 如果您使用内联标记,牢记 <screen> 标记中的换行会在任何输出中生成换行。将标记与内容 放在同一行。不要在 <screen> 的内容中过分使用标记。 <screen> 示例如下: <screen> 这是 screen 的示例。其中无须使用 &lt;para&gt; 标记。 </screen> 输出: 这是 screen 的示例。其中无须使用 <para> 标记。 在 <command>screen</command> 中使用内联标记 如果您在 <screen> 中使用内联标记,遵循下列准则以保持一致。如果 screen 的内容是配置文件的清单或程序的输出,使用 <computeroutput> 标记包含整个输出。如果用户应当在命令行照范例输入,或是配置文件,使用 <userinput> 标记。用简短的叙述性的话来区分输入和输出,如下所示: <para> 输入下面的命令: </para><screen><userinput>command -sw file1</userinput></screen><para> 可以看到下列输出: </para><screen><computeroutput>Completed, time = 0.12 sec</computeroutput></screen> 输出: 输入下面的命令: command -sw file1 可以看到下列输出: Completed, time = 0.12 sec 注意 screen 标记中显示一条命令或命令序列时,不要显示提示符。 如果 <screen> 向读者显示如何修改文本的 一部分,可以将修改部分以内联的 <userinput> 标记。您可以在大块内联的 <computeroutput> 文本中使用 <userinput>。这时不要包含更多上下文,除非必须这么做。下面的示例演示了这些准则: <para> 编辑 <filename>/etc/sysconfig/init</filename> 文件,如下所示: </para><screen> GRAPHICAL=<userinput>yes</userinput></screen> 输出: 编辑 /etc/sysconfig/init 文件,如下所示: GRAPHICAL=yes 对于如何在 screen 标记中使用 replaceable 标记,请参考 section XML 标记 在文章中 (或者在 chapter 中,如果是 DocBook XML book 样式的话,类似 &IG;),可以细分为节和小节。<sect1> 总是最顶层的节。如果两个 section 级别相同,那么一个不能包含另一个 (section 2 可以包含在 section 1 里面,但是如果再创建新的 section 1,必须先关闭当前的 section 1)。大致的布局如下: <sect1 id="s1-uniquename"> <title>插入标题</title> <para> 内容文本。 </para> <sect2 id="s2-uniquename"> <title>插入标题</title> <para> 内容文本。 </para> <sect3 id="s3-uniquename"> <title>插入标题</title> <para> 内容文本。 </para> </sect3> </sect2> </sect1> 在 DocBook article 样式中,如果您只需要一级 section,可以使用 section 标记。例如: <section id="sn-uniquename"> <title>插入标题</title> <para> 内容文本。 </para> </section> <section id="sn-anothername"> <title>插入标题</title> <para> 内容文本。 </para> </section> <command>table</command> XML 标记 table 下面是创建表格的范例。 <table id="tb-mockup-before-begin"> 这在 XML 中声明了一个表格,ID 是 "tb-mockup-before-begin" <title>Available Features of GNOME and KDE</title> <tgroup cols="3"> 这在 XML 中声明了一个表格,包含三列。 <colspec colnum="1" colname="Features" colwidth="3"/> colspec 表示您向 XML 声明的表格列信息。 colnum="1" 表示您对第一列的设定。colname="Features" 表示本列的标题是 "Features"。colwidth="3" 指定列宽。这里有些机关:如果两列的列宽分别是 1 和 2,那么 1 占据的页宽就是 2 的一半。但是,如果您需要让第一列比第二列的一半稍微宽一点,那么就用一个更大的数值,例如指定列宽分别为 10 和 20,然后把 10 增加到 11 或 12,这样就比第二列的 20 的一半大一点了。如果没有给定任何值,默认就是 1。 <colspec colnum="2" colname="GNOME" colwidth="2"/> <colspec colnum="3" colname="KDE" colwidth="2"/> <thead> 包含一个或多个表格行。 <row> 包含一个或多个表格单元。 <entry>Features</entry> 表格单元元素,一列表格单元中的一个,定义了行内的列。 <entry>GNOME</entry> <entry>KDE</entry> </row> </thead> <tbody> 包含一个或多个表格行,作为表格的主体。 <row> <entry>高度可定制</entry> <entry>yes</entry> <entry>yes</entry> </row> <row> <entry>多种窗口管理器</entry> <entry>yes</entry> <entry>yes</entry> </row> <row> <entry>互联网程序</entry> <entry>yes </entry> <entry>yes </entry> </row> </tbody> </tgroup> </table> Available Features of GNOME and KDE 特性 GNOME KDE 高度可定制 yes yes 多种窗口管理器 yes yes 互联网程序 yes yes
在表格中创建列表 XML 标记 table 表格中的列表 在表格中创建列表比较困难,它要求严格的格式化以及一些 Emacs 无法完成的命令补全。 需要使用的标记是 <simplelist><member> 下面是在表格中创建列表的例子。 <table id="tb-hardware-powerswitch"> <title>不间断电源硬件</title> <tgroup cols="4"> <colspec colnum="1" colname="Hardware" colwidth="2"/> <colspec colnum="2" colname="Quantity" colwidth="2"/> <colspec colnum="3" colname="Description" colwidth="6"/> <colspec colnum="4" colname="Required" colwidth="2"/> <thead> <row> <entry>Hardware</entry> <entry>Quantity</entry> <entry>Description</entry> <entry>Required</entry> </row> </thead> <tbody> <row> <entry>Serial power switches</entry> <entry>Two</entry> <entry><simplelist> <member>Power switches enable each cluster system to power-cycle the other cluster system. Note that clusters are configured with either serial or network attached power switches and not both.</member> <member>The following serial attached power switch has been fully tested:</member> <member>RPS-10 (model M/HD in the US, and model M/EC in Europe) </member> <member>Latent support is provided for the following serial attached power switch. This switch has not yet been fully tested:</member> <member>APC Serial On/Off Switch (partAP9211), <ulink url="http://www.apc.com/">http://www.apc.com/</ulink></member> </simplelist></entry> <entry>Strongly recommended for data integrity under all failure conditions</entry> </row> </tbody> </tgroup> </table> <simplelist> 标记必须紧挨 <entry> 标记。如果不这样,就无法成功解析。 上面的示例看起来象这样: 不间断电源硬件 Hardware Quantity 描述 Required Serial power switches Two Power switches enable each cluster system to power-cycle the other cluster system. Note that clusters are configured with either serial or network attached power switches and not both.The following serial attached power switch has been fully tested:RPS-10 (model M/HD in the US, and model M/EC in Europe)Latent support is provided for the following serial attached power switch. This switch has not yet been fully tested:APC Serial On/Off Switch (partAP9211), http://www.apc.com/ Strongly recommended for data integrity under all failure conditions
<command>trademark</command> XML 标记 trademark 不要使用商标实体 &trade;, &copy;, 或 &reg; 因为它们无法为所有字符集产生 HTML 输出。这些实体产生的 HTML 输出定义在 DTD 中,无法通过样式表改变。 应当使用 trademark 标记以及相关类别,如下所示: <trademark>其后是商标符号</trademark> <trademark class="registered">其后是注册商标符号</trademark> <trademark class="copyright">其后是版权符号</trademark> <command>userinput</command> XML 标记 userinput 要显示用户将输入的内容,使用 userinput 标记。例如: 在提示符下,输入: <userinput>dd if=boot.img of=/dev/fd0 bs=1440k</userinput> 输出: 在提示符下,输入: dd if=boot.img of=/dev/fd0 bs=1440k <command>ulink</command> XML 标记 ulink 要在文本中创建 URL,如下: 在线 &mdash; <ulink url="http://www.redhat.com/support/errata/"> http://www.redhat.com/support/errata/</ulink>; 提供可以在线阅读的更正,您也可以下载光盘镜像。 输出: 在线 — http://www.redhat.com/support/errata/; 提供可以在线阅读的更正,您也可以下载光盘镜像。 注意 如果 URL 不是以文件名结尾,必须以斜线结束 (/),才是格式正确的 URL,例如 http://www.redhat.com/ <command>wordasword</command> XML 标记 wordasword <wordasword> 标记用来定义一个词只作为语法单位,不代表其他含义。 许多技术文档使用了有丰富意义的词汇。有时又需要用到不带技术意味的这个词。<wordasword> 标记这样的词,指示这个词应当简单地理解为一个词而不是其他东西。 使用这个标记不会帮助读者理解其中的意义差别;好文档应当做到这一点。实际上 <wordasword> 的价值在于全文搜索和索引工具可以用它来减少虚假结果。 例如: 要使用 <command>grep</command> 搜索单词 <wordasword>linux</wordasword>,使用命令 <command>grep linux</command>。 输出: 要使用 grep 搜索单词 linux,使用命令 grep linux 这个例子中,"linux" 仅仅是一个单词。文档不是以 Linux 为主题,这个词也不为内容添加任何相关含义,可以替换为其他任何词。 <command>xref</command> XML 标记 xref 要引用手册中其他章节,使用 <xref> 标记。 它的输出是您向读者指引的章节的标题。例如: 关于主控文件,请参考 <xref linkend="ch-tutorial"></xref> 和 <xref linkend="s1-tutorial-parent"></xref> 输出: 关于主控文件,请参考