Modélisation et documents XML
Éléments de correction pour les exercices de modélisation.
Les articles
- la DTD Article : voir, récupérer ;
- la feuille de style CSS : voir, récupérer ;
- le document XML : voir, récupérer ;
Les brèves
Le championnat de football
Les acteurs de cinéma
Les films de cinéma
Les bandes dessinées de Florent
- la DTD : voir, récupérer ;
- le XML Schéma : voir, récupérer ;
- le Relax NG : voir, récupérer ;
- le document XML : voir, récupérer ;
La CDthèque
Requêtes XPath
Éléments de correction pour les exercices sur XPath.
Les articles
-
/ ou pour l'élément racine : /child::* /*
-
/descendant::node() //node() ou à partir de l'élément racine : /child::*/descendant::node() /*//node()
-
/descendant::*/attribute::* //@*
-
/descendant::text() //text()
-
/descendant::processing-instruction() //processing-instruction()
-
/descendant::processing-instruction('xml-stylesheet') //processing-instruction('xml-stylesheet') -
/descendant::p/child::text() //p/text()
-
/descendant::p[child::important] //p[important]
-
/descendant::référence[attribute::code='siteMarc'] //référence[@code='siteMarc']
-
/descendant::*/child::auteur[position()=2] //*/auteur[2] /descendant::auteur[count(preceding::auteur)=1] //auteur[count(preceding::auteur)=1] /descendant::auteur[(preceding::auteur) and not(preceding::auteur/preceding::auteur)] //auteur[(preceding::auteur) and not(preceding::auteur/preceding::auteur)]
Les acteurs de cinéma
-
/child::liste_acteurs/child::acteur /liste_acteurs/acteur /descendant::acteur //acteur
-
count(/child::liste_acteurs/child::acteur) count(/liste_acteurs/acteur) count(/descendant::acteur) count(//acteur)
-
/descendant::comment() //comment()
-
/descendant::comment()[position()=2] //comment()[2] NON !!!
-
/descendant::acteur[position()=1]/node()[position()=1] //acteur[1]/node()[1]
-
/descendant::acteur[position()=2]/node()[position()=1] //acteur[2]/node()[1]
-
/descendant::acteur/*[position()=1 or position()=2] //acteur/*[position()<=2]
-
/descendant::acteur/*[position()=last()] //acteur/*[last()]
-
/descendant::acteur[attribute::id='clint'] //acteur[@id='clint']
-
/descendant::acteur[child::prenom/text()='Clint'] //acteur[prenom='Clint']
-
/descendant::acteur/child::biographie/child::p[last()=2]/parent::biographie/parent::acteur/child::nom/text() //acteur/biographie/p[last()=2]/../../nom/text() /descendant::acteur/child::biographie/child::p[last()=2]/ancestor::acteur/child::nom/text() /descendant::acteur/child::nom/child::text()[count(ancestor::acteur/child::biographie/child::p)=2] //acteur/nom/text()[count(../../biographie/p)=2]
Le championnat de football
-
/descendant::JOURNEE[attribute::NUMERO < 8] //JOURNEE[@NUMERO < 8] /descendant::JOURNEE[attribute::NUMERO=8]/preceding-sibling::JOURNEE //JOURNEE[@NUMERO=8]/preceding-sibling::JOURNEE
-
/descendant::JOURNEE[attribute::NUMERO=4]/child::RENCONTRE //JOURNEE[@NUMERO=4]/RENCONTRE
-
/descendant::JOURNEE/child::RENCONTRE[position()=1] //JOURNEE/RENCONTRE[1]
-
/descendant::JOURNEE[attribute::NUMERO=10]/child::RENCONTRE[attribute::DOMICILE='Bastia']/attribute::EXTERIEUR | /descendant::JOURNEE[attribute::NUMERO=10]/child::RENCONTRE[attribute::EXTERIEUR='Bastia']/attribute::DOMICILE //JOURNEE[@NUMERO=10]/RENCONTRE[@DOMICILE='Bastia']/@EXTERIEUR | //JOURNEE[@NUMERO=10]/RENCONTRE[@EXTERIEUR='Bastia']/@DOMICILE
-
/descendant::RENCONTRE[attribute::DOMICILE='Bastia']/attribute::EXTERIEUR | /descendant::RENCONTRE[attribute::EXTERIEUR='Bastia']/attribute::DOMICILE //RENCONTRE[@DOMICILE='Bastia']/@EXTERIEUR | //RENCONTRE[@EXTERIEUR='Bastia']/@DOMICILE
-
/descendant::RENCONTRE[attribute::SCORED='-'] //RENCONTRE[@SCORED='-']
-
/descendant::RENCONTRE[attribute::DOMICILE='Bastia' and attribute::SCORED!='-' and attribute::SCORED=attribute::SCOREE] //RENCONTRE[@DOMICILE='Bastia' and @SCORED!='-' and @SCORED=@SCOREE]
-
count(/descendant::RENCONTRE[attribute::SCORED!='-' and attribute::SCORED=attribute::SCOREE]) count(//RENCONTRE[@SCORED!='-' and @SCORED=@SCOREE]) 100.*count(/descendant::RENCONTRE[attribute::SCORED!='-' and attribute::SCORED=attribute::SCOREE]) div count(/descendant::RENCONTRE[attribute::SCORED!='-']) 100*count(//RENCONTRE[@SCORED!='-' and @SCORED=@SCOREE]) div count(//RENCONTRE[@SCORED!='-'])
-
count(/descendant::RENCONTRE[attribute::SCORED>attribute::SCOREE]) count(//RENCONTRE[@SCORED>@SCOREE]) 100*count(/descendant::RENCONTRE[attribute::SCORED>attribute::SCOREE]) div count(/descendant::RENCONTRE[attribute::SCORED!='-']) 100*count(//RENCONTRE[@SCORED>@SCOREE]) div count(//RENCONTRE[@SCORED!='-'])
-
count(/descendant::RENCONTRE[attribute::SCORED<attribute::SCOREE]) count(//RENCONTRE[@SCORED<@SCOREE]) 100*count(/descendant::RENCONTRE[attribute::SCORED<attribute::SCOREE]) div count(/descendant::RENCONTRE[attribute::SCORED!='-']) 100*count(//RENCONTRE[@SCORED<@SCOREE]) div count(//RENCONTRE[@SCORED!='-'])
Les brèves
Correction fournie par Grégoire Laurence, merci à lui !
-
//node()
-
//*
-
soit uniquement les href :
//@href
soit tous les attributs commencant par http :
//@*[starts-with (.,'http')]
-
count(//breve)
-
//breve/titre/text()
-
//breve[@theme="sport"]
-
//breve[photo]
-
//breve[starts-with(titre/text(),"D")]
-
//breve[contains(texte/text(),"marathon")]
-
//breve[@theme="actu"]/following::*
Les films
Correction fournie par Grégoire Laurence, merci à lui !
-
count(//film)
-
//comment()
-
//film[2]//acteur
-
//film[@lang="en"]/titre/text()
-
//acteur[@id="lukemonfils"]/@personnage
-
//film[annee/text()="1981"]/titre/text()
-
count(//perso[@ref="indy"])
-
//film[count(.//acteur)=0]
-
//film[count(realisateur)>1]
-
//film[contains(synopsis,"believe")]/titre/text()
Les TODO list
-
//@* /attribute-or-self::node()/attribute::node()
-
//comment() /descendant-or-self::comment()
-
//text() /descendant-or-self::text()
-
//*[@deadline][position()=2]/@deadline
-
//item[1]
-
//todo[.//@level='critic']/title/
-
//todo[not (.//commentaires)]/title
-
.//@url
-
count(//todo[2]/commentaires/par)
-
//todo[@illustration='sapin.jpg']/title
Les bandes dessinées
Correction fournie par Grégoire Laurence, merci à lui !
-
count(//collection//bd)
-
//bd[not(ancestor::serie)]
-
//titreserie
et si titreserie n'était pas propre aux séries :
//serie/titreserie
-
count(//serie[titreserie/text()="Lanfeust de Troy"]/bd)
-
//@illustration
-
//bd[illustrateur/@ref=//personne[nom="Larcenet" and prenom="Manu"]/@id]
explication : d'abord on cherche l'identifiant de "Manu Larcenet" //personne[nom="Larcenet" and prenom="Manu"]/@id et ensuite on cherche les bd referençant cet illustrateur ;
en plus simple :
//bd[illustrateur/@ref="Larcenet"]
-
//personne[prenom="Riad"]/@id
-
//personne[nom="Larcenet" and prenom="Manu"]/preceding-sibling::*
les autres personnes définies étant des frères de l'élément sélectionné ;
ou :
//personne[nom="Larcenet" and prenom="Manu"]/preceding::personne
-
//bd[starts-with(titre,"L")]/sortie/text()
-
//bd[contains(resume,"oiseau")]
-
/descendant-or-self::bd[2]
attention ! différent de //bd[2].
Transformations XSLT
Éléments de correction pour les exercices sur le langage XSLT.
Les brèves
- la feuille XSLT produisant du HTML : voir, récupérer ;
- la feuille CSS associée à la page HTML : voir, récupérer ;
- le résultat final.
Le championnat de football
- la feuille XSLT produisant du HTML : voir, récupérer ;
- la feuille XSLT produisant du SVG : voir, récupérer ;
- la feuille CSS associée à la page HTML : voir, récupérer ;
- le résultat final :
- voir le code SVG produit ;
- la page HTML résultat.
Les acteurs de cinéma
- la feuille XSLT produisant du HTML : voir, récupérer ;
- la feuille CSS associée à la page HTML : voir, récupérer ;
- le résultat final.
Les films de cinéma
- la feuille XSLT produisant du HTML : voir, récupérer ;
- la feuille CSS associée à la page HTML : voir, récupérer ;
- le résultat final.
Les sujets abordés dans une formation
- la feuille XSLT produisant du HTML : voir, récupérer ;
- le résultat final.
Transformation des TODO list
- la feuille XSLT produisant du HTML : voir, récupérer ;
- le résultat final.
Les sujets abordés dans une formation (épisode 2, le retour)
Tourner les tables
Coloration syntaxique d'un fichier XML
- la feuille XSLT produisant du HTML : voir, récupérer ;
- la feuille CSS associée à la page HTML : voir, récupérer ;
- application aux acteurs, aux brèves, aux foot, aux films et à elle-même.
Calcul de la fonction factorielle
- le fichier XML en entrée : voir, récupérer ;
- la feuille XSLT réalisant le calcul : voir, récupérer ;
Résolution des tours de Hanoï
- le fichier XML en entrée : voir, récupérer ;
- la feuille XSLT réalisant le calcul : voir, récupérer ;
Tester la conjecture de Syracuse
Python et SAX
Éléments de correction pour les exercices SAX en Python.
Le championnat de football
- le programme Python/SAX calculant les statistiques et produisant le HTML : voir, récupérer ;
- la feuille CSS associée à la page html : voir, récupérer ;
- le résultat final.
Les acteurs
- le programme Python/SAX qui produit du HTML à partir du fichier d'acteurs : voir, récupérer ;
- la feuille CSS associée à la page html : voir, récupérer ;
- le résultat final.
Python et DOM
Éléments de correction pour les exercices DOM en Python.
Extraction de méta-données
Le programme Python/DOM : voir, récupérer.
Fonctions utiles
Le programme Python/DOM : voir, récupérer.
Voir aussi...
- Travaux pratiques XML
Exercices pratiques autour de XML.
- Cours sur le langage XML
Notes de cours sur les technologies liées au langage XML : définition de DTD, XSLT, etc.




