xs:element
<xs:element abstract = "( true |false
)" block = "( #all | extension | restriction | substitution )" default = "string
" final = "( #all | extension | restriction )" fixed = "string
" form = "( qualified | unqualified )" id = "ID
" maxOccurs = "(nonNegativeInteger
| unbounded )" minOccurs = "nonNegativeInteger
" name = "NCName
" nillable = "( true |false
)" ref = "QName
" substitutionGroup = "QName
" type = "QName
"> <!-- ( xs:annotation?, ((xs:simpleType | xs:complexType)?, (xs:unique | xs:key | xs:keyref)*) ) --> </xs:element>
The xs:element
element
declares an element, including its name and type. Used at the top
level of the schema, it indicates a potential root element. Used
inside an xs:complexType
element, it indicates a potential child element of another
element. Alternately, instead of specifying a name and a type, it
can have a ref
attribute that
points to a top-level element declaration elsewhere in the
schema.
abstract
,
optionalIf the abstract
attribute has the value true
, then only elements from this
element's substitution group are allowed in instance
documents, not elements actually declared by this
declaration.
default
,
optionaldefault
is the
default value of the element reported for empty elements
matching this declaration in the instance document.
block
,
optionalIf the block
attribute contains the value extension
or restriction
, then this element
cannot be replaced in instance documents by instances of
subtypes derived from this element's type by extension or
restriction, respectively. If the block
attribute has the value
substitution
, then this
element cannot be replaced in instance documents by members
of this element's substitution group. If the block
attribute has the value
#all
, then this element
cannot be replaced in instance documents by subtype
instances or substitution group members.
final
,
optionalThe final
attribute
controls which elements can refer to this element as the
head of their substitution group. If the value contains the
keyword restriction
, then
restrictions of this element's type cannot do so. If the
value contains the keyword extension
, then extensions of this
element's type cannot do so. If the value is #all
, then neither extensions nor
restrictions of this type can do so.
fixed
,
optionalIf the fixed
attribute is present, then the only legal value for this
element's content is the value of the fixed
attribute. Only elements
with simple types may be fixed.
form
, optionalIf the form
attribute has the value qualified
, then the element is in
the schema's target namespace. If it has the value unqualified
, then the element is
not in any namespace. The default value is set by the
elementFormDefault
attribute on the root xs:schema
element. This attribute
can only be used on locally declared elements. All globally
declared elements are always in the schema's target
namespace.
id
, optionalid
is an XML name
unique within ID-type attributes in this schema
document.
maxOccurs
,
optionalThis signifies the maximum number of times this element may be repeated in valid instance documents.
minOccurs
,
optionalThis signifies the minimum number of times this element must be repeated in valid instance documents.
name
, optionalThis contains the required name of the element. If
this is omitted, the xs:element
should be empty and
must have a ref
attribute
that points to another element declaration.
nillable
,
optionalIf nillable
has the
value true
, then this
element can be specified as being "nil" using an xsi:nil="true
" attribute in the
instance document.
ref
, optionalThe qualified name of an element declared by a
top-level xs:element
element.
substitutionGroup
,
optionalThis is the qualified name of a globally declared element for which this element may substitute in instance documents.
type
, optionalThis is the qualified name of the type of the element,
either a built-in simple type such as xs:integer
, xs:anyType
, or a user-defined
type.
The xs:element
element
may contain an optional xs:annotation
. If and only if the
xs:element
element does not
have a type
attribute, then it
must have either an xs:simpleType
child element or an
xs:complexType
child element
that provides an anonymous type for this element. Finally, it may
have any number of xs:key
,
xs:keyref
, and xs:unique
elements that set uniqueness
and identity constraints.