xs:attribute
<xs:attribute default = "string
" fixed = "string
" form = "( qualified | unqualified ) id = "ID
" name = "NCName
" ref = "QName
" type = "QName
" use = "(optional
| prohibited | required )"> <!-- ( xs:annotation?, xs:simpleType? ) --> </xs:attribute>
The xs:attribute
element
declares an attribute. Inside an xs:complexType
element it indicates that
elements of that type can have an attribute with the specified
name and type.
default
,
optionalThe default value of the attribute reported for those elements in the instance document that do not contain an explicit specification of this attribute.
fixed
,
optionalA default value for this attribute that may not be
overridden in the instance document. An xs:attribute
element cannot have
both fixed
and default
attributes.
form
, optionalIf this has the value qualified
, then the attribute must
be in the schema's target namespace. If this has the value
unqualified
, then the
attribute must not be in any namespace. The default value
for this is set by the attributeFormDefault
attribute on
the root xs:schema
element.
id
, optionalAn XML name unique among all of the ID-type attributes in this schema document.
name
, optionalThe local name of the attribute.
ref
, optionalThe qualified name of an attribute declared by a
top-level xs:attribute
element elsewhere in the schema. Either the name
or ref
attribute should be provided,
but not both.
type
, optionalThe qualified name of the type of the attribute,
either a built-in simple type such as xs:integer
or a user-defined
simple type.
use
, optionalOne of the three keywords—optional
, prohibited
, or required
—which have the following
meanings:
optional
Authors of instance documents may or may not include this attribute as they choose. This is the default.
prohibited
Authors of instance documents must not include this attribute. This is typically used to remove legal attribute values when defining a subtype that would otherwise inherit an attribute declaration from its base type.
required
Authors of instance documents must include this attribute on all elements of the requisite type.
The xs:attribute
element
may contain a single xs:annotation
element to describe
itself. This has no effect on the attribute type.
In place of a type
attribute, the xs:attribute
element may contain a single xs:simpleType
element that provides an
anonymous type for the attribute derived from a base simple
type.