xsd Global ComplexType with Sequence and attributes


This example shows a simple global definition of a complexType. The definition is considered global as it is a child of the xs:schema. Globally defined types can be used elsewhere in the schema.

This is the most common form for declaring a global xs:complexType, it defines the child elements using a xs:sequence, xs:choice or xs:all, and optionally has attributes as well.

Note : because it is a globally defined it must have a unique name within the schema set.

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid Studio 2017 (https://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" 
    <xs:complexType name="PersonType">
            <xs:element name="Forename" type="xs:string" />
            <xs:element name="Surname" type="xs:string" />
        <xs:attribute name="Gender">
                <xs:restriction base="xs:string">
                    <xs:enumeration value="male" />
                    <xs:enumeration value="female" />

ComplexType with Sequence and attributes