Dtd:document Type Definition
DTD is a simple XML constrained schema language
DTD documents must be encoded in Utf-8 or Unicode
Annotations in the same way as HTML, XML documents
References to DTD documents: There are two ways to follow an XML declaration statement (externally introduced and embedded internally)
<?xml standalone= "No"?>
<! DOCTYPE ... >
Externally introduced DTD mode:
There are two ways of referencing: the first is to reference the local DTD file, and the second is the public DTD file (Doctype-name is typically named with the root element)
1 <! DOCTYPE doctype-name SYSTEM "Dtd-url" > 2 <! DOCTYPE Doctype-name Public "Dtd-name" "Dtd-url">
Internally embedded DTD mode:
1 <! DOCTYPE doctype-name [2 3]>
A simple DTD document is as follows:
<! ELEMENT Bookshelf (book+)>2 <! ELEMENT Book (name,author,price)><! ELEMENT name (#PCDATA)><! ELEMENT author (#PCDATA)><! ELEMENT Price (#PCDATA)>
DTD element definition:<! Element name usage rules >
The following rules apply:
Empty: Define NULL elements
Any: In any form
(#PCDATA): normal text
(<ELE1> <ELE2> <ELE3> ...) : unordered element Group
(<ELE1>,<ELE2>,<ELE3> ...) : Ordered element group (requires child elements to be <ELE1>, <ELE2>, <ele3> The order in which they appear)
(<ELE1>|<ELE2>|<ELE3> ...) : Only one element
The following three kinds of elements can be added after the wildcard character (+: appear one or more times;?: appears 0 or more times; *:0 or multiple times; there is nothing to indicate and only once)
such as:<! ELEMENT MYFILE (title*, Author?,email) *| COMMENT)>
The DTD attribute definition:
<! attlist element name
Att1 Property Type setting description
...
>
The property types are as follows:
CDATA: String
Enumerated
Id
...
The setup instructions are as follows:
#REQUIRED: Must be set
#IMPLIED: Optional
#FIXED ' fixed ': fixed value
"Default": Setting defaults
such as:<! Attlist meat Kind (chicken|beaf|fish| ...) "Fish">
DTD entity definition:<! Entity name "Content">
DTD simple use