- XML Schema: An Overview
- Element and Attribute Declarations
- Types
- Namespaces
- Multiple Schema Documents
- Specifying a Schema Location
- Additional Features
Element and Attribute Declarations
XML Schemas contain declarations for each of the elements and attributes that may appear in an instance document. In our example, there are three element declarations and one attribute declaration. The employee element declaration is global, meaning that it is a direct child of the schema element. The other three declarations are local, meaning that they appear within a complex type definition.
The declaration indicates the type of the element or attribute. In XML Schema, an element or attribute is distinct from its type. It is possible to declare two elements with different names, but the same type. For example, two elements named employeeAddress and companyAddress can have the same type, say AddressType. In addition, two elements with the same name can have different types. For example, the status element can contain the values "FT" or PT" when it is a child of employee, or the values "pending", "rejected" or "approved" when it is a child of hiringRequest.