Examples of Simple Type and Complex Type Parameters |
Example: Suppose the XML of a Person complex type looks like the following: <Person> <FirstName>...</FirstName> <FamilyName>...</FamilyName> </Person>
The corresponding XML schema definition looks like the following: <xsd:complexType name="PersonType"> <xsd:sequence> <xsd:element name="FirstName" type="xsd:string"/> <xsd:element name="FamilyName" type="xsd:string"/> </xsd:sequence> </xsd:complexType>
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. Example: 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"/> </xsd:restriction> </xsd:simpleType> |