9.4. Concepts and Observations Regarding Attribute Types

Attribute types have fewer options than element types, simple types, or complex types. Because of the simplicity of attribute types, this section covers only three concepts: when to use an attribute type versus an element type, global and local attribute types, and how attribute types interact with namespaces in the corresponding XML instances.

9.4.1. When to Use an Attribute Type

In many XML schemas, the use of an attribute type versus an element type is an arbitrary choice. In the following example, the customer’s ID is an attribute type:

 <xsd:element name="customer"> <xsd:complexType> <xsd:attribute name="customerID" type="xsd:string" use="required"/> </xsd:complexType> </xsd:element> ...

Get XML Schema Complete Reference, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.