4.10. 元素、实体和属性——DocBook文档的积木

SGML/XML的文件主要由如下三部分构成:Elements, Attributes and Entities。

  1. Elements(元素)

    Describe a document's content and structure. 如:<sect1> </sect1>.

  2. Attributes(元素的属性)

    Elements can, but don't necessarily, include one or more attributes, which are additional terms that extend the function or refine the content of a given element.

    <sect1 id="idvalue">, id 是 元素 sect1的属性。

  3. Entities(实体)

    In the most general terms, entities allow you to assign a name to some chunk of data, and use that name to refer to that data.

    general entities and parameter entities:

    • General Entities(一般实体:包括内部实体和外部实体)

      由 & 和 ; 分隔的为实体。包括内部实体(定义在文件内部,引用的文本数据等) 和外部实体(指向文件外部的文件等)。

      如: <!ENTITY ora "O'Reilly & Associates"> 为内部实体。 如: "lt; 为指向 < 的内部实体。 <!ENTITY ch01 SYSTEM "ch01.sgm"> 为外部实体。 再入: <!ENTITY tree SYSTEM "tree.eps" NDATA EPS> 为指向外部图形的实体。

    • Parameter Entities(参数实体)

      只用在DTD中的实体声明。是由 % 和 ; 分隔的。在“标记块”中引用,实现标记块是被 忽略还是包含。对于SGML,“标记块”可以出现在DTD和SGML文档中;而对于XML,只出现 在DTD中。

      marked sections 中常用的关键字为 INCLUDE 和 IGNORE。

      Parameter entities are most frequently used to customize the DTD.

      You might use a parameter entity reference in an SGML document in a marked section. Marking sections is a mechanism for indicating that special processing should apply to a particular block of text. Marked sections are introduced by the special sequence <![keyword[ and end with ]]>. In SGML, marked sections can appear in both DTDs and document instances. In XML, they're only allowed in the DTD.