i don't think there is any reference between the InDesign document or the idml exported from it.
IDML is in fact a format that is used recreate the InDesign document. It is in fact a archive that has all the resources of the document.
As far as I understand in an IDML file is kind of like a tabled representation of an InDesign file. An INDD file on the other hand is a collection of objects that are specifically designed to be processed by the InDesign engine.
So while IDML can be rendered by the InDesign engine and an INDD file can also be rendered by the InDesign engine the files themselves are very different structurally.
The beauty of an IDML file is that for GUI interfacing users everything "looks" the same on the InDesign GUI side of things, for the more technical users the IDML file can be directly interfaced various technologies (XML based databases and processors, CMS/DAM systems).
However having said when I just did I'm not a particularly technical person so you have to eat everything I just said with a giant boulder of salt.
Sure there is a relation, it's even very easy to set up a test for this.
Of course, Adobe could have chosen to 'make up' the Self IDs as they are written out into text form in the IDML -- but then they'd have to keep tabs on what number is used for what object. But why should they? The internal ID already is a unique identifier for every single object. For a document, it's the same inside the UI, in its binary INDD file (if you know where to look), and also in an IDML exported from same.
Top left: a short script. Center left: a random InDesign document, with some text frame selected. Bottom left: the output of aforementioned script. Right, in the back: the Spread.XML file in an exported IDML of this very same document (the spread file is named "Spread_udb.xml", and I'm convinced another test script would show me that's the actual ID number of this spread). As you can see, the <TextFrame> "Self" ID is "ue5" and its "ParentStory" is "ud3". I'm guessing the 'u' here is an abbreviation for 'unsigned int'; the next characters are the ID numbers in hexadecimal.
But why would it matter to you? Any operation you perform may reshuffle the IDs around, and if you are somehow counting on the ID in a previously saved IDML file staying the same in your "live" document, you might get the occasional surprise. The same goes for saving an object's ID inside a script and relying on that staying the same, all through your ID session. It's way more safe to assign a label to the objects you are going to manipulate.
@Jongware – correct me, if I'm wrong, but for geometrical objects like text frames, graphic frames and lines I never saw it happen that an ID was changed in regards of a document. It's faster (more directly) to fetch such an object by document.pageItem.itemByID(*Integer*) than getting its label you inserted with the insertLabel(*String*) method.
However if you export to IDML and reopen the IDML in InDesign the IDs for the page items are not the same anymore, they are reordered. In such a case it would be best to use the insertLabel(*String*) method.
Another thing: keep in mind that a label will stick to an object and its copied or duplicated version. The ID, of course, will change. The ID is unique document wide. So in case you duplicate an object and you want to work with that object in a unique way, you have to update its label or get its ID and add it to a variable or store it in an array for further use.
This isn't an answer to the question, but a further question. I'm just finishing my free trial of CS6, and my documents are saved with a .indd extension. When I save them as CS5, which is what I have installed, they save as .idml. But when I open them in CS5, they open as untitled and I have to save again. Is everything going to be okay once the trial of CS6 disappears? Will I still have access to my documents? I sure hope so, I have quite a lot of hours of work in them. Thanks.
You will have all the access to the documents you are creating from IDML even when the trial of InDesign expires, they still reamin valid documents. However in order to use them you surely need a working copy of InDesign.
Hope this clears out your doubts.