Вы находитесь на странице: 1из 13

Validation d’un document XML par

DTD
1) Définition DTD :
Une DTD (définition du type de document) structure un document XML.
On dit qu'elle valide un document XML.
Dans un document XML valide apparaît une déclaration du type de
document (DTD: définition du type de document).
Cette déclaration définit:
 le nom des éléments, leur contenu, le nombre de fois et l'ordre
d'apparition,
 les attributs éventuels et leurs valeurs par défaut,
 les noms des entités qui peuvent être utilisées.
Les documents XML valides doivent respecter les règles données
d'une DTD.
2) Les types de DTD :

Une DTD contient deux types : Interne et Externe.

La déclaration d'une DTD doit apparaître après la


déclaration XML, mais avant l’élément racine.
<?xml version="1.0" ....>
<!DOCTYPE élément_racine ....>

Une déclaration d’une DTD interne commence par :

<!DOCTYPE ElementRacine [
….Déclaration des élements….
]>
DTD externe :
 DTD Privée:
<!DOCTYPE ElementRacine SYSTEM « nom de fichier dtd">
Exemple :
<!DOCTYPE Annuaire SYSTEM " annuaire.dtd">
 DTD Public:
<!DOCTYPE ElementRacine PUBLIC " Url dtd">
Le nom de dtd doit avoir la forme:
-//W3C//DTD annuaire//FR
Le nom du propriétaire suivie du type de document, suivi de la
langue
3) Déclaration des éléments :

Une déclaration d’un élément fournit le nom de l'élément et


décrit son contenu.
Le nom d'un élément utilisé dans le document XML doit être
identique à celui déclaré dans la DTD.
Un élément peut:
 contenir du texte,
 contenir d'autres éléments ( séquence / choix ) ,
 contenir un mélange de texte et d'éléments (contenu
mixte),
 être vide.
 quelconque
Chaque type d’élément doit être déclaré comme suit :
<!ELEMENT NOM_ELEMENT (type)>
Exemple :
 <!ELEMENT Nom (#PCDATA)>
<Nom> Mouad Elouafi </Nom>
 <!ELEMENT Professeur( Nom,Prénom,Adresse)>
<!ELEMENT Nom (#PCDATA)>
<!ELEMENT Prénom(#PCDATA)>
<!ELEMENT Adresse(#PCDATA)>
<Professeur>
<Nom> Hajjar</Nom>
<Prénom> Hind</Prénom>
<Adresse> Panoramique</Adresse>
</Professeur>
 <!ELEMENT Etudiant ( email| tel)>
<!ELEMENT email(#PCDATA)>
<!ELEMENT tel(#PCDATA)>
<Etudiant>
<email> hajjar.hind99@gmail.com</email>
</Etudiant>
 <!ELEMENT Livre any>
<Livre>
<Auteur> Albert .. </Auteur>
</Livre
 <!ELEMENT Formateur Empty>
<Formateur CIN=” BK478523”>
</Formateur>
 <!ELEMENT Voiture ( #PCDATA | Matricule)>
<Voiture>
<Matricule> 258963B </Matricule>
</Voiture
4) Les indicateurs d’occurrence :
? : 0 ou 1
+ : 1 ou n
• : 0 ou n
Exemple :
<!DOCTYPE Films [
<!ELEMENT Films ( film +)
<!ELEMENT film ( titre , date)
<!ELEMENT titre (#PCDATA)
<!ELEMENT date(#PCDATA)
]>
<Films>
<film>
<titre> Breaking bad </titre>
<date> 5/05/2014 </date>
</film>
<film>
<titre> Mercredi Addams</titre>
<date> 2/2/2006</date>
</film>
</Films>
5) Déclaration des Attributs :

Syntaxe :
<!ATTLIST Nom_Elément Attribut Type Obligation Valeur-par-défaut>
Pour l’obligation existe 3 cas:
#FIXED : attribut a une valeur fixe
#REQUIRED : attribut obligatoire
#EMPLIED : attribut n’est pas obligatoire
Les types d’un Attribut :
CDATA : texte
ID : ne peut pas prendre la même valeur
Énuméré : choix des valeurs
Exemple :
 <!ELEMENT Texte (#PCDATA) >
<!ATTLIST Texte Langue CDATA #REQUIRED
 <!ELEMENT Photo EMPTY>
<!ATTLIST Photo format (JPG|PNG) #EMPLIED "PNG"
6) Les entités :
Une entité interne correspond à une version abrégée d'un texte long
ou difficile à saisir.
Les entités peuvent être de deux types:
internes: définies dans l'entité document elle-même,
externes: dépendent d'une source externe au document XML.
Il existe 5 entités prédéfinies en XML, les voici avec leur signification:
lt: caractère '<'
gt: caractère '>‘
amp: caractère ‘&'
quot: caractère '"' (guillement double)
apos: caractère "'" (quillement simple ou apostrophe)
Déclaration d’ entité interne :
Une entité interne est définie à l'intérieur d'une DTD:
<!ENTITY nom_entité " contenue"
Exemple :
<!DOCTYPE CATALOGUE [
<!ENTITY SGBD " système de gestion de base de donnée " >
]>
La référence à une entité se fait en préfixant son nom avec & et à la
fin un ;
exemple:&SGBD;
toute référence à l'entité SGBD dans le document XML utilisant une
DTD, sera remplacé par le texte correspondant.
Déclaration d’ entité externe:
L'entité externe est définie à l'intérieur de la DTD:
<!ENTITY nom_entité SYSTEM "URL">

Soit l'exemple du document XML (livre.xml):


<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE LIVRE [
<!ENTITY legal SYSTEM "legal.xml">
]>
<LIVRE>
………………
&legal;
</LIVRE>
Si le fichier legal.xml est le suivant:
<?xml version="1.0" encoding="ISO-8859-1"?> <LEGAL>
<AUTEUR>Olivier Daudel</AUTEUR>
<DATE>1991</DATE>
<DROITS>Copyright 1991</DROITS>
</LEGAL>
Tout se passe comme si le document XML livre.xml est:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE LIVRE [
<!ENTITY legal SYSTEM "legal.xml">
]>
<LIVRE>
<LEGAL>
<AUTEUR>Olivier Daudel</AUTEUR>
<DATE>1991</DATE>
<DROITS>Copyright 1991</DROITS>
</LEGAL>
</LIVRE>
MERCI POUR VOTRE
ATTENTION

Вам также может понравиться

  • coursAngularPart1 PDF
    coursAngularPart1 PDF
    Документ34 страницы
    coursAngularPart1 PDF
    aladin007
    Оценок пока нет
  • Cours Angular Part 11
    Cours Angular Part 11
    Документ14 страниц
    Cours Angular Part 11
    aladin007
    Оценок пока нет
  • Cours Angular Part 6
    Cours Angular Part 6
    Документ32 страницы
    Cours Angular Part 6
    aladin007
    Оценок пока нет
  • Cours Angular Part 7
    Cours Angular Part 7
    Документ14 страниц
    Cours Angular Part 7
    aladin007
    Оценок пока нет
  • Cours Angular Part 3
    Cours Angular Part 3
    Документ15 страниц
    Cours Angular Part 3
    aladin007
    Оценок пока нет
  • Cours Angular Part 8
    Cours Angular Part 8
    Документ12 страниц
    Cours Angular Part 8
    aladin007
    Оценок пока нет
  • Atelier Base de Donnc3a9es 2016
    Atelier Base de Donnc3a9es 2016
    Документ80 страниц
    Atelier Base de Donnc3a9es 2016
    Vivo Vivoo VI
    Оценок пока нет
  • Les Sous Requettes
    Les Sous Requettes
    Документ2 страницы
    Les Sous Requettes
    aladin007
    Оценок пока нет
  • CM 1
    CM 1
    Документ76 страниц
    CM 1
    aladin007
    Оценок пока нет
  • Examen BD 2017 2018 VFinale
    Examen BD 2017 2018 VFinale
    Документ3 страницы
    Examen BD 2017 2018 VFinale
    aladin007
    100% (1)
  • SQL 2
    SQL 2
    Документ29 страниц
    SQL 2
    aladin007
    Оценок пока нет
  • Chap1 VectorsUnity
    Chap1 VectorsUnity
    Документ29 страниц
    Chap1 VectorsUnity
    aladin007
    Оценок пока нет
  • 50 Java Servlet JSP
    50 Java Servlet JSP
    Документ3 страницы
    50 Java Servlet JSP
    Riadh Triki
    Оценок пока нет
  • TP2 - Extraire Des Données À L'aide de L'instruction SQL SELECT
    TP2 - Extraire Des Données À L'aide de L'instruction SQL SELECT
    Документ1 страница
    TP2 - Extraire Des Données À L'aide de L'instruction SQL SELECT
    aladin007
    Оценок пока нет
  • ch2 BD 20161
    ch2 BD 20161
    Документ16 страниц
    ch2 BD 20161
    aladin007
    Оценок пока нет
  • Atelier Base de Donnc3a9es 2016
    Atelier Base de Donnc3a9es 2016
    Документ80 страниц
    Atelier Base de Donnc3a9es 2016
    Vivo Vivoo VI
    Оценок пока нет
  • Tdlstigisql2 150210080358 Conversion Gate01
    Tdlstigisql2 150210080358 Conversion Gate01
    Документ15 страниц
    Tdlstigisql2 150210080358 Conversion Gate01
    aladin007
    Оценок пока нет
  • ch4 BD 2016
    ch4 BD 2016
    Документ10 страниц
    ch4 BD 2016
    aladin007
    Оценок пока нет
  • ch5 BD 2016
    ch5 BD 2016
    Документ20 страниц
    ch5 BD 2016
    aladin007
    Оценок пока нет
  • 2015 04 27 Atelier BD 1.1
    2015 04 27 Atelier BD 1.1
    Документ8 страниц
    2015 04 27 Atelier BD 1.1
    risalafr
    Оценок пока нет
  • ch1 BD 20161 PDF
    ch1 BD 20161 PDF
    Документ10 страниц
    ch1 BD 20161 PDF
    aladin007
    Оценок пока нет
  • ch1 BD 20161 PDF
    ch1 BD 20161 PDF
    Документ10 страниц
    ch1 BD 20161 PDF
    aladin007
    Оценок пока нет
  • Chap2 Transf Geom
    Chap2 Transf Geom
    Документ15 страниц
    Chap2 Transf Geom
    aladin007
    Оценок пока нет
  • Atelier Les Fonctions D' ORACLE
    Atelier Les Fonctions D' ORACLE
    Документ6 страниц
    Atelier Les Fonctions D' ORACLE
    aladin007
    100% (1)
  • ch3 BD 2016
    ch3 BD 2016
    Документ10 страниц
    ch3 BD 2016
    aladin007
    Оценок пока нет
  • Cour PHP HTML
    Cour PHP HTML
    Документ31 страница
    Cour PHP HTML
    aladin007
    Оценок пока нет
  • Cours Communication Verbale Et Non Verbales
    Cours Communication Verbale Et Non Verbales
    Документ23 страницы
    Cours Communication Verbale Et Non Verbales
    aladin007
    100% (13)
  • Cours Javascript
    Cours Javascript
    Документ270 страниц
    Cours Javascript
    a.rharrab
    Оценок пока нет
  • TD TP
    TD TP
    Документ15 страниц
    TD TP
    aladin007
    100% (2)
  • CoursMatlab Id4540
    CoursMatlab Id4540
    Документ11 страниц
    CoursMatlab Id4540
    aladin007
    Оценок пока нет
  • TP2 BigData
    TP2 BigData
    Документ12 страниц
    TP2 BigData
    nadjah kara
    Оценок пока нет
  • IntroRDF PDF
    IntroRDF PDF
    Документ121 страница
    IntroRDF PDF
    Nõür Êl Hõüdã
    Оценок пока нет
  • DITACampus XML
    DITACampus XML
    Документ51 страница
    DITACampus XML
    Patrick Peccatte
    Оценок пока нет
  • Support de Formation - XML
    Support de Formation - XML
    Документ46 страниц
    Support de Formation - XML
    Houda
    Оценок пока нет
  • CorrigeFeuille4 11 12
    CorrigeFeuille4 11 12
    Документ7 страниц
    CorrigeFeuille4 11 12
    Anfal Ch
    Оценок пока нет
  • XML PDF
    XML PDF
    Документ152 страницы
    XML PDF
    Ansoumane Daff
    Оценок пока нет
  • php5 XSL
    php5 XSL
    Документ10 страниц
    php5 XSL
    Khalid Moubsite
    Оценок пока нет
  • Gibp1039r00fra PDF
    Gibp1039r00fra PDF
    Документ261 страница
    Gibp1039r00fra PDF
    nazim
    Оценок пока нет
  • Correction TD - XML
    Correction TD - XML
    Документ5 страниц
    Correction TD - XML
    Amine Nafid
    Оценок пока нет
  • Web Sémantique Et Ontologie (WSO) : Rapport de TP N°1
    Web Sémantique Et Ontologie (WSO) : Rapport de TP N°1
    Документ9 страниц
    Web Sémantique Et Ontologie (WSO) : Rapport de TP N°1
    فركوس محمد العيد
    Оценок пока нет
  • (COURS) - Apprendre XML
    (COURS) - Apprendre XML
    Документ51 страница
    (COURS) - Apprendre XML
    Antoine Comoe
    Оценок пока нет
  • Doctype Format
    Doctype Format
    Документ1 страница
    Doctype Format
    gianni
    Оценок пока нет
  • Cours Integration
    Cours Integration
    Документ18 страниц
    Cours Integration
    Animals Kingdom
    Оценок пока нет
  • XML Cours & Exercices
    XML Cours & Exercices
    Документ62 страницы
    XML Cours & Exercices
    madmaj
    100% (1)
  • XML
    XML
    Документ149 страниц
    XML
    muzoxi
    Оценок пока нет
  • OWLChap 6
    OWLChap 6
    Документ89 страниц
    OWLChap 6
    hamza elgarrag
    Оценок пока нет
  • Mlbda Analles Ex Reparti 1
    Mlbda Analles Ex Reparti 1
    Документ147 страниц
    Mlbda Analles Ex Reparti 1
    selen
    0% (1)
  • XML Xquery
    XML Xquery
    Документ14 страниц
    XML Xquery
    louka87
    Оценок пока нет
  • Exercice DTD
    Exercice DTD
    Документ8 страниц
    Exercice DTD
    Mohcine Rouessi
    Оценок пока нет
  • XML 2024
    XML 2024
    Документ18 страниц
    XML 2024
    hafsa.elhilali123
    Оценок пока нет
  • CV
    CV
    Документ19 страниц
    CV
    Nathan Fowler
    Оценок пока нет
  • Quelle Caractéristique Permet Aux Données Semi-Structurées de Ne Pas Avoir de Schéma
    Quelle Caractéristique Permet Aux Données Semi-Structurées de Ne Pas Avoir de Schéma
    Документ5 страниц
    Quelle Caractéristique Permet Aux Données Semi-Structurées de Ne Pas Avoir de Schéma
    Hacen Akbaoui
    Оценок пока нет
  • Cours IV XPath-2019-2020
    Cours IV XPath-2019-2020
    Документ47 страниц
    Cours IV XPath-2019-2020
    Wided Touhami
    Оценок пока нет
  • Xpath Et XSLT
    Xpath Et XSLT
    Документ36 страниц
    Xpath Et XSLT
    Ngagne03 Fall
    Оценок пока нет
  • Cours XML
    Cours XML
    Документ10 страниц
    Cours XML
    nesrine merrouchi
    Оценок пока нет
  • 7 XPath
    7 XPath
    Документ38 страниц
    7 XPath
    Hajji Youssef
    Оценок пока нет
  • Corrige-Fiche 3 DSS
    Corrige-Fiche 3 DSS
    Документ3 страницы
    Corrige-Fiche 3 DSS
    bakhti fatima zahra
    Оценок пока нет
  • TP2 DTD
    TP2 DTD
    Документ2 страницы
    TP2 DTD
    Baziz Aicha
    100% (1)
  • TP5 XML 2020
    TP5 XML 2020
    Документ3 страницы
    TP5 XML 2020
    Imane Abkadri
    Оценок пока нет
  • Seance 3 Cours XML Schema Partie 1 2023 2024
    Seance 3 Cours XML Schema Partie 1 2023 2024
    Документ13 страниц
    Seance 3 Cours XML Schema Partie 1 2023 2024
    Rouçadi Wafaa
    Оценок пока нет