文件类型描述


文件类型描述 (正體)

XML 文件的文档类型描述(Document Type Definition)可以看成一个或者多个 XML 文件的模板,在这里可以定义 XML 文件中的元素、元素的属性、元素的排列方式、元素包含的内容等等。

DTD(Document Type Definition)概念缘于 SGML,每一份 SGML 文件,均应有相对应的 DTD。对 XML 文件而言,DTD 并非特别需要,well-formed XML 就不需要有 DTD。DTD 有四个组成如下:

  • 元素(Elements)
  • 属性(Attribute)
  • 实体(Entities)
  • 注释(Comments)

由于 DTD 限制较多,使用时较不方便,近来已渐被 XML Schema 所取代。

声明语法

  • 元素声明语法如下:
<!ELEMENT 元素名稱 元素內容>
  • 属性声明语法如下:
<!ATTLIST 元素名稱、屬性名稱、屬性值型態、屬性的內定值>
  • 实体声明语法如下:
<!ENTITY 實體名稱 實體內容>
  • 注释语法如下:
<!-- 註解內容 -->






stock | retire | vm
Why are we here?
All text is available under the terms of the GNU Free Documentation License
This page is cache of Wikipedia. History