Learning Objectives

You will be able... distinguish between internal and external DOCTYPE decalarations. identify the reference to an XML Schema in an XML document when looking at a given XML document. list the main differences between XML DTD and XML Schema.


Until now, you learned how to create an XML document and how to "invent" XML tags. But we still did not tell you anything about how to define the structure and the elements that can or have to be used in a specific XML document. We make an example:
Imagine that you want to store the addresses of all your friends in an XML document and every address must have the same child elements such as first name, last name, street, number and city as it is shown in the following example:
Example XML DocumentExample XML Document

Don't you agree that somewhere, we have to define that the element <address> must have the child elements <first_name>, <last_name>, <street>, <number> and <city>, do you?

The specification of which elements are allowed in your document and what structure do they have is part of the DOCTYPE declaration (DTD) and the XML Schema.

If there exist a DTD or an XML Schema for the example above, you are not anymore able to store an address in the wrong way as it is shown in the next picture:
Wrong tag nestingWrong tag nesting

The example shows you that DTD and XML Schema play an important role in the subject of XML. Therefore, we introduce the properties and the usage of DTD and XML Schema in this unit.

This unit is based on the DTD Tutorial and the XML Schema Tutorial of the W3C. If you are interested in more details about DTD and XML Schema have a look at those tutorials.

In addition to just introduce XML DTD and XML Schema, we will present you the main differences between these two schema types.