In This Topic
Graphical Representation
Summary
The <complexType> allows you to build up re-usable or extendable objects. The Complex Type may contain compositors (<all>, <choice>, <sequence>) as well as <attribute>'s and <attributeGroup>'s.
ComplexTypes can only be defined at global level (as a child of the <schema>). They can then be used as the type for other <element>'s.
Creating
A <complexType> can only be added to the <schema> object. This can be done using the right click context menu Add Child->Complex Type.
Properties
Name - The name the complex type will be referred to as. This must be unique, and it's a good standard to postfix it with 'Type').
Type - (optional) It's possible to create a new complex type based on an existing simple or complex type. If you specify an existing type then there are 2 ways that the 'base' type can be interpreted determined by the 'Derived By' property.
Derived By - Only available when the base type is specified. If this is Extension , then the complexType takes all the properties of the 'Type' (elements/attributes etc), and allows a new compositor (<all>, <choice>, <sequence>) and <attribute>'s to be added to it. If the value is Restriction, then the complexType can ONLY contain the elements and attributes defined in the 'Type'. You can not add in elements and attributes that are not defined in the base type.
Abstract - If this is true then it means that the complexType can not be used on its own, it must be extended or restricted before it can be used (See 'Derived By' and 'Type' properties).
Block - Indicates that the type can not be substituted, extended or restricted - see 'Derived By' Property and Substitution Groups on <element>.
Final - .
Id - A user defined ID to uniquely identify the entity within the schema.
Mixed - Indicates if the XML element described by this complexType may contain text interspersed between its child elements (like HTML). It is recommended that is is false, as it makes processing the resulting XML documents more difficult, but it is sometimes necessary to use this.
Sample
The following XSD code
Example Title |
Copy Code
|
<xs:complexType name="AddressType">
<xs:sequence>
<xs:element name="Recipient" type="xs:string" />
<xs:element name="StreetAddress" type="xs:string" />
<xs:element name="Town" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="USAddressType">
<xs:complexContent>
<xs:extension base="AddressType">
<xs:sequence>
<xs:element name="State" type="USStateType" />
<xs:element name="ZipCode" type="ZipCodeType" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="InternalOfficeAddress">
<xs:complexContent>
<xs:restriction base="AddressType">
<xs:sequence>
<xs:element name="Recipient" type="xs:string" />
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="PostcodeType">
<xs:restriction base="xs:string">
<xs:pattern value="(GIR 0AA)|((([A-Z-[QVX]][0-9][0-9]?)|(([A-Z-[QVX]][A-Z-[IJZ]][0-9][0-9]?)|(([A-Z-[QVX]][0-9][A-HJKSTUW])|([A-Z-[QVX]][A-Z-[IJZ]][0-9][ABEHMNPRVWXY])))) [0-9][A-Z-[CIKMOV]]{2})" />
</xs:restriction>
</xs:simpleType>
|
Shows the definition of a complex Type.
The complex type UKAddressType Extends the complexType AddressType, note the icon .
The complex type UKAddressType Restricts the complexType AddressType, note the icon .
Inline Properties
Properties that apply to a type are shown inline at the bottom of the items container.
Values that are inherited from the base types are shown in brackets, values specifically set against the item are shown without brackets.
If a facet is not valid for a given type (typically because of its data type), then its value is shown in red.
Inline properties can be disabled in the
Options.