Stylus Studio XML Editor

Table of contents

Appendices

5.3 XML Schema Constraints vs. XML 1.0 ID Attributes

XML Schema Constraints vs. XML 1.0 ID Attributes

[XML 1.0] provides a mechanism for ensuring uniqueness using the ID attribute and its associated attributes IDREF and IDREFS. This mechanism is also provided in XML Schema through the ID, IDREF, and IDREFS simple types which can be used for declaring XML 1.0-style attributes. XML Schema also introduces new mechanisms that are more flexible and powerful. For example, XML Schema's mechanisms can be applied to any element and attribute content, regardless of its type. In contrast, ID is a type of attribute and so it cannot be applied to attributes, elements or their content. Furthermore, Schema enables you to specify the scope within which uniqueness applies whereas the scope of an ID is fixed to be the whole document. Finally, Schema enables you to create keys or a keyref from combinations of element and attribute content whereas ID has no such facility.