For faster navigation, this Iframe is preloading the Wikiwand page for 文档类型定义.

文档类型定义

此條目可参照英語維基百科相應條目来扩充。 (2017年2月4日)若您熟悉来源语言和主题,请协助参考外语维基百科扩充条目。请勿直接提交机械翻译,也不要翻译不可靠、低品质内容。依版权协议,译文需在编辑摘要注明来源,或于讨论页顶部标记((Translated page))标签。

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 實體名稱 實體內容>
  • 注释語法如下:
<!-- 註解內容 -->
{{bottomLinkPreText}} {{bottomLinkText}}
文档类型定义
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?