XML Schema Simple Data Type Element:
Printer Friendly Page
An element is a Simple Type if it only contains text.
<xs:element name = "LastName" />
<xs:element name = "CustNumber" />
<xs:element name = "TransDate" />
<xs:element name = "CreditHold" />
To specify a data type, use the attribute "Type"
<xs:element name = "LastName" type="xs:string" />
<xs:element name = "CustNumber" type="xs:integer" />
<xs:element name = "TransDate" type="xs:date" />
<xs:element name = "CreditHold" type="xs:boolean" />
Note that the namespace xs: is used with a built-in data type.
XML usage:
<LastName>George Washington</LastName>
<CustNumber>232021</CustNumber>
<TransDate>2004-02-25</TransDate>
<CreditHold>false</CreditHold>
Common XSD Data Types:
xs:string
xs:integer
xs:decimal
xs:boolean
true OR 1.
xs:date
CCYY-MM-DD
xs:time
HH:MM:DD
XSD Simple Data Type Sample : Int:
<xsd:simpleType name="CustomerID">
<xsd:restriction base="xsd:Int">
<xsd:minInclusive value="10000"/>
<xsd:maxInclusive value="99999"/>
</xsd:restriction>
</xsd:simpleType>
XSD Restrictions : Constraining Facets
enumeration
Restricts the data type to a list of values.
length
Number of characters
minlength
Minimum number of characters
maxlength
Maximum number of characters
minExclusive
Restricts to greater than this value
maxExclusive
Restricts to less than this value
minInclusive
Restricts to greater than or equal to
maxInclusive
Restricts to less than or equal to
pattern
Regular expression
totalDigits
Maximum number of digits
whiteSpace
Set as "preserve", "collapse", "replace"
XSD Simple Data Type Sample : Date:
<xsd:simpleType name="FiscalYear2004">
<xsd:restriction base="xsd:date">
<xsd:minInclusive value="2004-01-01"/>
<xsd:maxInclusive value="2004-12-31"/>
</xsd:restriction>
</xsd:simpleType>
XSD Simple Data Type Sample : String:
<xsd:simpleType name="cName">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
XSD Simple Data Type Sample : Based on Other Data Type:
<xsd:simpleType name="LastName">
<xsd:restriction base="xsd:cName">
<xsd:maxLength value="25"/>
</xsd:restriction>
</xsd:simpleType>
XSD Complex Data Type:
An element is COMPLEX if it contains other elements.
<xs:element name="memo">
<xs:complexType>
<xs:sequence>
<xs:element name="date" type="xs:date"/>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>