25. DTD for a Unique Attribute

The ID attribute type can be used to two define that no two elements have the same value within a document. Elements can only be given one attribute of this type. The value assigned to the attribute of this type is required to be a proper XML name. The ID attribute can be used by applications in order to identify elements.

Example 25.1 An ID Attribute Type
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE rootelement [
<!ELEMENT rootelement (childelement1)>
<!ELEMENT childelement (#PCDATA*)>
<!ATTLIST childelement
	sampleattributeid ID #REQUIRED>
]>
<rootelement>
	<childelement sampleattributeid="1">
		Child element.
	</childelement>
	<childelement sampleattributeid="2">
		Child element.
	</childelement>
</rootelement>