Bonjour,
J'aimerai refondre mon site en utilisant la techno XML/XSL. Pour cela, j'ai mis en place l'architecture suivante:
* Je génère du code XML en PHP
* Je créé le template en XSL
* Je combine les 2 via un script PHP
Mon problème est que j'arrive à transformer du XML "pur" via mon script php mais pas du XML généré.
Voici le fichier XML que je génère (http://www.milesteg.org/temp/test.php)
Voici le fichier XSL que j'utilise (http://www.milesteg.org/temp/test.xsl)
Et voici le script PHP que j'utilise pour effectuer la transfo XML + XSL = HTML (http://www.milesteg.org/temp/template.php5)
Lorsque j'execute tout ça, j'obtiens une erreur "Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Start tag expected, '<' not found in Entity, line: 1 in /home.10.4/milesteg/www/temp/template.php5 on line 9"
Auriez vous une piste pour m'aider à mettre tout ça en place?
D'avance merci
Modifié par Miles Teg (25 Jul 2007 - 09:58)
J'aimerai refondre mon site en utilisant la techno XML/XSL. Pour cela, j'ai mis en place l'architecture suivante:
* Je génère du code XML en PHP
* Je créé le template en XSL
* Je combine les 2 via un script PHP
Mon problème est que j'arrive à transformer du XML "pur" via mon script php mais pas du XML généré.
Voici le fichier XML que je génère (http://www.milesteg.org/temp/test.php)
<?php
header("Content-type: text/xml");
print('<?xml version="1.0" encoding="iso-8859-1"?>');
?>
<root>
<node><?php echo "test";?></node>
</root>
Voici le fichier XSL que j'utilise (http://www.milesteg.org/temp/test.xsl)
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1><xsl:value-of select="root/node"/></h1>
aaa
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Et voici le script PHP que j'utilise pour effectuer la transfo XML + XSL = HTML (http://www.milesteg.org/temp/template.php5)
<?php
$filexml = 'test.php';
$filexsl = 'test.xsl';
$xml = new DomDocument; // from /ext/dom
$xml->loadxml($filexml);
$xsl = new DomDocument;
$xsl->load($filexsl);
// Configure the transformer
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml); // actual transformation
?>
Lorsque j'execute tout ça, j'obtiens une erreur "Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Start tag expected, '<' not found in Entity, line: 1 in /home.10.4/milesteg/www/temp/template.php5 on line 9"
Auriez vous une piste pour m'aider à mettre tout ça en place?
D'avance merci

Modifié par Miles Teg (25 Jul 2007 - 09:58)