xs:element(reference or local definition) — Reference to a global element declaration or local definition (local definitions cannot be referenced).
<xs:element block = ( “#all” | list of ( “extension” | “restriction” | “substitution” ) ) default = xs:string fixed = xs:string form = ( “qualified” | “unqualified” ) id = xs:ID maxOccurs = ( xs:nonNegativeInteger | “unbounded” ) : “1” minOccurs = xs:nonNegativeInteger : “1” name = xs:NCName nillable = xs:boolean : “false” ref = xs:QName type = xs:QName {any attributes with non-schema namespace} > Content: (xs:annotation?, (xs:simpleType | xs:complexType)?, (xs:unique | xs:key | xs:keyref)*) </xs:element>
May be included in: xs:choice (outside a group), xs:choice (within a group), xs:sequence (within a group), xs:sequence (outside a group)
This element serves two different purposes and has two different content models for these purposes: it can either be a reference to a globally defined element or to a local element definition. These options are mutually exclusive.
When used as a reference to an element, the ref
attribute must contain the qualified name of the element (with its
namespace prefix).
When used as a local definition, the definition is done by assigning
a simple or complex datatype to the element. This assignment can be
done either by reference, using the type
attribute
to refer to a simple or complex datatype by its qualified name, or
inline, by embedding the definition of the simple
(xs:simpleType
) element or complex
(xs:complexType
) element within the
xs:element
element.
In all cases, the number of occurrences can be constrained using the
minOccurs
and maxOccurs
attributes, whose default value is 1. The
maxOccurs
attribute can take the value unbounded,
to define that an element may appear as many times as the author of
the document wishes.
The default and fixed values are defined in attributes and, therefore, can only apply to simple type elements.
The fact that W3C XML Schema cannot describe the exclusive combinations of the attributes and elements of xs:element which could be summarized as:
ref attribute xor name attribute, type attribute xor xs:simpleType element, xor xs:complexType element
is an example that shows some of the restrictions of the language.
<xs:sequence> <xs:element name="book" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element ref="isbn"/> <xs:element ref="title"/> <xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="character" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute ref="id"/> <xs:attribute ref="available"/> </xs:complexType> </xs:element> </xs:sequence>
block
Controls whether the element can be subject to a type or substitution
group substitution. #all
blocks any substitution,
substitution
blocks any substitution through
substitution groups, and extension
and
restriction
block any substitution (both through
xsi:type
and substitution groups) by elements or
types, derived respectively by extension or restriction from the type
of the element. Its default value is defined by the
blockDefault
attribute of the parent
xs:schema
.
default
Default value of the element. Defined in an attribute, element
default values must be simple contents. Also note that default values
apply only to elements that are present in the document and empty.
The fixed
and default
attributes are mutually exclusive.
fixed
A simple content element may be fixed to a specific value using this
attribute. This value is also used as a default value, and if the
element is empty, it is supplied to the application. The
fixed
and default
attributes
are mutually exclusive.
form
Defines if the element is “qualified” (i.e., belongs to the target namespace) or “unqualified” (i.e., doesn’t belong to any namespace)—to be used only for local element definitions.
id
W3C XML Schema’s element ID.
maxOccurs
Maximum number of occurrences (“unbounded” means “unlimited”).
minOccurs
Minimum number of occurrences.
name
Local name (without namespace prefix)—to be use only for local element definitions.
nillable
When this attribute is set to true
, the element
can be declared as nil using an xsi:nil
attribute
in the instance documents.
ref
Reference to a global element—to be used only for references.
type
Reference to a simple or complex type—to be used only for local element definitions.
18.118.137.243