How to Use XSD?
XML documents can reference a DTD or an XML Schema.
A Simple XML Document:
Take a look at this XML document named "note.xml":
DTD File
The following example is a DTD file named "note.dtd", which defines the elements of the aforementioned XML document ("note.xml"):
Line 1 defines that the note element has four child elements: "to, from, heading, body".
Lines 2-5 define that the types of the to, from, heading, body elements are "#PCDATA".
XML Schema
The following example is an XML Schema file named "note.xsd", which defines the elements of the aforementioned XML document ("note.xml"):
The note element is a complex type because it contains other child elements. The other elements (to, from, heading, body) are simple types because they do not contain other elements. You will learn more about complex and simple types in the following sections.
Referencing a DTD
This file contains a reference to a DTD:
Referencing an XML Schema
This file contains a reference to an XML Schema: