(PHP 4 >= 4.2.0)
domxml_xslt_stylesheet — Creates a DomXsltStylesheet object from an XSL document in a string
Creates a DomXsltStylesheet object from the given XSL buffer.
The XSL document, as a string.
Returns a new instance of DomXsltStylesheet.
Call XSLTProcessor::importStylesheet() with DOMDocument::loadXML($xsl_buf) as parameter.
This is an exemple to change from XML to HTML by XSL utilising XML_DOM
File XML : Reunions.xml
<?xml version="1.0"?>
<reunions prev_id_reunion="2">
<reunion id_reunion="0">
<organisateur>Organisateur 1</organisateur>
<date>Date 1</date>
<heure>Heure 1</heure>
<lieu>Lieu 1</lieu>
<sujets>
<sujet>Sujet 11</sujet>
<sujet>Sujet 12</sujet>
</sujets>
<participants>
<participant>Participant11</participant>
<participant>Participant12</participant>
</participants>
</reunion>
<reunion id_reunion="1">
<organisateur>Organisateur 2</organisateur>
<date>Date 2</date>
<heure>Heure 2</heure>
<lieu>Lieu 2</lieu>
<sujets>
<sujet>Sujet21</sujet>
<sujet>Sujet22</sujet>
</sujets>
<participants>
<participant>Participant21</participant>
<participant>Participant22</participant>
</participants>
</reunion>
</reunions>
File PHP : Reunions.PhP
<?php
$StrXsl = '<?xml version="1.0" encoding="ISO-8859-1"?>'.
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">'.
'<xsl:template match="/">'.
'<html>'.
'<head>'.
'<title></title>'.
'</head>'.
'<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="+2">La liste des reunions</font>'.
'<table border="0" cellpadding="0" cellspacing="0" width="300" bgcolor="#f5fffa">'.
'<tr>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Organisateur</font>'.
'</div>'.
'</th>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Date</font>'.
'</div>'.
'</th>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Heure</font>'.
'</div>'.
'</th>'.
'<th>'.
'<div align="center">'.
'<font face="Verdana" color="#4682b4" size="-1">Lieu</font>'.
'</div>'.
'</th>'.
'</tr>'.
'<xsl:apply-templates select="reunions/reunion">'.
'<xsl:sort select="organisateur" order="ascending"/>'.
'</xsl:apply-templates>'.
'</table>'.
'</div>'.
'</body>'.
'</html>'.
'</xsl:template>'.
'<xsl:template match="reunion">'.
'<tr>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="organisateur"/></font>'.
'</td>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="date"/></font>'.
'</td>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="heure"/></font>'.
'</td>'.
'<td bgcolor="white">'.
'<font face="Verdana" color="#4682b4" size="-1"><xsl:value-of select="lieu"/></font>'.
'</td>'.
'</tr>'.
'</xsl:template>'.
'</xsl:stylesheet>';
//Transformer XML -> HTML par XSL
$CurrentDir = dirname(__FILE__);
$xmldoc = domxml_open_file("$CurrentDir\\Reunions.xml");
$xsldoc = domxml_xslt_stylesheet ($StrXsl);
$result = $xsldoc->process($xmldoc);
print $xsldoc->result_dump_mem($result);
?>