What is the meaning of DOCTYPE in xml file?

蹲街弑〆低调 提交于 2019-11-29 14:52:59

The line you refer to is the document type declaration.

It is documented in the W3C's XML Recommendation here: http://www.w3.org/TR/xml/#dt-doctype

It specifies a DTD that is to be used when processing the document. Two mechanisms are available for specifying this

  1. an optional PUBLIC identifier (rare these days) which is, in your example, " -//Hibernate/Hibernate Mapping DTD 3.0//EN". The mechanism by which this is resolved to a DTD resource is application-specific.

  2. A SYSTEM identifier, which in your example is "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd". This is typically interpreted as a URL from where the DTD can be retrieved.

A Doctype describes which DTD the XML file follows.

This:

  1. Describes what elements are allowed inside what other elements (for the purpose of validation)
  2. Describes what named character references are available (beyond the 5 XML built-ins of &, <, >, ' and ").
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!