Quackit Logo

FREE Hosting!

With every domain name you register with ZappyHost, you get FREE hosting.

$1.99 Domain Names

With every new non-domain purchase thru ZappyHost, you get a domain name for only $1.99.

DTD Attribute Types - IDREF

Print Version

The attribute type of IDREF is used for referring to an ID value of another element in the document.

Syntax:

<!ATTLIST element_name
attribute_name IDREF default_value>

Example:

<!ATTLIST employee
employee_id ID #REQUIRED
manager_id IDREF #IMPLIED>

Valid XML - The following XML document would be valid, as it conforms to the above DTD:

<employees>
  <employee employee_id="e10001" manager_id="e10002">
    <first_name>Homer</first_name>
    <last_name>Flinstone</last_name>
  </employee>
  <employee employee_id="e10002">
    <first_name>Fred</first_name>
    <last_name>Burns</last_name>
  </employee>
</employees>

Invalid XML - The following XML document would be invalid. This is because the "manager_id" attribute of the second element contains a value that isn't the same as a value of another element that contains an attribute with a type of ID:

<employees>
  <employee employee_id="e10001" manager_id="e10002>
    <first_name>Homer</first_name>
    <last_name>Flinstone</last_name>
  </employee>
  <employee employee_id="e10002" manager_id="e10003>
    <first_name>Fred</first_name>
    <last_name>Burns</last_name>
  </employee>
</employees>

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
               
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!