Declares an element.
<element abstract = Boolean : false block = (#all | List of (extension | restriction | substitution)) default = string final = (#all | List of (extension | restriction)) fixed = string form = (qualified | unqualified) id = ID maxOccurs = (nonNegativeInteger | unbounded) : 1 minOccurs = nonNegativeInteger : 1 name = NCName nillable = Boolean : false ref = QName substitutionGroup = QName type = QName {any attributes with non-schema Namespace}…> Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) </element>
The default is false.
Optional.
extension | Prevents elements derived by extension from being used in place of this element. |
restriction | Prevents elements derived by restriction from being used in place of this element. |
substitution | Prevents elements derived by substitution from being used in place of this element. |
#all | Prevents all derived elements from being used in place of this element. |
Optional.
The fixed and default attributes are mutually exclusive.
If the element contains a simple type, this value must be a valid value of that type.
Optional.
This attribute can be used on any element if the referring element is declared at the global level (parent is schema element).
This value must be a QName.
Optional.
extension | Prevents elements derived by extension from being used in place of this element. |
restriction | Prevents elements derived by restriction from being used in place of this element. |
#all | Prevents all derived elements from being used in place of this element. |
Prohibited if the containing element is not the schema element.
Optional.
The fixed and default attributes are mutually exclusive.
Optional.
If the value is unqualified, this element is not required to be qualified with the namespace prefix.
If the value is qualified, this element must be qualified with the namespace prefix.
Optional.
Optional.
Prohibited if the containing element is the schema element.
Optional.
Prohibited if the containing element is the schema element.
Optional.
Required if the containing element is the schema element.
Optional.
If nillable is true, this enables an instance of the element to have the nil attribute set to true. The nil attribute is defined as part of the XML Schema namespace for instances.
For example, the following fragment defines a single element with nillable set to true.
<xs:element name="myDate" type="xs:date" nillable="true"/>
The following fragment uses that element and has an explicit nil value (nil attribute set to true).
<myDate xsi:nil="true"></myDate>
Optional.
Prohibited if the containing element is the schema element.
If the ref attribute is present, complexType, simpleType, key, keyref, and unique elements and nillable, default, fixed, form, block, and type attributes cannot be present.
<xs:element ref="comment"/>
Optional.
The type and ref attributes are mutually exclusive.
To declare an element using an existing simple type or complex type definition, use the type attribute to specify the existing type.
<xs:element name="name" type="xs:string"/>
Optional.
Number of occurrences | Number of elements defined in the schema. |
Parent elements | schema, choice, all, sequence |
Contents | simpleType, complexType, key, keyref, unique |
An element declaration associates a name with a type definition, which can be a built-in data type, a simple type, or a complex type.
Element declarations can be present as child elements of the schema element (having global scope) or within complex type definitions. Within complex types, element declarations can be present as local declarations or references to elements with global scope.
Global element declarations must directly define complex types.
A simpleType or complexType element can be present as a child only if both the ref and type attributes are not present.
In addition, elements can appear by reference within choice, all, sequence, and complexType elements.
The following example contains two elements that can serve as substitutes for another element.
<xs:element name="cat" type="xs:string"/> <xs:element name="dog" type="xs:string"/> <xs:element name="redDog" type="xs:string" substitutionGroup="dog" /> <xs:element name="brownDog" type="xs:string" substitutionGroup ="dog" /> <xs:element name="pets"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="cat"/> <xs:element ref="dog"/> </xs:choice> </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-element.
W3C Namespaces in XML Recommendation | XML Schema Namespace for Instances