Use the element keyword in a DTD document to declare an XML element. Syntax: <! element name use rules > Usage rules: (#PCDATA): Indicates that the body content of an element can only be normal text. (Parsed Character Data) Empty: Used to indicate that the body of the element is null. For example, <br/>any: used to indicate that the principal content of an element is any type. (child element): Indicates that the element contains child elements that define child elements and describe their relationship: if the child elements are separated by commas, the XML document must be written in the order in which they are declared. such as: <! Element FILE (Title,author,email) If the child element uses the "|" Separate, explain any choice. such as: <! ELEMENT FILE (title| author| EMAIL) with +, *,? To indicate the number of occurrences of an element if there is no +* behind the element?: Indicates must and can only occur once +: indicates at least one time, one or more times *: denotes dispensable, 0 times, one or more times?: Indicates can or can not, some words only once. 0 times or once such as: <! ELEMENT MYFILE (title*, AUTHOR?, EMAIL) * | COMMENT) >
Use the Attlist keyword in a DTD document to declare attributes for an element. Grammar:
<! Attlist element Name Property Name 1 property value type set Description Property Name 2 property value type set description ...
Property value type: CDATA: Indicates that the value of the property is a normal text string enumerated (DTD does not have this keyword): Represents an enumeration and can only be selected from the enumeration list, such as (chicken | beef | pork | fish) ID: Indicates that the value of the property cannot be repeated setting description # REQUIRED: Indicates that the property must appear #IMPLIED: Indicates that the property is optional #FIXED: Indicates that the value of the property is a fixed value. Syntax: #FIXED fixed Value Direct value: Indicates that the value of the property is the default value
Description of the DTD keyword in XML