ID/IDREF

The XML standard relies upon the two special attribute types, 'ID' and 'IDREF', to identify attributes that serve as the target and source of a link. Using this technique, the target object must be enclosed by an element that has an attribute defined to be of type ID. A unique value must be placed in this attribute:

<!ELEMENT section (...) >
<!ATTLIST section target
					ID #REQUIRED>
   <section target="S6">
     <title>This is Section 6</title>
     ...
     ...
     ...
   </section>

Every reference must be contained within an element that has an attribute defined to be of type IDREF. For example, a referencing element called 'XRef' may use an attribute called 'Link' to point to the required element:

<!ELEMENT xref (...) >
<!ATTLIST xref link IDREF #REQUIRED>


   <para>Please refer to
   <xref link="S6">Section 6</xref>
   for more details</para>

An XML parser uses the ID and IDREF attribute type designators to identify and validate these values. Every ID value must be unique, to avoid ambiguity, and every IDREF value must match the value of an attribute of type ID in order to avoid 'hanging' pointers:



The following fragment is invalid because two sections have the same identifier value. They both have a locator value of 'S6':

<section target="S6">
  <title>This is Section 6</title>
  ...
  ...
</section>
<section target="S6"> <! -- ERROR -->
  <title>This is Section 7</title>
  ...
  ...

The following fragment is invalid because no element with an identifier matches the reference value:

<section target="S1">
  <title>This is Section 1</title>
  <para>Refer to <xref link="S0"> <!-- ERROR -->
  Section 7</xref> for more details.</para>
</section>
<section target="S2">
  <title>This is Section 2</title>
  ...

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.28.48