1. Declaring elements
• XML document has number of elements.
• The first node of XML document is called
the root node.
Syntax: <!ELEMENT element-type category>
Ex: <!ELEMENT name(fname, lname)*>
Control characters
• Item*
• (item1,item2,item3)
• Item
• (item1,item2)
• (item1/item2)
• Item+
• Item?
• Appears zero or more times.
• Separates items in a sequence.
• Appears exactly once.
• Closes a group of items.
• Only one may appear.
• Appears at least once.
• Appears once or not at all.
Ex: <!ELEMENT recipe(name, ingredients+ ,cooking+ serves?, instruction*)>
2. DTD attributes
• Attributes are additional information
associated with an element type.
• ATTLIST is used to identify attributes for
elements.
• Syntax: <!ATTLIST element-name attribute-
name attribute-type default-value>
<element attribute-name=“attribute-value”>
• Ex:
<?xml version=“1.0”>
<!DOCTYPE image[
<!ELEMENT image EMPTY>
<!ATTLIST image height CDATA #REQUIRED>
<!ATTLIST image width CDATA #REQUIRED>
]>
<image height=“32” width=“32”>
3. DTD entities
• It is a symbolic representation of information.
• Mark up elements that contains complex data
are often referred as entities.
• Entities are variables used to define shortcuts
to text and special characters.
• They are internal and external.
1. Internal entity
• Refers to data that an XML processor has to
parse.
• Syntax: <!ENTITY name “entity value”>
Ex:
<?xml version=“1.0”>
<!DOCTYPE letter[
<!ENTITY hbd “happy birth day”>
]>
<letter> &hbd;</letter>
2. External entity
• Used for creating a common reference
that can be shared between multiple
documents.
• There are two types: private and public
• Syntax:
<!ENTITY name SYSTEM “URL/URI”>
<!ENTITY name PUBLIC “publicID” “URI”>

DTD elements

  • 2.
    1. Declaring elements •XML document has number of elements. • The first node of XML document is called the root node. Syntax: <!ELEMENT element-type category> Ex: <!ELEMENT name(fname, lname)*>
  • 3.
    Control characters • Item* •(item1,item2,item3) • Item • (item1,item2) • (item1/item2) • Item+ • Item? • Appears zero or more times. • Separates items in a sequence. • Appears exactly once. • Closes a group of items. • Only one may appear. • Appears at least once. • Appears once or not at all. Ex: <!ELEMENT recipe(name, ingredients+ ,cooking+ serves?, instruction*)>
  • 4.
    2. DTD attributes •Attributes are additional information associated with an element type. • ATTLIST is used to identify attributes for elements. • Syntax: <!ATTLIST element-name attribute- name attribute-type default-value> <element attribute-name=“attribute-value”>
  • 5.
    • Ex: <?xml version=“1.0”> <!DOCTYPEimage[ <!ELEMENT image EMPTY> <!ATTLIST image height CDATA #REQUIRED> <!ATTLIST image width CDATA #REQUIRED> ]> <image height=“32” width=“32”>
  • 6.
    3. DTD entities •It is a symbolic representation of information. • Mark up elements that contains complex data are often referred as entities. • Entities are variables used to define shortcuts to text and special characters. • They are internal and external.
  • 7.
    1. Internal entity •Refers to data that an XML processor has to parse. • Syntax: <!ENTITY name “entity value”> Ex: <?xml version=“1.0”> <!DOCTYPE letter[ <!ENTITY hbd “happy birth day”> ]> <letter> &hbd;</letter>
  • 8.
    2. External entity •Used for creating a common reference that can be shared between multiple documents. • There are two types: private and public • Syntax: <!ENTITY name SYSTEM “URL/URI”> <!ENTITY name PUBLIC “publicID” “URI”>