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

Description

The value of an attribute of ID type can contain only characters permitted for NMTOKEN and must start with a letter. No element type may have more than one ID attribute specified. The value of an ID attribute must be unique between all values of all ID attributes.

DTD


The attributes id, code and X uniquely determine their element:

<!ELEMENT XXX (AAA+ , BBB+ , CCC+)>
<!ELEMENT AAA (#PCDATA)>
<!ELEMENT BBB (#PCDATA)>
<!ELEMENT CCC (#PCDATA)>
<!ATTLIST AAA 
      id ID #REQUIRED>
<!ATTLIST BBB 
      code ID #IMPLIED
      list NMTOKEN #IMPLIED>      
<!ATTLIST CCC 
      X ID #REQUIRED
      Y NMTOKEN #IMPLIED>

Valid documentsTop


All ID values are unique :

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA id="a1"/>
   <AAA id="a2"/>
   <AAA id="a3"/>
   <BBB code="QWQ-123-14-6" list="14:5"/>
   <CCC X="zero" Y="16" />
</XXX>

The attributes list and Y are of type NMTOKEN not ID. They can have therefore the same value as ID attributes or to have the same value in several elements :

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA id="L12"/>
   <BBB code="QW" list="L12"/>
   <CCC X="x-0" Y="QW" />
   <CCC X="x-1" Y="QW" />
</XXX>

Documents with errorsTop


The ID attribute must not start with a number or contain a character not permitted in NMTOKEN:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA id="L12"/>
   <BBB code="#QW" list="L12"/>
   <CCC X="12" Y="QW" />
</XXX>

The ID attribute must have a unique value:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA id="L12"/>
   <BBB code="QW" list="L12"/>
   <CCC X="ZA" Y="QW" />
   <CCC X="ZA" Y="QW" />
</XXX>

The ID attribute must have a unique value. Both id and X are of type ID:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA id="L12"/>
   <BBB code="QW" list="L12"/>
   <CCC X="L12" Y="QW" />
</XXX>