Examples of Simple Type and Complex Type Parameters

Previous Next


Suppose the XML of a Person complex type looks like the following:






The corresponding XML schema definition looks like the following:

<xsd:complexType name="PersonType">


       <xsd:element name="FirstName" type="xsd:string"/>

       <xsd:element name="FamilyName" type="xsd:string"/>




In this case, the Person XML element is of the Persons complexType.

You can define your own simpleType element, but a simpleType cannot contain multiple elements or attributes. The simpleType element is usually defined to represent a restriction on the data type.


Here is the definition for an Age simpleType with valid values between 1 and 120:

<xsd:simpleType name="Age">

   <xsd:restriction base="xsd:integer">

       <xsd:minInclusive value="1"/>

       <xsd:maxInclusive value="120"/>