<<< XML Schema differentiates between two types of elements. Simple types can't contain nested elements or have attributes; complex types can. Obviously, the <report> element contains other elements, so we have to define it as a complex type.
<element name="report"> <complexType> <!-- sub-elements go here --> </complexType> </element>
The <datestamp> element is a simple one; it has no attributes and can't have any other elements inside it. However, the information between the beginning and ending tags must be in a specific format; that of a date. In XML Schema, we say:
<element name="datestamp" type="date"/>
The next element in our weather report is the <station> information, shown below.
<station fullname="San Jose" abbrev="KSJC"> <latitude>37.3618619</latitude> <longitude>-121.9290089</longitude> </station>
This has sub-elements and attributes, so it, too, is a complex type, which we might specify as follows:
<element name="station"> <complexType> <element name="latitude" type="decimal"/> <element name="longitude" type="decimal"/> <attribute name="fullname" type="string"/> <attribute name="abbrev" type="string"/> </complexType> </element>
Again, this is fairly easy to read. The <station> element is made up of the <latitude> and <longitude> elements, which must contain decimal numbers between their beginning and ending tags. The <station> element also has a fullname and abbrev attribute, both of which are strings.
The only difference so far between this and a DTD is that we can specify what kind of content an element must have (date, string, decimal, etc.) Let's use the power of XML Schema to be much more specific on what content elements and attributes may have. >>>