>> English << | česky | Español | По-русски | Français | Italiano | Deutsch | MagyarZVON > Tutorials > DTD Tutorial
>> Example 12 << | Prev | Next | Contents

Description

The value of IDREF attribute must match the value of some ID attribute in the document. The value of IDREFS attribute can contain several references to elements with ID attribute separated with whitespaces.

DTD


The attributes id and mark uniquely determine their element. The attributes ref refer to these elements:

<!ELEMENT XXX (AAA+ , BBB+, CCC+, DDD+)>
<!ELEMENT AAA (#PCDATA)>
<!ELEMENT BBB (#PCDATA)>
<!ELEMENT CCC (#PCDATA)>
<!ELEMENT DDD (#PCDATA)>
<!ATTLIST AAA 
      mark ID #REQUIRED>
<!ATTLIST BBB 
      id ID #REQUIRED>      
<!ATTLIST CCC 
      ref IDREF #REQUIRED>
<!ATTLIST DDD 
      ref IDREFS #REQUIRED>      

Valid documentsTop


All ID values are unique and all IDREF and IDREFS point to elements with relevant IDs:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA mark="a1"/>
   <AAA mark="a2"/>
   <AAA mark="a3"/>
   <BBB id="b001" />
   <CCC ref="a3" />
   <DDD ref="a1 b001 a2" />
</XXX>

Documents with errorsTop


There are no ID attributes with value a3 or b001:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA mark="a1"/>
   <AAA mark="a2"/>   
   <BBB id="b01" />
   <CCC ref="a3" />
   <DDD ref="a1 b001 a2" />
</XXX>

The attribute ref in element CCC is of type IDREF. It can contain only one reference:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA mark="a1"/>
   <AAA mark="a2"/>
   <AAA mark="a3"/>
   <BBB id="b001" />
   <CCC ref="a1 b001 a2" />
   <DDD ref="a1 b001 a2" />
</XXX>