13.07.2013 Views

dans des entrepôts de données XML - CoDE - Université Libre de ...

dans des entrepôts de données XML - CoDE - Université Libre de ...

dans des entrepôts de données XML - CoDE - Université Libre de ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPITRE 7. RÉALISATION DE L’ETL 45<br />

7.1.2 Vérifier si un tag <strong>de</strong> XSD définit un élément<br />

Comme nous l’avons vu au chapitre 5 (p. 28), la définition d’un élément se fait avec le tag<br />

spécial xs : element (parfois on utilise xsd : element). Il suffit donc <strong>de</strong> vérifier si on a affaire<br />

avec ce tag pour savoir si on définit un élément. C’est ce que nous faisons <strong>dans</strong> l’algorithme<br />

du listing 7.2.<br />

Listing 7.2 – Algorithme testant si un tag XSD définit un élément<br />

function isElement ( tagName )<br />

{<br />

returnval := false ;<br />

if " tagName is ’xs: element ’" then returnval := true ;<br />

return returnval ;<br />

}<br />

7.1.3 Vérifier si un tag <strong>de</strong> XSD définit un attribut<br />

En suivant un raisonnement analogue á celui du paragraphe 7.1.2, nous obtenons l’algorithme<br />

du listing 7.3.<br />

Listing 7.3 – Algorithme testant si un tag XSD définit un attribut<br />

function isAttribute ( tagName )<br />

{<br />

returnval := false ;<br />

if " tagName is ’xs: attribute ’" then returnval := true ;<br />

return returnval ;<br />

}<br />

7.1.4 Extraction du nom d’un élément, attribut ou type défini<br />

Ce paragraphe montre comment extraire le nom <strong>de</strong> l’élément, <strong>de</strong> l’attribut ou du type<br />

complexe défini <strong>dans</strong> le noeud courant <strong>de</strong> l’arbre du schéma XSD. Pour trouver 2 cette information,<br />

il suffit <strong>de</strong> vérifier si le noeud a <strong><strong>de</strong>s</strong> attributs. Si c’est le cas, alors prendre la valeur <strong>de</strong><br />

l’attribut name. Une fonction que nous proposons pour effectuer cette tâche est reprise <strong>dans</strong><br />

le listing 7.4.<br />

Listing 7.4 – Algorithme d’extraction du nom <strong>de</strong> l’élément/attribut/type complexe défini<br />

function elemName ( no<strong>de</strong> )<br />

{<br />

if (" no<strong>de</strong> is not null " and no<strong>de</strong> -> hasAttributes ()) then<br />

{<br />

returnval := no<strong>de</strong> -> getAttribute (" name ");<br />

}<br />

return returnval ;<br />

}<br />

2 Voir le chapitre 5 pour la définition <strong>de</strong> schéma XSD

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!