HTML and CSS Reference
In-Depth Information
Table 12-5 XML Simple Type and Complex Type Elements
Type
Description and XML Element
XML Schema
Simple
an XML element that contains only text
<irst_name>Bill</irst_name>
<xs:element name="irst_name" type="string" />
Complex
an XML element that contains child elements or attributes
<products>
<item>
<item-id>A345</item-id>
</item>
</products>
<xs:element name="products">
<xs:complexType>
<xs:sequence>
<xs:element name="item" type="childType"
minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
The definition of elements in the schema must include the data type. XML Schema
Definition has several built-in data types shown in Table 12-6. From this list of simple
data types, a developer can build custom data types. Custom data types begin with a base
data type and include restrictions in the form of domain (range of valid values), length, or
number of characters or digits (patterns).
Table 12-6 XML Schema Definition Data Types
Data Types
Description
String
data is any set of characters
Integer
data is any whole number not a fraction
Decimal
data is any number that contains a decimal fraction
Date
represent the date as YYYY-MM-DD
Boolean
binary logic of true or false, yes or no, on or off
Binary
a set of binary codes in groups of eight
AnyURI
a valid URI Internet address
Custom data types are quite common in database systems. These data types help
in validating data fields, to reduce erroneous data entry. Table 12-7 shows an example
custom data type. The example shows a custom data type field called age_range, which
has a domain between 18 and 70. A domain is a set of valid values for a database field.
Table 12-7 XML Custom Data Types
Custom Data Type Example
<xs:simpleType name="age_range">
<xs:restriction base=xs:integer">
<xs:minInclusive value="18" />
<xs:maxInclusive value="70" />
</xs:restriction>
</xs:simpleType>
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="employment_age" type="age_range" />
</xs:sequence>
</xs:complexType>
</xs:element name="employee">
Search WWH ::




Custom Search