{"id":3208,"date":"2017-03-24T10:33:53","date_gmt":"2017-03-24T09:33:53","guid":{"rendered":"http:\/\/www.blue-bears.com\/blog\/?p=3208"},"modified":"2018-06-04T21:00:56","modified_gmt":"2018-06-04T19:00:56","slug":"xml-xsl-access","status":"publish","type":"post","link":"http:\/\/www.blue-bears.com\/blog\/?p=3208","title":{"rendered":"XML \/ XSL \/ ACCESS"},"content":{"rendered":"<p>Import de donn\u00e9es XML dans une base de donn\u00e9es ACCESS.<br \/>\nImport de donn\u00e9es XML dans une base MYSQL<\/p>\n<p><!--more--><\/p>\n<h5>Proc\u00e9dure :<\/h5>\n<ul>\n<li>Donn\u00e9es de d\u00e9part : XML<\/li>\n<li><a href=\"http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3214\" src=\"http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML.jpg\" alt=\"\" width=\"770\" height=\"264\" srcset=\"http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML.jpg 1122w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML-300x103.jpg 300w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML-768x264.jpg 768w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML-1024x351.jpg 1024w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML-830x285.jpg 830w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML-230x79.jpg 230w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML-350x120.jpg 350w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XML-480x165.jpg 480w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/a><\/li>\n<li>Transformation : XSL\n<ul>\n<li>Attention : tous les caract\u00e8res non d\u00e9finis dans l&rsquo;ent\u00eate bloque le traitement. (exemple : \u20ac \/ \u00e9\u00a0\/\u00d4 &#8230;.)<\/li>\n<li><a href=\"http:\/\/www.w3.org\/TR\/REC-html40\/sgml\/entities.html\">http:\/\/www.w3.org\/TR\/REC-html40\/sgml\/entities.html<\/a><\/li>\n<li><a href=\"http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3215\" src=\"http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL.jpg\" alt=\"\" width=\"1247\" height=\"809\" srcset=\"http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL.jpg 1247w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL-300x195.jpg 300w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL-768x498.jpg 768w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL-1024x664.jpg 1024w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL-830x538.jpg 830w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL-230x149.jpg 230w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL-350x227.jpg 350w, http:\/\/www.blue-bears.com\/blog\/wp-content\/uploads\/2017\/03\/Capture_XSL-480x311.jpg 480w\" sizes=\"auto, (max-width: 1247px) 100vw, 1247px\" \/><\/a><\/li>\n<\/ul>\n<\/li>\n<li>Import : XML =&gt; ACCESS<\/li>\n<\/ul>\n<p align=\"justify\">L&rsquo;attribut \u00ab\u00a0<i>match<\/i>\u00a0\u00bb de la balise <i>&lt;xsl:template&gt;<\/i> permet de d\u00e9finir (gr\u00e2ce \u00e0 la notation <i>XPath<\/i>) le ou les \u00e9l\u00e9ments du document XML sur lesquels s&rsquo;applique la transformation.<\/p>\n<p align=\"justify\">La notation <i>Xpath<\/i> permet de d\u00e9finir des patterns, c&rsquo;est-\u00e0-dire des cha\u00eenes de caract\u00e8res permettant de rep\u00e9rer un noeud dans le document XML. Les principaux patterns sont\u00a0:<\/p>\n<table class=\"ccm\">\n<tbody>\n<tr>\n<th>Pattern<\/th>\n<th>Exemple<\/th>\n<th>Signification<\/th>\n<\/tr>\n<tr>\n<td>|<\/td>\n<th>Gauche|Milieu<\/th>\n<td>Indique une alternative (un noeud ou bien l&rsquo;autre (ou les deux))<\/td>\n<\/tr>\n<tr>\n<td>\/<\/td>\n<th>personne\/nom<\/th>\n<td>Chemin d&rsquo;acc\u00e8s aux \u00e9l\u00e9ments (<i>personne\/bras\/gauche<\/i>) au m\u00eame titre que l&rsquo;arborescence utilis\u00e9e g\u00e9n\u00e9ralement pour les fichiers (<i>\/usr\/bin\/toto<\/i>)<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<th>*<\/th>\n<td>Motif \u00ab\u00a0joker\u00a0\u00bb d\u00e9signant n&rsquo;importe quel \u00e9l\u00e9ment<\/td>\n<\/tr>\n<tr>\n<td>\/\/<\/td>\n<th>\/\/personne<\/th>\n<td>Indique tous les descendants d&rsquo;un noeud<\/td>\n<\/tr>\n<tr>\n<td>.<\/td>\n<th>.<\/th>\n<td>Caract\u00e9rise le noeud courant<\/td>\n<\/tr>\n<tr>\n<td>..<\/td>\n<th>..<\/th>\n<td>D\u00e9signe le noeud parent<\/td>\n<\/tr>\n<tr>\n<td>@<\/td>\n<th>@valeur<\/th>\n<td>Indique un attribut caract\u00e9ristique (dans l&rsquo;exemple l&rsquo;attribut <i>value<\/i><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p align=\"justify\">La transformation peut \u00eatre r\u00e9alis\u00e9e<\/p>\n<ul>\n<li>soit par ajout de texte,<\/li>\n<li>soit en d\u00e9finissant des <i>\u00e9l\u00e9ments de transformation<\/i>, c&rsquo;est-\u00e0-dire des \u00e9l\u00e9ments permettant de d\u00e9finir des r\u00e8gles de transformation \u00e0 appliquer aux \u00e9l\u00e9ments s\u00e9lectionn\u00e9s par l&rsquo;attribut <i>match<\/i><\/li>\n<\/ul>\n<h3>Exemple code VBA 6.0<\/h3>\n<p><a href=\"https:\/\/khany.developpez.com\/tutoriel\/xml\/\">https:\/\/khany.developpez.com\/tutoriel\/xml\/<\/a><\/p>\n<pre><\/pre>\n<pre>\u00a0\r\nPublic Sub ImportXML<span class=\"br0\">(<\/span><span class=\"br0\">)<\/span>\r\n\u00a0\r\n    Dim doc As MSXML2.DOMDocument\r\n    Dim parent As MSXML2.IXMLDOMElement\r\n    Dim fils As MSXML2.IXMLDOMNode\r\n\u00a0\r\n    Dim dt As DAO.Recordset\r\n\u00a0\r\n    Set dt = CurrentDb.OpenRecordset<span class=\"br0\">(<\/span>\"table1\"<span class=\"br0\">)<\/span>\r\n    Set doc = New MSXML2.DOMDocument\r\n\u00a0\r\n    doc.async = False\r\n    doc.Load <span class=\"br0\">(<\/span>emplacement et nom du fichier XML<span class=\"br0\">)<\/span>\r\n    ' Recherche des noeuds IDENT\r\n    For Each parent In doc.getElementsByTagName<span class=\"br0\">(<\/span>\"IDENT\"<span class=\"br0\">)<\/span>\r\n        dt.AddNew\r\n        ' parcourir noeud fils du parent\r\n        For Each fils In parent.childNodes\r\n            ' attribut = nom du champs\r\n            dt.Fields<span class=\"br0\">(<\/span>fils.nodeName<span class=\"br0\">)<\/span> = fils.Text\r\n        Next\r\n        dt.Update\r\n    Next\r\n\u00a0\r\n    Set doc = Nothing\r\n    dt.close\r\n    Set dt = nothing\r\n\u00a0\r\nEnd Sub<\/pre>\n<p>&nbsp;<\/p>\n<h3>Manipulation XML \/ PHP<\/h3>\n<ul>\n<li>V\u00e9rifier que le composant DOM\/XML est activ\u00e9 =&gt; PHPInfo()<\/li>\n<li>Voir fonction SimpleXML<\/li>\n<li>Conversion MYSQL=&gt; XML en PHP avec exemple Google Map API :\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/maps\/documentation\/javascript\/mysql-to-maps?hl=fr\">https:\/\/developers.google.com\/maps\/documentation\/javascript\/mysql-to-maps?hl=fr<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h5>Biblio :<\/h5>\n<ul>\n<li>Transformation XML via XSL :\n<ul>\n<li><a href=\"https:\/\/openclassrooms.com\/courses\/les-bases-de-la-mise-en-forme-xml-avec-xslt\">https:\/\/openclassrooms.com\/courses\/les-bases-de-la-mise-en-forme-xml-avec-xslt<\/a><\/li>\n<li><a href=\"http:\/\/www.commentcamarche.net\/contents\/1337-mise-en-page-de-xml-avec-xsl\">http:\/\/www.commentcamarche.net\/contents\/1337-mise-en-page-de-xml-avec-xsl<\/a><\/li>\n<\/ul>\n<\/li>\n<li>Manipulation XML\/PHP =&gt; DOM\n<ul>\n<li><a href=\"http:\/\/php.net\/manual\/fr\/refs.xml.php\">http:\/\/php.net\/manual\/fr\/refs.xml.php<\/a><\/li>\n<\/ul>\n<\/li>\n<li>SimpleXML (basic mais efficace):\n<ul>\n<li><a href=\"http:\/\/php.net\/manual\/fr\/simplexml.examples-basic.php\">http:\/\/php.net\/manual\/fr\/simplexml.examples-basic.php<\/a><\/li>\n<li>Avec un exemple \u00e0 la fin :<\/li>\n<li><a href=\"https:\/\/www.univ-orleans.fr\/iut-orleans\/informatique\/intra\/tuto\/php\/xml-json.html\">https:\/\/www.univ-orleans.fr\/iut-orleans\/informatique\/intra\/tuto\/php\/xml-json.html<\/a><\/li>\n<\/ul>\n<\/li>\n<li>Le XML en g\u00e9n\u00e9ral avec les bases de donn\u00e9es :\n<ul>\n<li><a href=\"http:\/\/peccatte.karefil.com\/software\/RBourret\/xmlBD.htm\">http:\/\/peccatte.karefil.com\/software\/RBourret\/xmlBD.htm<\/a><\/li>\n<li><a href=\"http:\/\/miage.univ-nantes.fr\/miage\/D2X1\/chapitre_bdxml\/section_principes.htm\">http:\/\/miage.univ-nantes.fr\/miage\/D2X1\/chapitre_bdxml\/section_principes.htm<\/a><\/li>\n<\/ul>\n<\/li>\n<li><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Import de donn\u00e9es XML dans une base de donn\u00e9es ACCESS. Import de donn\u00e9es XML dans une base MYSQL<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-3208","post","type-post","status-publish","format-standard","hentry","category-informatique"],"_links":{"self":[{"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3208"}],"version-history":[{"count":12,"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3208\/revisions"}],"predecessor-version":[{"id":3636,"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3208\/revisions\/3636"}],"wp:attachment":[{"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3208"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.blue-bears.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}