26. DTD for an Attribute Referencing a Single Element by ID

The IDREF attribute type is used to specify something about a document's structure. In particular, something about the relationship that exists between elements. The IDREF attribute type holds the value of an ID attribute of some other element within a document. Typically the IDREF usually defines another element to which the current element is related.

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