sudo apt-get install libxml2-utils xsltproc
xmllint mais1.xml xmllint mais2.xmlModifiez ces 2 fichiers pour les transformer en documents XML valides:
xmllint --noout mais1.xml && echo "SUCCESS" xmllint --noout mais2.xml && echo "SUCCESS"RENDU: mais1.xml et mais2.xml.
<les animaux de la forêt> <animal> <nom>chouette <cri>ouh ouh <animal/> <animal> <nom>écureuil <cri>non documenté <animal/> <animal> <nom>renard <repas> fromage <animal/> <les animaux de la forêt/> <les animaux de la savane> <animal herbivore=non> <nom> hyène <repas> zèbres, gnous, antilopes <animal/> <animal herbivore=oui> <nom>zèbre <repas> herbe </les animaux de la savane> <animal/>Vérifiez en sauvegardant votre fichier sous 2.1.xml puis en faisant:
rm 2.1.tar.gz; wget --no-cache http://fabien.viger.free.fr/xml/td1/2.1.tar.gz tar xf 2.1.tar.gz ./2.1.test.shRENDU: 2.1.xml.
xmllint --noout --dtdvalid file.dtd file.xml && echo "OK"
<!-- Racine -->
<!ELEMENT ecole (annee+)>
<!-- Année -->
<!ELEMENT annee (nom, age, matieres, effectif)>
<!ATTLIST annee bloc (maternelle | primaire | college | lycee) #REQUIRED>
<!-- Nom et prénom -->
<!ELEMENT nom (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT effectif (#PCDATA)>
<!-- Bloc matières -->
<!ELEMENT matieres (matiere+)>
<!ELEMENT matiere (#PCDATA)>
Mettez au moins deux années avec des blocs différents.
rm 3.1.tar.gz; wget --no-cache http://fabien.viger.free.fr/xml/td1/3.1.tar.gz tar xf 3.1.tar.gz ./3.1.test.shRENDU: 3.1.xml.
<!ELEMENT petita (petitf | (petita,petita))>
<!ELEMENT petitf (#PCDATA)>
De plus, le XML devra avoir au moins un élement a une profondeur de 5
(sachant que l'élément racine à une profondeur de 1).
rm 3.2.tar.gz; wget --no-cache http://fabien.viger.free.fr/xml/td1/3.2.tar.gz tar xf 3.2.tar.gz ./3.2.test.shRENDU: 3.2.xml.