Complex Types (XSM)

A complex type is an element that contains other elements or attributes, and which is used to define a data type to be reused and derived by extension or restriction.You can only create complex types in a model targeted with XSD.

Complex types are generally created directly under the <schema> tag, to be reused or derived (by extension or restriction) in other parts of the schema. Such global complex types are listed in the Browser, and can have symbols in the diagram. Complex types can also be created within an element, by selecting Complex in the Embedded Type field of the element property sheet (see Element Properties). Such local complex types can only be seen as part of the schema in the Preview tab of the element property sheet.

In this example, the global Address complex type is selected as the type of the User Address element:

The generated schema is as follows:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema 
    elementFormDefault="qualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="Address">
      <xs:sequence>
         <xs:element name="Street_Number"/>
         <xs:element name="Town"/>
         <xs:element name="Zip"/>
         <xs:element name="Country"/>
      </xs:sequence>
    </xs:complexType>
    <xs:element name="User">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="First_Name"/>
            <xs:element name="Family_Name"/>
            <xs:element name="User_Address" type="Address"/>
         </xs:sequence>
      </xs:complexType>
    </xs:element>
</xs:schema>