Referencing composites using ID and IDREF
XML allows for two mechanisms that can be employed to express a relationship between two entities: embedding and referencing. The difference is shown on the right. DDEX uses both mechanisms. Referencing is used typically when a composite may need to be used multiple times. For example, because Sound Recordings are (i) usually referenced from at least two Releases in a NewReleaseMessage and, the DDEX standard uses the referencing mechanism for linking SoundRecording
s to Release
s. In ERN-3 parties such as writers and recording artists are not referenced; instead their information is embedded.
Using ID and IDREF
The referencing mechanism employed by DDEX – and many other XML schemas – is often called "ID/IDREF pairs". In that case, the composite that is to be referenced needs to contain an element with a datatype of xs:ID
. In DDEX messages this element is named XXXReference
with XXX
denoting the type of the composite. So, the relevant element for all Resources (SoundRecording
s, Video
s, Image
s, etc.) is called ResourceReference
and the relevant element for a Release composite is called ReleaseReference
.
These references are strings and the first letter of these strings denotes the type of composite they belong to:
References to a Release start with the letter R;
References to a Resources start with the letter A (because the letter R is already used);
References to a Deal start with the letter D;
References to a Cue start with the letter C;
etc.
Referring to one of these references is achieved by elements of datatype xs:IDREF. The name of these referring elements is YYYZZZReference
with YYY being the type of element that is referencing and ZZZ being the type of element that is being referenced. Therefore, the element to reference from a Release to a Resource such as a SoundRecording is called ReleaseResourceReference
. The example below shows a Release
pointing to two SoundRecording
s: Line 17 points to the second SoundRecording
(it's reference is provided in line 9) and the line 18 points to the first SoundRecording (it's reference is provided in line 4):
<ResourceList> <SoundRecording> <!-- ... --> <ResourceReference>A1</ResourceReference> <!-- ... --> </SoundRecording> <SoundRecording> <!-- ... --> <ResourceReference>A2</ResourceReference> <!-- ... --> </SoundRecording> </ResourceList> <ReleaseList> <Release> <!-- ... --> <ReleaseResourceReference>A2</ReleaseResourceReference> <ReleaseResourceReference>A1</ReleaseResourceReference> <!-- ... --> </Release> </ReleaseList>
Best practices for selecting ID/IDREF values
ID/IDREF values in DDEX have to be:
ASCII strings;
Start with the specific letter as indicated above; and
May not contain certain characters (
:
,@
,$
,%
,&
,/
,+
,,
,;
, whitespace characters or different parenthesis).
The scope of the ID/IDREF pair is the message in which they are used. Therefore a ResourceReference
used in a message is only valid in that message. When the same SoundRecording
is communicated in a different message, it's ResourceReference
will, in all likelihood, change.
It might therefore be best to start each message with reference number 1 and simply increase the number for each subsequent reference element.
It is specifically recommended to not use any of the metadata elements for the References:
Don't do this
<SoundRecording> <SoundRecordingId> <ISRC>USRC17607839</ISRC> <SoundRecordingId> <Title> <TitleText>Crazy Eyes</TitleText> </Title> <ResourceReference>A_CrazyEyes</ResourceReference> </SoundRecording>
Don't do this either
<SoundRecording> <SoundRecordingId> <ISRC>USRC17607839</ISRC> <SoundRecordingId> <Title> <TitleText>Crazy Eyes</TitleText> </Title> <ResourceReference>A_USRC17607839</ResourceReference> </SoundRecording>
Do this instead
<SoundRecording> <SoundRecordingId> <ISRC>USRC17607839</ISRC> <SoundRecordingId> <Title> <TitleText>Crazy Eyes</TitleText> </Title> <ResourceReference>A1</ResourceReference> </SoundRecording>
Note: these samples are not valid DDEX XML as they only focus on how to use ID/IDREF links