Exforsys

Home arrow Technical Training arrow XML Tutorials

XML - Elements in Document Type Definitions (DTD) Page - 3

Page 3 of 3
Author : Exforsys Inc.     Published on: 14th Jun 2006

XML - Elements in Document Type Definitions (DTD)

.

.

.

Ads

The sequence operator (,) is used to provide sequence of child elements.
The following declaration requires first_name followed by middle_name followed by last_name

< ! ELEMENT name (fist_name, middle_name, last_name ) >

< name >
< first_name >Nick< /first_name >
< middle_name >John< /middle_name >
< last_name >Price< /last_name >
< /name >

is valid while

< name >
< last_name >Price< /last_name >
< first_name >Nick< /first_name >
< middle_name >John< /middle_name >
< /name >

or

< name >
< middle_name >John< /middle_name >
< first_name >Nick< /first_name >
< last_name >Price< /last_name >
< /name >


or any other such combinations are invalid.

The Optional operator (?) is used to declare zero or once appearance of the element

Thus for the declaration

< !ELEMENT EVENT (LOCATION,SPONSOR?) >

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< /EVENT >

OR

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< SPONSOR >Flying Toys< /SPONSOR >
< /EVENT >


are valid.

while

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< SPONSOR >Flying Toys< /SPONSOR >
< SPONSOR >Plastic Toys< /SPONSOR >
< /EVENT >

is invalid.

The plus sign (+) is used to indicate one or more instances of the element.

Thus for the declaration

< !ELEMENT EVENTLIST (EVENT+) >

< EVENTLIST >
< EVENT >Balsa Wood Flyer Days< /EVENT >
< EVENT >Sundays in the Park< /EVENT >
< EVENT >Teach Your Child to Fly< /EVENT >
< /EVENTLIST >

or

< EVENTLIST >
< EVENT >Balsa Wood Flyer Days< /EVENT >
< /EVENTLIST >

are valid

while

< EVENTLIST >
< /EVENTLIST >

is not valid.

Ads

The asterisk (*) signifies zero or more appearances of the elements.

Thus for the declaration

< !ELEMENT EVENT (LOCATION*, EVENT-NAME) >

< EVENT >
< LOCATION >West Bay Ballpark< /LOCATION >
< LOCATION >North Side Park< /LOCATION >
< EVENT-NAME >Sundays in the Park< /EVENT-NAME >
< /EVENT >


OR

< EVENT >
< EVENT-NAME >Sundays in the Park< /EVENT-NAME >
< /EVENT >

are valid.

Read Next: XML Advantages


 
This tutorial is part of a XML Tutorials tutorial series. Read it from the beginning and learn yourself.

XML Tutorials

 

Comments