With the broad overview out of the way, let's now focus on the different elements (pun definitely intended!) that make up a schema.
The XML Schema specification makes a basic distinction between "simple" and "complex" elements. Simple elements cannot contain other elements or possess additional attributes; complex elements can have additional attributes and serve as containers for other elements (which themselves may be either simple or complex).
Within a schema, these two element types are represented by the <xsd:simpleType> and <xsd:complexType> elements respectively.
Simple elements can be represented in two ways. The first (and simplest) method is to use the <xsd:element> declaration with a built-in datatype - the following simple element
When the datatype name is preceded by the "xsd:" prefix, it indicates a predefined
datatype and not a new, user-defined type. The XML Schema specification lists about forty different built-in datatypes, including "string", "integer", "decimal", "float", "boolean", "time", "date", "dateTime" and "anyURI". However, in case these are too generic for you, it's also possible to derive your own custom datatype from the built-in ones, and then declare simple elements using this custom datatype.
Consider the following schema definition, which is equivalent to the one above:
a new datatype -->
an element of this type -->
<xsd:element name="title" type="simpleDType"/>
Typically, this second method is used only when a schema author needs to restrict
the values of a particular simple element over and above the constraints inherent in a specific datatype. Here's a more constructive definition, which restricts the values of the "rating" element to an integer between 1 and 10.
a new datatype -->
<!-- restrict integer values between 1 and 10 -->
declare an element of this type -->
<xsd:element name="rating" type="simpleDType"/>
I'll be discussing the derivation of new datatypes in more detail a little further
down, so don't worry too much if the syntax seems a little unfamiliar. The important thing to note here is the two different options open to you while defining a simple element.