Quackit Logo

Got a MySpace Page?

Get "www.yourname.com" for your MySpace page. Learn how >>.

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!

FREE Hosting!

With every domain name you register with ZappyHost, you get FREE (ad supported) hosting.

PLUS you get:

  • FREE Website Builder
  • FREE Blog
  • FREE Starter Web Page
  • FREE Email Account
  • & much more! (Total value $123 for FREE!)
Get your FREE hosting today! >>