XML and XHTML Content Versus Appearance
XML and XHTML Content Versus Appearance
DATA CONSTRAINTS DTD's have minimal data constraints. Schemas allow more specific constraints
You can also use the values of "0" (false) or "1" (true); either convention is fine.
time A time in hours, minutes, seconds, and milliseconds formatted as hh:mm:ss.sss (e.g.,
1:20 PM is 13:20:00)
You may include the optional Coordinated Universal Time (UTC) designator (e.g.,
1:20 PM Eastern Standard Time (EST) is 13:20:00-05:00) [e]
date A Gregorian date in centuries, years, months, and days (e.g., December 31, 2004 is
2004-12-31)[e]
dateTime A Gregorian date measured in centuries, years, months, and days, with a time field
set off by a T (e.g., 1:20 PM EST on December 31, 2004 would be 2004-12-
31T13:20:00-05:00)[e]
duration A span of time measured in years, months, days, and seconds (e.g., 1 year, 2 months,
3 days, 10 hours, and 30 minutes would be P1Y2M3DT10H30M)
Duration may be negative, and zero values can be left off (e.g., 120 days earlier is
P120D). The value must always start with the letter P. [f]
Complex Types
complex types define how elements that contain other elements are
organized.
<complexType name="USAddress">
<sequence>
<element name="name" type="string" />
<element name="street" type="string" />
<element name="city" type="string" />
<element name="state" type="string" />
<element name="zip" type="string" />
</sequence>
</complexType>
Complex Types
Sequences of Elements :complexType declarations in
schemas will contain a sequence element that lists
one or more element definitions. The element
definitions tell you which elements are nested in the
type, the order in which they appear, and the kind of
data each element contains.
Mapping a Schema Complex Type to an XML Element
<complexType name="USAddress">
<sequence> <address>
<element name="name" type="string" /> <name>Amazon.com</name>
<street>1516 2nd Ave</street>
<element name="street" type="string" />
<city>Seattle</city>
<element name="city" type="string" /> <state>WA</state>
<element name="state" type="string" /> <zip>90952</zip>
<element name="zip" type="string" /> </address>
</sequence>
</complexType>