Lecture 02 - XML DTD
Lecture 02 - XML DTD
1
Objectives
2
–Declaring an Element
–Declaring Attributes
Explain the use of DTD
Document Type Definition (DTD)
3
Syntax
Example
<img src="tittle.gif"/>
Elements with Data
9
Syntax
<!ELEMENT element-name (#PCDATA)>
or
<!ELEMENT element-name ANY>
Where:
#PCDATA = element contains character data that is to be parsed
ANY = element with any content
Elements with Child Elements
10
Elements with one or more children are defined with the name of the
child element inside the parentheses.
• Syntax
• Syntax
Value Explanation
CDATA The value is character data
(eval|eval|..) The value must be an enumerated value
ID The value is an unique id
IDREF The value is the id of another element
IDREFS The value is a list of other ids
NMTOKEN The value is a valid XML name
NMTOKENS The value is a list of valid XML names
ENTITY The value is an entity
ENTITIES The value is a list of entities
NOTATION The value is a name of a notation
xml: The value is predefined
Attribute Default Value
17
Value Explanation
#DEFAULT The attribute has a default value.
The attribute value must be included in the
#REQUIRED
element.
#IMPLIED The attribute does not have to be included.
#FIXED The attribute value is fixed.
Attribute Default Value
18
Syntax Example
Default value <!ATTLIST Model type CDATA
"Camera">
#IMPLIED <!ATTLIST element-name <!ATTLIST Model type CDATA
attribute-name attribute-type "Camera" #IMPLIED>
#IMPLIED>
#REQUIRED <!ATTLIST element-name <!ATTLIST Model type CDATA
attribute-name attribute-type "Camera" #REQUIRED>
#REQUIRED>
#FIXED <!ATTLIST element-name <!ATTLIST Model type CDATA
attribute-name attribute-type #FIXED "Camera" >
#FIXED “value”>
Enumerated <!ATTLIST element-name <!ATTLIST Model type
attribute-name (en1|en2|...) (Camera|Phone) "Camera">
default-value>
Internal DTD
19
21