note 29521 added to function.domxml-xslt-stylesheet

From: Date: Sun, 16 Feb 2003 09:04:23 +0000
Subject: note 29521 added to function.domxml-xslt-stylesheet
Groups: php.notes 
Request: Send a blank email to php-notes+get-44049@lists.php.net to get a copy of this message
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>'. '<br></br>'. '<br></br>'. '<br></br>'. '<br></br>'. '<br></br>'. '<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>'. '<br></br>'. '<br></br>'. '<br></br>'. '<br></br>'. '<br></br>'. '</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); ?> -- http://www.php.net/manual/en/function.domxml-xslt-stylesheet.php http://master.php.net/manage/user-notes.php?action=edit+29521 http://master.php.net/manage/user-notes.php?action=delete+29521 http://master.php.net/manage/user-notes.php?action=reject+29521

« previous php.notes (#44049) next »