xsdxs:complexType


Introduction

A xs:complexType provides a description of an XML element's content in the instance document. The definition of the xs:complexType can be made globally in which case it has a name and can be re-used within the schema, or it can be inplace and only used within the context it is declared.

Parameters

AttributesDescription
abstractWhen set to true the complex type can not be used directly in an instance XML document via xsi:type. It can however be used as the base type for an element definition. (default false) - Only valid for root level xs:complexType's
blockLimits the types that can be used in an XML instance document (defaults to the value of the xs:schemas blockDefault attribute if set, otherwise defaults to empty, values '#all' | a list of ('extension', 'list', 'union') separated by whitespace).
finalLimits deriving types from using this type in certain ways within the schema (defaults to the value of the xs:schemas finalDefault attribute if set, otherwise defaults to empty, values '#all' | or a list of ('extension', 'list', 'union') separated by whitespace) - Only valid for root level xs:complexType's
idThe id of the schema item (optional)
mixedIndicates the instance XML element may contain mixed content (defaults to false)
nameThe name of the xs:complexType - Only valid for root level xs:complexType's
anyAny other attributes not in the 'http://www.w3.org/2001/XMLSchema' namespace are allowed.
-----------------------
ElementsDescription
-----------------------
xs:annotationProvides the ability to add documentation and machine readable data.
xs:simpleContentUsed when the xs:complexType derives from a xs:simpleType.
xs:complexContentUsed when the xs:complexType derives from another xs:complexType.
xs:groupAdds the elements from an xs:group to the xs:complexType definition
xs:allAdds the elements from an xs:all to the xs:complexType definition
xs:choiceAdds the elements from an xs:choice to the xs:complexType definition
xs:sequenceAdds the elements from an xs:sequence to the xs:complexType definition
xs:attributeAdds the xs:attribute to the xs:complexType definition
xs:attributeGroupAdds the xs:attributeGroup to the xs:complexType definition
xs:anyAttributeAdds the xs:anyAttribute to the xs:complexType definition

Remarks

Deriving from a xs:complexType

When a xs:complexType derives from another xs:complexType is can do it via extension or restriction.

  • extension - the deriving type takes everything defined in the base type and adds to it.
  • restriction - the deriving type takes only selected parts from the base type, only allowing the parts it wants, no additional items can be added.

Deriving from a xs:simpleType

When a xs:complexType derives from a xs:simpleType is can do it via extension, in which case it can add attributes to the resulting type, but not elements.

Content Type

Conceptually a xs:complexType either contains simple or complex content. If the xs:complexType derives from a typed based on xs:anySimpleType (xs:int, xs:string etc) then it is simple. If it derives from a xs:complexType which contains complex content, then it itself is complex (if the xs:complexType does not derive from a type, then it is also complex).