ID, IDREF could someone please explain them :)

Posted on 2005-03-05
Medium Priority
Last Modified: 2010-07-27
Hi im trying to learn XML im very much a beginner :

Im trying to understand the concept and usage of IDREFs in XML. I belive there is also ID, IDREF and IDREFS. Im not sure if they can be used to uniquely identify something, but i would like to use this, if i could understand how it works ( i am also using a DTD ).

Would it please be possible for someone to explain what ID, IDREF and IDREFS is and if possible with examples explain why they would be used or how they could be used in XML.

Much appreciated.

Many thanks

Question by:gisvpn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 15

Expert Comment

ID: 13493678
ID - is used to provide some unique identifier for element.
IDREF - is used to reference some ID.  Generally it means that you can define IDREF with the same value as some existent ID.

This is just to ensure data integrity and consistency, to ensure you have a reference to existent element only.

Author Comment

ID: 13499445
Hey Dualsoul thats great thanks for the post :)

Is there anyway in which you can give me a basic example ?
LVL 15

Accepted Solution

dualsoul earned 2000 total points
ID: 13505128
yes, why not, in general let's consider following example:

  <man id="1" />
  <man id="3" />
   <bid personId="1" /> <!-- Valid -->
   <bid personId="2" /> <!-- Invalid, there are on man with ID=2 -->

, so if you declare man/@id as ID, and bid/@personId as IDREF to man/@id, you can control consistency, @personId can have only value from existent @id. It's like a foreign key in RDBMS.

Featured Post


We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question