xsd xs:complexType Global ComplexType with Sequence and attributes

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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" 
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="PersonType">
        <xs:sequence>
            <xs:element name="Forename" type="xs:string" />
            <xs:element name="Surname" type="xs:string" />
        </xs:sequence>
        <xs:attribute name="Gender">
            <xs:simpleType>
                <xs:restriction base="xs:string">
                    <xs:enumeration value="male" />
                    <xs:enumeration value="female" />
                </xs:restriction>
            </xs:simpleType>
        </xs:attribute>
    </xs:complexType>
</xs:schema>

ComplexType with Sequence and attributes



Got any xsd Question?