The elements of the XML documents can be defined in DTD using ELEMENT keyword. The elementName given below should conform to the naming syntax of XML elements.
|
Syntax |
Description |
|---|---|
|
|
General syntax for declaring elements, where category represents the type of element. |
|
|
The category is
Example: <!ELEMENT br EMPTY> |
|
|
The content of the element is only parsed character data.
Example:
|
|
|
The content of the element can be any type of parsable data.
Example:
|
|
< |
The elements with one or more children are declared in this syntax with the name and order of the children appearing in same sequence as the document.
Example:
|
Cardinality operators
The cardinal operators are: none, ?, +, *. They determine the number of times element appears within content model. They can be applied to single element, group or subgroup of elements as below:
- None: With none of the above operators the element should appear only once. This default operator. (EX:
<!ELEMENT message (developer, manager)>) -
?: This has the value 0 or 1. This makes the element optional. (EX DTD:
<!ELEMENT message (developer, manager?), EX XML: <message><developer>Tony</developer><message>) -
+ - This indicates the element that can appear one or more times. (EX DTD:
<!ELEMENT message (developer, manager)+>, EX XML:<message><developer>Tony</developer><developer>Mark</developer><manager>David</manager><message>) -
* -This indicates the element may not appear or can appear from one to many times. (EX DTD:
<!ELEMENT message (developer*, manager)>, EX XML:<message> <manager>David</manager><message> -
Comments
No comments have been made yet.
Please login to leave a comment. Login now