Click to return to the XML (Extensible Markup Language) home page    
Attribute Element     datatype Element     XML Schema Preview    
Web Workshop  |  XML (Extensible Markup Language)

AttributeType Element


Defines an attribute type for use within the Schema element.

Syntax

<AttributeType
    default="default-value" 
    dt:type="primitive-type" 
    dt:values="enumerated-values" 
    name="idref" 
    required="{yes | no}" >

Attributes

default
Default value for the attribute. The default value must be legal for that attribute instance. For example, when the attribute is an enumerated type, the default value must appear in the values list.
dt:type
Specifies the data type for this attribute type. In the implementation provided with Internet Explorer 5, an attribute can take one of the following types: entity, entities, enumeration, id, idref, idrefs, nmtoken, nmtokens, notation, or string. When the type "enumeration" is selected, the dt:values attribute should also be supplied, listing the allowed values. For more information about data types, see XML Data Types.
dt:values
When dt:type is set to "enumeration," this attribute lists the possible values.
name
Name of the attribute type. This attribute is required. References to this attribute type within an ElementType definition are made in the schema with the attribute element. The name supplied here corresponds to the "type" attribute of the "attribute" element.
required
Indicator of whether the attribute must be present on the element.

Element Information

Number of occurrences Unlimited
Parent elements ElementType, Schema
Child elements datatype, description
Requires closing tag Yes. XML Schema is an XML grammar and, like all XML grammars, all tags must have closing tags to satisfy the definition of well-formed.

Remarks

An AttributeType declaration contained within an ElementType element defines that attribute type within the scope of the ElementType that contains it.

In XML Schema, as in XML 1.0, the order of appearance of attributes in an element is not constrained, and a given attribute can appear no more than once in an element.

Example

The following example shows an enumeration and its document type definition (DTD) equivalent.

<AttributeType name="colors" dt:type="enumeration"
   dt:values="red green blue">
<!ATTLIST x colors (red | green | blue)>

The following example declares an attribute type called "myattr." This declaration constrains "myattr" attributes to contain only a name token.

<AttributeType name="myattr" dt:type="nmtoken"/>


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.