In This Topic
Graphical Representation
Summary
The <xs:simpleType> element allows you to define new types. These new types can then be used though out your schema.
There are 3 main forms for a simple type, these are determined by the 'Simple Type Content' property. Restriction allows an existing type to be further restricted. List allows an number of valid values to be contained within the type. Union allows a number of different types to be valid for the value.
Creating
A <xs:simpleType> can be created by selecting the <xs:schema> object and using the right click context menu, Add Child -> Simple Type.
Properties
(When 'Simple Type Content' is Restriction, None or List)
Name - The name of the attribute (this is used within the XML document i.e. <Order OrderID="87">).
Simple Content Type - Effects the value of the type. Restriction, the type selected is being restricted. The restrictions come in the form of facets. Union, the value can take any valid value from the list of types defined in the Union Types property. List, the value can be a number of valid values for the Type selected. These values are white space separated in the XML document.
Type - The simple type that is being used as the base for this element (only available when the Simple Content Type, is NOT set to union).
Facets - The facets available depend on the 'Type' attribute see Facets for more information.
Final -
Id - A user defined ID to uniquely identify the entity within the schema
(When 'Simple Type Content' is Union)
Union Type - The list of types that are valid as values for the element (only available when the Simple Content Type, is set to union).
Sample Restriction
The following XSD code
<xsd:simpleType name="LowerCaseLetterType">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[a-z]" />
</xsd:restriction>
</xsd:simpleType>
...
<xsd:element name="MiddleInitial" type="LowerCaseLetterType" />
Will be represented like this
Sample XML would look like this
<?xml version="1.0" encoding="utf-16"?>
<MiddleInitial>j</MiddleInitial>
Sample List
The following XSD code
<xs:simpleType name="SuitableDatesType">
<xs:list itemType="xs:date" />
</xs:simpleType>
...
<xs:element name="SuitableDates" type="SuitableDatesType" />
Will be represented like this
Sample XML would look like this (space separated list)
<?xml version="1.0" encoding="utf-16"?>
<SuitableDates>2000-01-12 2000-01-15 2000-01-18</SuitableDates>
Sample Union
The following XSD code
<xs:simpleType name="DateOrNumberType" >
<xs:union memberTypes="xs:date xs:int" />
</xs:simpleType>
...
<xs:element name="BookingLengthOrCheckoutDate" type="DateOrNumberType" />
Will be represented like this
Sample XML would look like this, where the contents are either a valid int or a valid date.
<?xml version="1.0" encoding="utf-16"?>
<BookingLengthOrCheckoutDate>3</BookingLengthOrCheckoutDate>
or
<?xml version="1.0" encoding="utf-16"?>
<BookingLengthOrCheckoutDate>2000-01-12</BookingLengthOrCheckoutDate>
Inline Properties
Properties that apply to a type are shown inline at the bottom of the items container.
Values that are inherited from the base types are shown in brackets, values specifically set against the item are shown without brackets.
If a facet is not valid for a given type (typically because of its data type), then its value is shown in red.
Inline properties can be disabled in the
Options.