DTD - Elements
- Baya na baya Kwarara na karshe
- Baya na karshe DTD - Attibutu
在一个 DTD 中,元素通过元素声明来进行声明。
声明一个元素
在 DTD 中,XML 元素通过元素声明来进行声明。元素声明使用下面的语法:
!ELEMENT 元素名称 类别
Or
!ELEMENT 元素名称 (元素内容)
空元素
空元素通过类别关键词EMPTY进行声明:
!ELEMENT 元素名称 EMPTY
Anfani:
!ELEMENT br EMPTY
XML例子:
<br />
只有 PCDATA 的元素
只有 PCDATA 的元素通过圆括号中的 #PCDATA 进行声明:
!ELEMENT 元素名称 (#PCDATA)
Anfani:
!ELEMENT from (#PCDATA)
带有任何内容的元素
通过类别关键词 ANY 声明的元素,可包含任何可解析数据的组合:
!ELEMENT 元素名称 ANY
Anfani:
!ELEMENT note ANY
An element with child elements (sequence)
An element with one or more child elements is declared by the child element names in parentheses:
<!ELEMENT 元素名称 (子元素名称 1)>
Or
<!ELEMENT 元素名称 (子元素名称 1,子元素名称 2,...)>
Anfani:
<!ELEMENT note (to,from,heading,body)>
When child elements are declared in a sequence separated by commas, these child elements must appear in the same order in the document. In a complete declaration, child elements must also be declared, and child elements can also have child elements. The complete declaration of the "note" element is:
<!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>
Declare the element that appears only once
<!ELEMENT 元素名称 (子元素名称)>
Anfani:
<!ELEMENT note (message)>
The above example states that the "message" child element must appear once and must only appear once within the "note" element.
Declare the element that appears at least once
<!ELEMENT 元素名称 (子元素名称+)>
Anfani:
<!ELEMENT note (message+)>
The plus sign in the above example states that the "message" child element must appear at least once within the "note" element.
Declare the element that appears zero or multiple times
<!ELEMENT 元素名称 (子元素名称*)>
Anfani:
<!ELEMENT note (message*)>
The asterisk in the above example states that the child element "message" can appear zero or multiple times within the "note" element.
Declare the element that appears zero or once
<!ELEMENT 元素名称 (子元素名称?)>
Anfani:
<!ELEMENT note (message?)>
The question mark in the above example states that the child element "message" can appear zero or once within the "note" element.
Declare the content of the type "non.../both..."
Anfani:
<!ELEMENT note (to,from,header,(message|body))>
An example states that the "note" element must contain the "to" element, the "from" element, the "header" element, and the non-"message" element, which is the "body" element.
An fahimtar da shi: an fahimtar da shi a cikin kiyaye.
Anfani:
<!ELEMENT note (#PCDATA|to|from|header|message)*>
An fahimtar da shi: "note" elemnti zai iya daurin kama da kuma yawa na PCDATA, "to", "from", "header" ko "message".
- Baya na baya Kwarara na karshe
- Baya na karshe DTD - Attibutu