xml文件中的DOCTYPE的含义是什么? [英] What is the meaning of DOCTYPE in xml file?
问题描述
在xml中,第一行是版本,然后我们指定DOCTYPE DTD行。
示例:
<!DOCTYPE hibernate-mapping PUBLIC - // Hibernate / Hibernate Mapping DTD 3.0 // ENhttp://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">
任何人都可以解释一下这是什么意思吗?
我知道DTD是文档类型定义,就像为XML定义语法一样。
我想知道这个声明中的属性。 您引用的行是文档类型声明。
W3C的XML推荐文档中记载了 http://www.w3.org/TR/xml/#dt-doctype
它指定处理文档时要使用的DTD。有两种机制可用于指定这个
-
一个可选的PUBLIC标识符(很少这些
天)例如,
- // Hibernate / Hibernate Mapping DTD 3.0 // EN。解析为DTD资源
的机制是特定于应用程序的。
-
SYSTEM
标识符,在您的示例中是
http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd。
这通常被解释为一个
的URL,其中DTD可以是
检索的位置。
In hibernate we use configuration and mapping xml files. In xml the first line will be version and then we specify DOCTYPE DTD line. Example:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
Can anybody please explain what is the meaning of this? I know that DTD is document type definition which is like defining grammar for the xml.
I want to know the attributes in this statement.
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
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.
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.
这篇关于xml文件中的DOCTYPE的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!