Non-atomic Types


 

Non-atomic Types

Values of atomic data types cannot be sub divided further. It can be either primitive or derived like strings, integers, decimals, dates etc.

Values of atomic data types cannot be sub divided further. It can be either primitive or derived like strings, integers, decimals, dates etc.

Non-atomic Types

Values of atomic data types cannot be sub divided further. It can be either primitive or derived like strings, integers, decimals, dates etc. XML Schema provides two non atomic types lists and unions. Non atomic data types are comprised of atomic types.

1. List Data Types

List types consist of sequence of atomic data types separated by whitespace.

Creating a List of integer:
<xs:simpleType name="integerList">
         <xs:list itemType="xs:integer"/>
</xs:simpleType>

The above element can be used as below:
<integerList>10 20 30 40</integerList>


2. Union Data Types

Unions can be used to specify a simple type that can contain values of a number of other simple types. It is defined using a simpleType element.
<simpleType name="myUnion">
        <union memberTypes="xs:int xs:string" />
</simpleType>

Attribute memberTypes contains a list of one or more defined simple type names. The above example defines a type whose value is either the integer 1 or the string "One".

<myUnion>1 One</myUnion>

You can also define an anonymous simple type as a member type of a union. See the example below:

<simpleType name="myUnion">
           <union memberTypes="xs:string">
                 <simpleType>
                        <restriction base="xs:int">
                             <minInclusive value="4" />
                             <maxInclusive value="8" />
                        </restriction>
                 </simpleType>
           </union>
</simpleType>

Ads