5.2. XML 格式的DocBook文档

[注意]

其实XML和SGML并无太大区别,只要在写SGML格式的DocBook时遵从:

  1. If you are interested in future XML compatibility, input all element and attribute names strictly in lowercase.

  2. If you are interested in future XML compatibility, always quote all attribute values.

用 XML 撰写DocBook文档

  1. An XML Declaration

    不像 SGML的Declaration 可有可无,XML 文档必须以 An XML Declaration开始。

    <?xml version="1.0" standalone="no"?>
    
  2. A Document Type Declaration

    DocBook XML documents 需要有一个 Document Type Declaration ,虽然这并不是XML所必须。

    <?xml version='1.0'?>
    <!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN"
                             "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd">
    
  3. An Internal Subset

    在一个Document Type Declaration 中,可以包含一个或者多个 Internal Subset,如:

    <?xml version='1.0'?>
    <!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4/EN"
                             "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd" [
    <!ENTITY nwalsh "Norman Walsh">
    <!ENTITY chap1 SYSTEM "chap1.sgm">
    <!ENTITY chap2 SYSTEM "chap2.sgm">
    ]>
    
  4. The Document (or Root) Element

    如下面的 <boot> 和 </boot> 即是该文档的唯一根元素。

    <?xml version='1.0'?>
    <!DOCTYPE book PUBLIC "-//Norman Walsh//DTD DocBk XML V3.1.4//EN"
                             "http://nwalsh.com/docbook/xml/3.1.4/db3xml.dtd" [
    <!ENTITY nwalsh "Norman Walsh">
    <!ENTITY chap1 SYSTEM "chap1.sgm">
    <!ENTITY chap2 SYSTEM "chap2.sgm">
    ]>
    <book>...</book>