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

Description

This example uses a combination of [ + * ?]

DTD


The root element XXX can contain one element AAA followed by one or more elements BBB. Element AAA can contain one element CCC and several elements DDD. Element BBB must contain precisely one element CCC and one element DDD:

<!ELEMENT XXX (AAA? , BBB+)>
<!ELEMENT AAA (CCC? , DDD*)>
<!ELEMENT BBB (CCC , DDD)>
<!ELEMENT CCC (#PCDATA)>
<!ELEMENT DDD (#PCDATA)>

Valid documentsTop


A valid document:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA>
      <CCC/><DDD/>
   </AAA>
   <BBB>
      <CCC/><DDD/>
   </BBB>
</XXX>

Elements in AAA are not mandatory:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA/>
   <BBB>
      <CCC/><DDD/>
   </BBB>
</XXX>

Element AAA can be omitted:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <BBB>
      <CCC/><DDD/>
   </BBB>
</XXX>

Documents with errorsTop


Element BBB must contain elements CCC and DDD:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA/>
   <BBB/>
</XXX>

Element AAA can contain maximaly one element CCC:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX>
   <AAA>
      <CCC/><CCC/>
      <DDD/><DDD/>
   </AAA>
   <BBB>
      <CCC/><DDD/>
   </BBB>
</XXX>