xs:attribute(reference or local definition) — Reference to a global attribute definition or local definition (local definitions cannot be referenced).
<xs:attribute default = xs:string fixed = xs:string form = ( “qualified” | “unqualified” ) id = xs:ID name = xs:NCName ref = xs:QName type = xs:QName use = ( “prohibited” | “optional” | “required” ) : “optional” {any attributes with non-schema namespace} > Content: ((xs:annotation?), (xs:simpleType?)) </xs:attribute>
May be included in: xs:attributeGroup (global definition), xs:complexType (local definition), xs:complexType (global definition), xs:extension (complex content), xs:extension (simple content), xs:restriction (complex content), xs:restriction (simple content)
This element serves two different purposes and has two different content models for these two purposes: it can either be a reference to a globally defined attribute or it can be a local attribute definition. These options are mutually exclusive.
When used as a reference to an attribute, the ref
attribute must contain the qualified name of the attribute (with its
namespace prefix).
When used as a local definition, the definition is done by assigning
a simple datatype to the attribute. This assignment can be done
either by reference, using the type
attribute to
refer to a simple datatype by its qualified name, or inline, by
embedding the definition of the simple type
(xs:simpleType
element) within the
xs:attribute
element.
<xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute ref="lang"/> </xs:extension> </xs:simpleContent> </xs:complexType> .../... <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="lang" type="xs:language"/> </xs:extension> </xs:simpleContent>
default
Default value. When specified, an attribute is added by the schema
processor, if missing from the instance document, and is given this
value. The default
and fixed
attributes are mutually exclusive.
fixed
When specified, the value of the attribute is fixed and must be equal
to the value specified here. The default
and
fixed
attributes are mutually exclusive.
form
Specifies if the attribute is qualified (i.e., must have a namespace
prefix in the instance document) or not. The default value for this
attribute is specified by the attributeFormDefault
attribute of the xs:schema
document
element—local definition only.
id
W3C XML Schema’s element ID.
name
Local name (without namespace prefix)—local definition only.
ref
Qualified name of a globally defined attribute—reference only.
type
Qualified name of a simple datatype—definition only.
use
Possible usage of the attribute. Marking an attribute “prohibited” is useful to exclude attributes during derivations by restriction.