Bonjour,
Je voudrais afficher le contenu d'un fichier xml dans une page php existante:
le fichier xml:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 echo '<div class="notice_metadata"> <h4>' . gettext('Fragment') . '</h4>'; $xml=new DOMDocument(); $xml->load('../templates/affichage_fragment.xml'); $xsl=new DOMDocument(); $xsl->load('../templates/affichage_fragment.xsl', LIBXML_NOCDATA); $proc = new XSLTProcessor(); $proc->importStylesheet($xsl); echo $proc->transformToXml($xml); echo '</div>';
le fichier xsl:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="../templates/affichage_fragment.xsl"?> <record><fragment> <cit hand="GF-encre"> <quote>donna à la cupidité des princes <choice> <orig><c>&</c></orig> <reg>et</reg> </choice> des peuples les biens des pauvres <choice> <orig><c>&</c></orig> <reg>et</reg> </choice> les dépouilles <lb/>des monastères. »</quote> <bibl id="2862-3"><lb/><choice> <abbr>P.</abbr> <expan>P<ex>ère</ex></expan> </choice> Félix <choice> <abbr>progr.</abbr> <expan><reg>P</reg>rogr<ex>ès</ex></expan> </choice> par le <choice> <abbr>chr</abbr> <expan>chr<ex>istianisme</ex></expan> </choice> (<abbr>t</abbr><supplied>.</supplied> 2. <supplied reason="omission"><abbr>p.</abbr></supplied> 91)</bibl> </cit> </fragment></record>
et j'obtiens les erreurs suivantes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://wwww.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <div> <xsl:value-of select="record/fragment/cit/cote"/> </div> </xsl:template> </xsl:stylesheet>
J'ai tourné ça dans tous les sens, mais rien n'y fait.Warning: XSLTProcessor::importStylesheet() [function.XSLTProcessor-importStylesheet]: compilation error: file /home/web/dossiers-flaubert.dev/templates/affichage_fragment.xsl line 2 element stylesheet in /home/web/dossiers/templates/affichage_fragment.php on line 99
Warning: XSLTProcessor::importStylesheet() [function.XSLTProcessor-importStylesheet]: xsltParseStylesheetProcess : document is not a stylesheet in /home/web/dossiers/templates/affichage_fragment.php on line 99
Warning: XSLTProcessor::transformToXml() [function.XSLTProcessor-transformToXml]: No stylesheet associated to this object in /home/web/dossiers/templates/affichage_fragment.php on line 101
Partager