A simple type is an abstract definition of
an item of data such as a number, a string, or a date.
The purpose of a simple type is to define the content of one or
more simple elements. Simple types (and any elements that are based
on simple types) cannot contain attributes or child elements. Simple
types stand in contrast to complex types, which define the structure
of an element, but typically do not define any simple data.
Global and local simple types
Simple types
can be global or local. A global simple type can be used as the basis
for more than one element. It must be given a unique name by which
it can be referenced. A local simple type is associated with a single
element, and is not available for reuse elsewhere in the message model.
Local types do not have a name and are sometimes referred to as anonymous
types.
Variations of simple types
- Built-in
XML Schema defines many simple types for you to use, covering
all the standard data types such as strings, integers, decimals, and
floats.
- Restriction
You can define your own simple types by deriving from another
simple type (the base type) by restriction. A restriction type can
have value constraints applied to it.
A restriction type can
derive from a built-in simple type or a restriction simple type.
- List
For XML messages only, a list type is a way of rendering a
repeating simple value in XML. The notation is more compact than the
notation for a repeating element, and offers a way to have multi-valued
attributes.
A list type can be based on a union type (introduced
later in this section). This can describe a space-separated list of
items in which each item can be based on any of the simple types in
the union.
A list of lists is not legal. The item type of a
list cannot be a list itself, or derived at any level from another
list type.
A list type can have the facets of minLength, maxLength,
and length applied to it. These facets restrict the number of items
in the list. To restrict the values of each item in the list, facets
must be applied to the item type and not to the list itself. The message
definition editor provides additional support for enumeration and
pattern facets directly on a List type, to enable the import of any
schema that uses them, but issues a warning that enumeration and
pattern facets are ignored by the integration node.
- Union
A union type is a union of two or more other simple types.
A
union type enables a value to conform to any one of several different
simple types. The simple types that comprise a union type are known
as its member types. There is no upper limit on how many member types
can exist, but there must be at least one. A member type can be defined
as a built-in simple type, a user defined simple type, or a local
simple type defined anonymously within the union type.
A union
type can also include list, union, and restricted simple types, among
its members.
Value constraints
Value constraints are
known as facets by XML Schema. Any value constraints that are applied
to a derived type must further restrict the base type. It is not valid
for a derived type to weaken or remove a value constraint that its
base type has defined. If no value constraints are applied to the
derived type, the derived type is almost identical to its base type,
but it is treated as a restriction of the base type in situations
where that is relevant (type inheritance and element substitution).