YouTip LogoYouTip

Schema El Element

* * Complete XML Schema Reference Manual](#) * * * ## Definition and Usage The `element` element defines an element. ### Element Information * **Parent elements:** schema, choice, all, sequence, group ### Syntax annotation?,(simpleType|complexType)?,(unique|key|keyref)* (The ? symbol indicates that the element may appear zero or one time within the `element` element; the * symbol indicates that the element may appear zero or more times.) Optional. Specifies whether an explicit null value can be assigned to this element. This applies to element content, not to attributes of the element. The default value is false. If `nillable` is true, instances of this element may set the `nil` attribute to true. The `nil` attribute is defined as part of the XML Schema namespace for instances. | Attribute | Description | | --- | --- | | id | Optional. Specifies a unique ID for this element. | | name | Optional. Specifies the name of the element. If the parent element is the `schema` element, this attribute is required. | | ref | Optional. A reference to another element. The `ref` attribute may contain a namespace prefix. If the parent element is the `schema` element, this attribute is not used. | | type | Optional. Specifies the name of a built-in data type, or the name of a `simpleType` or `complexType` element. | | substitutionGroup | Optional. Specifies the name of an element that may substitute for this element. That element must have the same type or a type derived from the specified element type. This attribute cannot be used if the parent element is not the `schema` element. | | default | Optional. Specifies a default value for the element (used only when the element content is a simple type or textOnly). | | fixed | Optional. Specifies a fixed value for the element (used only when the element content is a simple type or textOnly). | | form | Optional. The form of this element. The default value is the value of the `elementFormDefault` attribute of the containing `schema` element. The value must be one of the following strings: "qualified" or "unqualified". This attribute cannot be used if the parent element is the `schema` element. * If the value is "unqualified", the element does not need to be qualified with a namespace prefix. * If the value is "qualified", the element must be qualified with a namespace prefix. | | maxOccurs | Optional. Specifies the maximum number of times the `element` element may appear within its parent element. The value may be a non-negative integer. To impose no upper limit, use the string "unbounded". The default value is 1. This attribute cannot be used if the parent element is the `schema` element. | | minOccurs | Optional. Specifies the minimum number of times the `element` element may appear within its parent element. The value may be a non-negative integer. The default value is 1. This attribute cannot be used if the parent element is the `schema` element. | | nillable | | | abstract | Optional. Indicates whether the element may be used in instance documents. If the value is true, the element cannot appear in instance documents. Instead, other elements whose `substitutionGroup` attribute contains the qualified name (QName) of this element must appear in its place. Multiple elements may reference this element in their `substitutionGroup` attributes. The default value is false. | | block | Optional. Derived types. The `block` attribute prevents elements derived with the specified derivation methods from being used to substitute for this element. The value may be `#all` or a list consisting of a subset of `extension`, `restriction`, or `substitution`: * `extension` β€” prevents elements derived by extension from substituting for this element. * `restriction` β€” prevents elements derived by restriction from substituting for this element. * `substitution` β€” prevents elements derived by substitution from substituting for this element. * `#all` β€” prevents all derived elements from substituting for this element. | | final | Optional. Sets the default value of the `final` attribute on the `element` element. This attribute cannot be used if the parent element is not the `schema` element. The value may be `#all` or a list consisting of a subset of `extension` or `restriction`: * `extension` β€” prevents elements derived by extension from substituting for this element. * `restriction` β€” prevents elements derived by restriction from substituting for this element. * `#all` β€” prevents all derived elements from substituting for this element. | | _any attributes_ | Optional. Specifies any additional attributes from a non-schema namespace. | ### Example 1 The following example shows a schema containing four simple elements: "fname", "lname", "age", and "dateborn", typed as string, nonNegativeInteger, and date respectively: ### Example 2 The following example shows a schema containing a complex-type element named "note". The "note" element contains four simple elements: "to", "from", "heading", and "body": ### Example 3 This example is identical to Example 2, but here we choose to use the `ref` attribute to reference element names: * * Complete XML Schema Reference Manual](#)
← El ExtensionEl Documentation β†’