XML Schema complexType-Element
Definition und Verwendung
complexType-Element definiert einen komplexen Typ. Ein komplexer Typ ist ein XML-Element, das andere Elemente und/oder Attribute enthält.
Elementinformation
Anzahl der Auftretens | Im Schema uneingeschränkt; im Element einmalig. |
Übergeordneter Element | element, redefine, schema |
Inhalt | annotation, simpleContent, complexContent, group, all, choice, sequence, attribute, attributeGroup, anyAttribute |
Syntax
<complexType id=ID name=NCName abstract=true|false mixed=true|false block=(#all|list of (extension|restriction)) final=(#all|list of (extension|restriction)) jegliche Attribute > (annotation?,(simpleContent|complexContent|((group|all| choice|sequence)?,((attribute|attributeGroup)*,anyAttribute?)))) </complexType>
(? Symbol declaration in the complexType element, the element can appear zero or one time, * Symbol declaration of the element can appear zero or more times.)
Attributes
id
Optional. Specifies the unique ID of the element.
name
Optional. Specifies the name of the element.
abstract
Optional. Specifies whether complex types can be used in the instance document. If this value is true, the element cannot use the complex type directly but must use a complex type derived from it. The default value is false.
mixed
Optional. Specifies whether character data is allowed to appear between the child elements of this complex type. The default value is false.
- If the simpleContent element is a child element, the mixed attribute is not allowed.
- If the complexContent element is a child element, the mixed attribute can be overridden by the mixed attribute of the complexContent element.
block
Optional. Prevents complex types with the specified derivation type from being used to replace the complex type. This value can contain #all or a list, which is a subset of extension or restriction:
- extension - Prevents derived complex types by extension from being used to replace the complex type.
- restriction - Prevents derived complex types by restriction from being used to replace the complex type.
- #all - Prevents all derived complex types from being used to replace the complex type.
final
Optional. Prevents the specified type derived from the complexType element from being used. This value can contain #all or a list, which is a subset of extension or restriction.
- extension - Verhindert Ableitungen durch Erweiterung.
- restriction - Verhindert Ableitungen durch Beschränkung.
- #all - Verhindert alle Ableitungen (Erweiterungen und Beschränkungen).
jegliche Attribute
Optional. Definiert alle anderen Attribute mit einer non-schema Namensraum.
Beispiel
Beispiel 1
In dem folgenden Beispiel verfügt ein komplexer Typ namens "note" über eine komplexe Typ-Element:
<xs:element name="note"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
Beispiel 2
In dem folgenden Beispiel gibt es einen komplexen Typ "fullpersoninfo", der durch die Verwendung von drei zusätzlichen Elementen (address, city und country) den abgeleiteten Typ erweitert, der von einem anderen komplexen Typ "personinfo" abgeleitet ist:
<xs:element name="employee" type="fullpersoninfo"/> <xs:complexType name="personinfo"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> </xs:complexType> <xs:complexType name="fullpersoninfo"> <xs:complexContent> <xs:extension base="personinfo"> <xs:sequence> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType>
In the above example, the "employee" element must contain the following elements in order: "firstname", "lastname", "address", "city", and "country".