|
DTD Syntax
Part:
1
2
3
(Continued from previous part...)
2. Parsed Text Content: Only parsed text is allowed in the content.
Parsed text is a string of regular characters and XML entities. No child element is
allowed in the content.
<!ELEMENT element_name (#PCDATA)>
3. Element Sequence Content: Only one or more named elements are allowed in
the content. The named elements must be appear in the same sequence of they are specified
in the declaration statement. No text is allowed in the content. Element sequence
content is declared by a sequence of child element names, expressional symbols
and grouping parentheses. Examples of element sequence content are:
<!ELEMENT element_name (e) >
<!ELEMENT element_name (e?) >
<!ELEMENT element_name (e+) >
<!ELEMENT element_name (e*) >
<!ELEMENT element_name (e,f) >
<!ELEMENT element_name (e,f)? >
<!ELEMENT element_name (e,f)+ >
<!ELEMENT element_name (e|f)* >
<!ELEMENT element_name (e,(f|g)) >
where;
- "?" indicates that the element or group can appear once or not at all.
- "+" indicates that the element or group can appear once or many times.
- "*" indicates that the element or group can appear once, many times, or not at all.
- "," indicates that the elements or groups separated by it should appear in
that squence.
- "|" indicates that one of the elements or groups separated by it should appear.
4. Mixed Content: Parsed text and named elements are allowed in the
content. Mixed content must be declared in the following syntax:
<!ELEMENT element_name (#PCDATA | e | f | ...)* >
5. Any Content: Parsed text and any elements are allowed in the content.
Any content is declared by key word, ANY:
<!ELEMENT element_name ANY>
Note that:
- White space characters: space character, tab key, line feed, are catrige return,
are not considered as text. So, for example, they can be used in elements declared
as empty content elements.
ATTLIST Declaration Statement
ATTLIST: A DTD statement that defines one or more attributes of an XML element.
The ATTLIST statement specifies what are the names of the attributes, what are the
data types of the values, whether the attributes are required, and what are the
default values.
The syntax of ATTLIST statement is:
<!ATTLIST element_name
attribute_name value_type default_value
......
>
"value_type" specifies what types of values are allowed for this attribute.
The most commonly used values types are:
1. Character Data: The attribute value can be a string of any regular characters.
<!ATTLIST element_name
attribute_name CDATA default_value
......
>
2. List of String Values: The attribute value can be any string value in the list.
List of string values is declared by:
<!ATTLIST element_name
attribute_name (value_1 | value_2 | ...) default_value
......
>
Note that string values are entered without quotes.
"default_value" specifies whether this attribute is required or not, what is the
default value. There are 4 ways to specify a default value:
(Continued on next part...)
Part:
1
2
3
|