ID and IDREF Attributes

ID and IDREF attributes together provide a simple inside-the-document linking mechanism, with every IDREF attribute required to point at an ID attribute. ID attributes, though, are important, whether or not you have any IDREFs, because they give elements unique addresses. They have a very important use in the future as the targets of hyperlinks coming into the document from outside.

In general, it's a good idea to attach ID attributes to as many elements as possible in every document, because, later, if you decide you need to point at anything, you'll be happy if it has an ID attribute ready for use.

However, there's a real problem here. In principle, you can't know whether an attribute is of type ID unless you're a validating processor and thus required to read the DTD, where the type is declared. On the other hand, we know that there are many non-validating applications which could make very good use of IDs.

Thus there is a real requirement that XML figure out a way to identify ID attributes without relying on the DTD. One of the simplest ways to do this would simply be to assert that attributes named id are of type ID unless declared otherwise. Quite a few applications (including the one that generated this annotated spec) are already doing this, de facto.

Back-link to spec

Copyright © 1998, Tim Bray. All rights reserved.