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

Description

With character [ | ] you can select one from several elements.

DTD


The root element XXX must contain one element AAA followed by one element BBB. Element AAA must contain one element CCC followed by element DDD. Element BBB must contain either one element CCC or 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/>
   </BBB>
</XXX>

Another valid document:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

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

Documents with errorsTop


The element BBB can contain either element CCC or DDD but not both:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

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

The element BBB can contain either element CCC or DDD but not both:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

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