In a DTD, XML elements are declared with a DTD element declaration.在DTD中,XML元素是用DTDA元素的声明方式来声明的。
In the DTD, XML elements are declared with an element declaration. An element declaration has the following syntax:在DTD中,XML元素是用XML元素的声明方式来声明的。元素的声明方式含有以下句法构造:
<!ELEMENT element-name category>or<!ELEMENT element-name (element-content)>Empty elements are declared with the category keyword EMPTY:空元素是用类别关键字EMPTY来声明的:
<!ELEMENT element-name EMPTY>example: <!ELEMENT br EMPTY> XML example: <br />Elements with only character data are declared with #PCDATA inside parentheses:纯字符数据的元素用圆括号中的#PCDATA来声明:
<!ELEMENT element-name (#PCDATA)>example: <!ELEMENT from (#PCDATA)>Elements declared with the category keyword ANY, can contain any combination of parsable data:以类别关键字ANY声明的元素能包括任何部分数据的结合体。
<!ELEMENT element-name ANY> example: <!ELEMENT note ANY>Elements with one or more children are defined with the name of the children elements inside parentheses:……包含若干个子类别的元素用圆括号中的子元素的名字来定义。
<!ELEMENT element-name (child-element-name)>or<!ELEMENT element-name (child-element-name,child-element-name,.....)> example: <!ELEMENT note (to,from,heading,body)>When children are declared in a sequence separated by commas, the children must appear in the same sequence in the document. In a full declaration, the children must also be declared, and the children can also have children. The full declaration of the "note" element will be: 当子元素被逗号依次隔开声明时,子元素必须在文件中以相同的顺序出现。在一个完整的声明中,子元素必须也被声明,同时子元素也能有子元素。"note"元素的完整声明是:
<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>The example declaration above declares that the child element message must occur once, and only once inside the "note" element.上面的实例声明了子元素信息必须出现一次,并且在"note"元素中只出现一次。
The + sign in the example above declares that the child element message must occur one or more times inside the "note" element.上面实例中的加号声明了子元素信息必须在"note"元素中出现一次或几次。
The * sign in the example above declares that the child element message can occur zero or more times inside the "note" element.在上面实例中的*号声明了子元素信息可以在"note"元素中出现0或更多次数。
The ? sign in the example above declares that the child element message can occur zero or one times inside the "note" element.在上面的实例中的?号声明了子元素信息可以在"note"元素中出现0或1次。
The example above declares that the "note" element must contain a "to" element, a "from" element, a "header" element, and either a "message" or a "body" element.上面的事例声明了"note"元素必须包含一个”TO”元素、一个“form”元素、一个“header”元素以及“message”或“body”元素。
The example above declares that the "note" element can contain zero or more occurrences of parsed character, "to", "from", "header", or "message" elements.上面的实例声明了"note"元素可以包含0或更多分列字符(“or”、“form”、“header”或“message”元素)。
