Defines a complex type, which determines the set of attributes and the content of an element.
<complexType
abstract = Boolean : false
block = (#all | List of (extension | restriction))
final = (#all | List of (extension | restriction))
id = ID
mixed = Boolean : false
name = NCName
{any attributes with non-schema Namespace…}>
Content: (annotation?, (simpleContent | complexContent | ((group | all |
choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))
</complexType>
true, an element cannot use this complex type directly but must use a complex type derived from this complex type. The default is false.
Optional.
block attribute prevents a complex type that has the specified type of derivation from being used in place of this complex type. This value can contain #all or a list that is a subset of extension or restriction. The block attribute is only used when, during validation, an instance document overrides the normal type for an element by using the schema-instance:type attribute. The block attribute is capable of stopping elements from selecting complex types that are defined through extension and/or restriction to replace the original type that is specified for the element.
extension |
Prevents complex types derived by extension from being used in place of this complex type. |
restriction |
Prevents complex types derived by restriction from being used in place of this complex type. |
#all |
Prevents all derived complex types from being used in place of this complex type. |
Optional.
final attribute prevents the specified type of derivation of this <complexType> element. This value can contain #all or a list that is a subset of extension or restriction.
extension |
Prevents derivation by extension. |
restriction |
Prevents derivation by restriction. |
#all |
Prevents all derivation (both extension and restriction). |
Optional.
id value must be of type ID and be unique within the document containing this element.
Optional.
false.
If <simpleContent> element is a child element, the mixed attribute is not allowed.
If <complexContent> element is a child element, this mixed attribute can be overridden by the mixed attribute on the <complexContent> element.
Optional.
Required if the containing element is the <schema> element; otherwise, prohibited.
If specified, the name must be unique among all <simpleType> and <complexType> elements.
Optional.
| Number of occurrences | Unlimited within schema; one time within element. |
| Parent elements | element, redefine, schema |
| Content | annotation, simpleContent, complexContent, group, all, choice, sequence, attribute, attributeGroup, anyAttribute |
A complex type is essentially a type definition for elements that may contain attributes and elements. An element can be declared with a type attribute that refers to a <complexType> element that defines the structure, content, and attributes of that element. (An element can also take a reference to a <simpleType> in its type attribute.)
A complex type can contain one and only one of the following elements, which determines the type of content allowed in the complex type.
| Element | Description |
|---|---|
<simpleContent> |
The complex type has character data or a <simpleType> as content and contains no elements, but may contain attributes. |
<complexContent> |
The complex type contains only elements or no element content (empty). |
<group> |
The complex type contains the elements defined in the referenced group. |
<sequence> |
The complex type contains the elements defined in the specified sequence. |
<choice> |
The complex type allows one of the elements specified in the choice element. |
<all> |
The complex type allows any or all of the elements specified in the all element to appear once. |
If <group>, <sequence>, <choice>, or <all> is specified as the child element, the attributes for the <complexType> can be declared optionally using the following elements.
| Element | Description |
|---|---|
<attribute> |
The complex type contains the specified attribute. |
<attributeGroup> |
The complex type contains the attributes defined in the referenced <attributeGroup>. |
<anyAttribute> |
The complex type can contain any attribute from the specified namespace(s). |
Any number of <attribute> or <attributeGroup> elements can be used. One instance of <anyAttribute> can also be used.
If <group>, <sequence>, <choice>, or <all> is specified, the elements must appear in the following order.
<group> | <sequence> | <choice> | <all><attribute> | <attributeGroup><anyAttribute>The following example shows a complex type that contains a simple type (decimal) with an attribute and element declaration that uses a complex type.
<xs:complexType name='internationalShoeSize'> <xs:simpleContent> <xs:extension base='xs:decimal'> <xs:attribute name='sizing' type='xs:string' /> </xs:extension> </xs:simpleContent> </xs:complexType> <xs:element name='myShoeSize' type='internationalShoeSize'/>
The following example shows an instance of the <myShoeSize> element within an XML document.
<myShoeSize sizing='UK'>10.5</myShoeSize>
The following example shows the <myShoeSize> element with the <complexType> defined anonymously within the element. (Note the absence of the name attribute.)
<xs:element name='myShoeSize'>
<xs:complexType>
<xs:simpleContent>
<xs:extension base='xs:decimal'>
<xs:attribute name='sizing' type='xs:string' />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
XML Schema Reference (XSD) | XML Schema Elements
For more information, see the W3C XML Schema Part 1: Structures Recommendation at http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-complexType.

W3C Namespaces in XML Recommendation
| This HTML Help has been published using the chm2web software. |