Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

571 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