XML Schema element 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
id=ID name=NCName ref=QName type=QName substitutionGroup=QName default=string fixed=string form=qualified|unqualified maxOccurs=nonNegativeInteger|unbounded minOccurs=nonNegativeInteger nillable=true|false abstract=true|false block=(#all|list of (extension|restriction)) final=(#all|list of (extension|restriction)) any attributes annotation?,(simpleType|complexType)?,(unique|key|keyref)* (The ? symbol declares that the element can occur zero or one time in the element element, and the * symbol declares that the element can occur zero or more times.) Optional. Indicates whether an explicit zero value can be assigned to the element. This applies to the element content and is not an attribute of the element. The default value is false. If nillable is true, it enables instances of the element to set the nil attribute to true. The nil attribute is defined as part of the XML Schema namespace of the instance. Optional. The form of the element. The default value is the value of the elementFormDefault attribute of the schema element that contains this attribute. 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. Optional. Specifies the maximum number of times the element can occur in the parent element. The value can be an integer greater than or equal to zero. If you do not want to set any limit on the maximum number, use the string "unbounded". The default value is 1. This attribute cannot be used if the parent element is the schema element. Optional. Specifies the minimum number of times the element can occur in the parent element. The value can be an integer greater than or equal to zero. The default value is 1. This attribute cannot be used if the parent element is the schema element. Optional. Indicates whether the element can be used in an instance document. If the value is true, the element cannot appear in the instance document. Instead, other elements whose substitutionGroup attribute contains the qualified name (QName) of this element must appear in its place. Multiple elements can reference this element in their substitutionGroup attribute. The default value is false. Optional. The derived type. The block attribute prevents elements with the specified derived type from being used to substitute for this element. The value can contain #all or a list that is a subset of extension, restriction, or substitution: 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 can contain #all or a list that is a subset of extension or restriction: Optional. Specifies any other attributes with a non-schema namespace. The following example is a schema with four simple elements: "fname", "lname", "age", and "dateborn", with types string, nonNegativeInteger, and date: The following example is a schema with a complex type "note" element. The "note" element contains four simple elements: "to", "from", "heading", and "body": This example is the same as Example 2, but in this case, we choose to use the ref attribute to reference the element names:
property
Description
id
Optional. Specifies a unique ID for the element.
name
Optional. Specifies the name of the element. This attribute is required if the parent element is the schema element.
ref
Optional. A reference to another element. The ref attribute can contain a namespace prefix. This attribute is not used if the parent element is the schema element.
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 can be used to substitute for this element. The element must have the same type as, 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
| | final |
| | *any attributes* |
Example 1
Example 2
Example 3
Complete XML Schema Reference Manual