The attribute Element
Attributes were declared in the simplified DTD in "A DTD for Schemas" as follows:
<!ELEMENT attribute ((annotation)?, (simpleType)?)>
<!ATTLIST attribute type CDATA #IMPLIED
default CDATA #IMPLIED
fixed CDATA #IMPLIED
name CDATA #REQUIRED
minOccurs (0|1) '0'
maxOccurs (0|1) '1' >
|
In schemas, attributes are the association of a name with a particular simple data type. The attribute element is not included in the schema element, and therefore can only be used as a child element of the complexType or attributeGroup element. This means that all attribute elements will have local scope.
You can use the attribute element within a complexType element that has either local or document scope. As we'll see in the next section, you can group attribute elements together in an attributeGroup element. The name attribute must follow the same naming conventions as attribute names for DTDs.
You can use either a default attribute or a fixed attribute with attribute elements, but not both for the same attribute element. Unlike in DTDs, the fixed and default values are not linked to an attribute as optional or required-you can choose to make any attribute have a fixed value or a default value. A fixed value cannot be changed. The value of the default attribute will be the default value if one is not supplied for the attribute. The following declarations show the usage of default and fixed attributes:
<attribute name = "myAttribute" minOccurs = "1" fixed = "preserve"
type = string"/>
<attribute name = "align" minOccurs = "0" default = "Center"
type = "string"/>
|