Purpose |
This element defines an attribute. The If the If the |
Parent element | xs:attributeGroup ,
xs:complexType ,
xs:extension or
xs:schema |
Child elements | xs:annotation ,
xs:simpleType |
Attributes | default ,
fixed , form ,
name , ref ,
type , use |
Name | Type | Description |
---|---|---|
default |
xs:string |
This attribute enables you to specify a default value for an attribute definition. The default value is used if the attribute is not explicitly specified in the XML instance. Notes:
|
fixed |
xs:string |
This attribute specifies a fixed value for the attribute. That value cannot be changed later on (i.e. it is a constant value). This has the following consequences for instances of that schema:
Note: |
form |
xs:NMTOKEN |
This attribute specifies whether the appearance of
locally-declared attributes in an instance document must be qualified with a
namespace prefix. It overrides the default that is set using the
|
name |
xs:NCName |
This attribute specifies a name for the attribute to be
defined using the |
ref |
xs:QName |
A global attribute can be referenced in
other declarations in the same schema using the
ref attribute of the xs:attribute
element. The value of the ref attribute must
refer to a global attribute. If you specify a
ref attribute, you cannot specify a
name attribute on that attribute
declaration.
|
type |
xs:QName |
This attribute indicates the type of the attribute to be
defined using the The type can be any of the predefined types described in section 3 "Built-in datatypes" of W3C Recommendation, XML Schema Part 2: Datatypes or any user-defined simple type. |
use |
xs:NMTOKEN |
The
The default value for the Restriction:
If the |
This example shows an attribute definition using restriction. It defines a simple type that can only accept the values:
instrumentalist
jazzSinger
jazzComposer
<xs:attribute name = "type"> <xs:simpleType> <xs:restriction base = "xs:NMTOKEN"> <xs:enumeration value = "instrumentalist"/> <xs:enumeration value = "jazzSinger"/> <xs:enumeration value = "jazzComposer"/> </xs:restriction> </xs:simpleType> </xs:attribute>
The next example presents a more complex attribute definition in TSD .
<xs:attribute name = "C_ob_id" type = "xs:integer"> <xs:annotation> <xs:appinfo> <tsd:attributeInfo> <tsd:physical> <tsd:native> <tsd:objectRef> <tsd:collectionRef>Customers</tsd:collectionRef> <tsd:accessPredicate operator = "="> <tsd:nodeRef>/Customer/CustomerNo</tsd:nodeRef> </tsd:accessPredicate> </tsd:objectRef> </tsd:native> </tsd:physical> </tsd:attributeInfo> </xs:appinfo> </xs:annotation> </xs:attribute>