Tipworld -> XML
IDRefs

So, what can you do with an ID attribute? Well, for starters, you can reference it using another type of attribute called IDREF. When you use an IDREF attribute, it must contain a value previously defined in an ID attribute. Here is an example:

<?xml version="1.0"?>

<!DOCTYPE Company [
<!ELEMENT Test (employee*)>
<!ELEMENT employee (#PCDATA)>
<!ATTLIST employee empid ID #REQUIRED>
<!ATTLIST employee boss IDREF #IMPLIED>
]>

<Company>
<employee empid="e44">john</employee>
<employee empid="e84">john</employee>
<employee empid="e94" boss="e89">john</employee>
</Company>

Here, the boss attribute is defined as an IDREF, so it must contain a value from an empid tag. Also, notice that the sample uses "e89" in the boss attribute, which is not defined in any empid attributes. Therefore, my document is not valid!