[XSLT][PHP5] Impossible d'obtenir les CDATAS ...
Bonjour,
je m'arrache les cheveux sur quelquechose qui me paraissait simple a la base.
J'ai un code xsl pour le menu du site qui fonctionne parfaitement, et impossible de faire la meme chose pour le contenu, voila les documents, si vous pouvez jeter un coup d'oeil et griller ce que j'ai certainement zappé en tant que débutant... merci beaucoup.
la DTD:
Code:
1 2 3 4 5 6 7 8 9 10
|
<!ELEMENT PagePhX (ParaG)*>
<!ATTLIST PagePhX xmlns CDATA #FIXED "http://www.eritroblast.com">
<!ATTLIST PagePhX idRoot ID #REQUIRED>
<!ATTLIST PagePhX idMax CDATA #IMPLIED>
<!ATTLIST PagePhX nbElements CDATA #REQUIRED>
<!ELEMENT ParaG (#PCDATA)>
<!ATTLIST ParaG xmlns CDATA #FIXED "http://www.eritroblast.com">
<!ATTLIST ParaG id ID #REQUIRED> |
le XSL:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
media-type="text/html; charset=ISO-8859-1"/>
<xsl:template match="PagePhX">
<div id="datas" >
<xsl:for-each select="ParaG">
<div class="ParaG">
<xsl:value-of select="current()" disable-output-escaping="yes" />
</div>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet> |
le XML
Code:
1 2 3 4 5 6 7 8
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE PagePhX SYSTEM "../../include/xml_css/datas.dtd">
<?xml-stylesheet type="text/xsl" href="../../include/xml_css/datas.xsl"?>
<PagePhX xmlns="http://www.eritroblast.com" idMax="A03" idRoot="root" nbElements="0">
<ParaG id="A02">sfdsdvsvsvcxfxvfdvfdv</ParaG>
<ParaG id="A01"><![CDATA[Bienvenue, blablabla,<b>première</b> page!]]></ParaG>
</PagePhX> |
et la fonction PHP:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
function processDatas($fileXml,$fileXsl){
// Load the XML source
$xml = new DOMDocument;
$xml->load($fileXml);
$xsl = new DOMDocument;
$xsl->load($fileXsl);
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo html_entity_decode($proc->transformToXML($xml));
} |