Schema Definition

Unlike a DTD document, an XML schema document cannot be declared within an XML document. An XML schema document is defined in a separate document that has a .xsd extension.

Every XML schema document contains a schema element as the root element. The schema element may contain attributes such as the namespace declaration. For example, in the code snippet on the right, the schema element is defined as:

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

Note the following:

  • xs:schema indicates the schema element with the xs prefix. Note that a prefix can take any value, which is typically unique within an XML schema document.
  • xmlns:xs="http://www.w3.org/2001/XMLSchema" indicates an attribute that defines the XML schema namespace.

The element and attribute declarations follow the schema definition.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

// Additional declarations
Click the Next button to continue.