1. Role of DTD
A DTD is a type of XML that lists the elements in the XML, the relationships between elements, what the elements can have, and what the attributes of the elements are. The DTD essentially describes the relationship between elements, that is, the relationship between classes. is a description of a tree structure, similar to XML .
The responsibility of the DTD is only responsible for standardizing the structure of the document, and the actual validation work is performed by the application. So XML is not a processing language, but a language to describe the data.
The keyword for a DTD is an object-oriented Attribute attribute, which is a description of the various types.
A DTD is a definition of all the keywords to be described, equivalent to a custom keyword (the tag structure of an element of XML)
2, the content of the DTD:
(1) References to DTDs
The DTD can be inside the XML and must have the DOCTYPE keyword to boot. On the outside, the relevant reference is made, which is divided into the system identifier and the public identifier. Use a variety of methods to refer to DTDs.
<! DOCTYPE xxx root element SYSTEM "path" [internal definition]>
<! DOCTYPE XXX root element Public "FPI definition" "File name" >
(2) Declaration of elements
element's content model element content, mixed content, empty content, arbitrary content.
Element content: Child elements, order, selection. (,,) (|)
Mixed content is shaped like an element's content. (pcdata| Element)
Empty <! Element elements empty>
Any <! Element elements any>
(3) Attribute declaration
<! Attlist element Name Property Name property Type property Value Declaration >
Property type: Limits the value that the property can take. It is especially emphasized that the type of attribute is limited when it is defined, but it is not the same when used.
ID type, the attribute must be unique when it is used.
When you define a property as a IDREF type, this property is used to refer to the attribute name of the element property type ID.
Identification function NmToken
Properties of enum types
Entity (used in conjunction with the definition of the entity, when the entity exists in the attribute)
How property values are valued: can be default, fixed, must, implied. is to restrict the existence of a property. It can be understood that the value of the property is how much.
(4) Entity references (using these entities defined in the DTD in XML)
Built-in entities (5 standard) character entities (character direct reference &) Ordinary entities (a section of content substitution typically XML reference dtd--dtd reference text file unsigned &) parameter entity (% in DTD definition)
The DTD specifies the rules of the game.