What are the constraints on attributes while tagging data?

XML Schema provides two constructs for tagging data in XML instances – elements and attributes. Which construct to employ is not always clear. While data can often be stored as attributes or elements, there are a number of constraints on attributes that generally impact one's decision:


·        XML does not support specification of structure in attribute values; attribute values are just strings. Elements may contain additional structure as sub-elements or attributes.

·       Attributes are not easily extended (for future changes). However, you can add additional sub-elements and attributes to an element through type subclassing and type substitution.

·       Mixed content (mixing simple values and elements together) is hard to work with, and harder to specify. This means that properties of a simple data type must be included as attributes (in order to avoid having to use mixed content).

For this reason, GJXDM and NIEM take the approach of tagging most data in elements. Attributes are reserved generally for metadata.