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

Description

If an element name in DTD is followed by the question mark [?], this element can occur zero or one times.

DTD


The root element XXX can contain one element AAA followed by precisely one element BBB. Element BBB must be always present.:

<!ELEMENT XXX (AAA? , BBB)>
<!ELEMENT AAA (#PCDATA)>
<!ELEMENT BBB (#PCDATA)>

Valid documentsTop


A valid document:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

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

Element AAA is not mandatory:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX> <BBB/> </XXX>

Documents with errorsTop


Element BBB is missing:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

<XXX> ___ </XXX>

Maximaly one AAA element can occur inside the document:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

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

Element BBB must follow element AAA:

 <!DOCTYPE XXX SYSTEM "tutorial.dtd">

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