Pour cet exercice on utilisera un éditeur XML, tel que Oxygen.
Soit la DTD suivante :
<!ELEMENT document (entete,corps)>
<!ELEMENT entete (identification, motscles?, resume?)>
<!ELEMENT identification (titre, date, auteur, version)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT auteur (#PCDATA)>
<!ELEMENT titre (#PCDATA)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT motscles (motitem+)>
<!ELEMENT motitem (#PCDATA)>
<!ELEMENT resume (paragraphe+)>
<!ELEMENT corps (introduction?, (div+ | contenu), conclusion?)>
<!ELEMENT div (titre, introduction?, (div+ | contenu), conclusion?)>
<!ELEMENT introduction (paragraphe+)>
<!ELEMENT conclusion (paragraphe+)>
<!ELEMENT contenu (paragraphe)+>
<!ELEMENT paragraphe (#PCDATA | important | etranger | note)*>
<!ELEMENT important (#PCDATA)>
<!ELEMENT note (#PCDATA)>
<!ELEMENT etranger (#PCDATA)>
<!ATTLIST etranger
langue CDATA #IMPLIED
>
Produire un document XML valide par rapport à cette DTD.
Produire le plus petit document XML valide par rapport à cette DTD.
Produire un document XML utilisant toutes les balises de la DTD.
Soit le document XML suivant.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE document SYSTEM "document.dtd">
<document>
<entete>
<identification>
<titre>Text</titre>
<date>Text</date>
<auteur>Text</auteur>
<version>Text</version>
</identification>
<motscles>
<motitem>Text</motitem>
<motitem>Text</motitem>
<motitem>Text</motitem>
</motscles>
</entete>
<corps>
<introduction>
<paragraphe>Text</paragraphe>
<paragraphe>Text <important>Text</important>Text</paragraphe>
</introduction>
<div>
<titre>Text</titre>
<introduction>
<paragraphe>Text</paragraphe>
</introduction>
<contenu>
<paragraphe>Text</paragraphe>
</contenu>
<conclusion>
<paragraphe><note>Text</note></paragraphe>
</conclusion>
</div>
<div>
<titre>Text</titre>
<div>
<titre></titre>
<contenu>
<paragraphe>Text</paragraphe>
</contenu>
</div>
<conclusion>
<paragraphe>Text</paragraphe>
</conclusion>
</div>
<conclusion>
<paragraphe>Text</paragraphe>
</conclusion>
</corps>
</document>
Ce document est-il valide par rapport à la DTD ?