Help - Search - Member List - Calendar
Full Version: Php / Xslt Et Xml
OpenSpace > Zone Ordinateurs > Programmation
Guepi
Salut tous !

Voilà, je n'arrive pas à faire fonctionner ce fichu XSLT ( Sablotron ) ( exemples chopés dans le Linux Magazine n°51 )

J'ai un fichier XML en entrée :
CODE
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.1/EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<body>
<h1>Accueil</h1>
<p>
 Ceci est la super page de <b>monprog</b>
</p>
</body>


J'ai un fichier xsl en traitement :
CODE

<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
 encoding="iso-8859-1"
 doctype-public="-//W3C/DTD HTML 4.0 Transitional/EN"
 doctype-system="http://www.w3.org/TR/REC-html40/loose.dtd"
 indent="yes"
 />
<xsl:template match="/body">
 <html>
  <xsl:comment>
   This web site is (c) 2003 Me
   Feel free to get inspiration from this site, as soon as you leave this comment here

   THIS PAGE WAS AUTOMATICALLY GENERATED FROM TEMPLATES.
   DO NOT MODIFY ANYTHING IN THIS FILE: IT WILL BE OVERWRITTEN AND ANY CHANGE WILL BE LOST
  </xsl:comment>
  <head>
   <link rel="stylesheet" type="text/css" href="monprog.css" />
   <title><xsl:apply-templates select="/body/h1[position()=1]/*"/></title>
   </head>
   <body>
    <xsl:apply-templates select="@*/node()"/>
   </body>
  </html>
  </xsl:template>
  <xsl:template match="@*/node()">
   <xsl:copy>
    <xsl:apply-templates select="@*/node()"/>
   </xsl:copy>
  </xsl:template>
  </xsl:stylesheet>


et mon fichier PHP qui devrait m'afficher le résultat ...
CODE

<?php
chdir("C:/program files/easyphp/www/test/xml/");
$xmldata='file://home1.xml';
$xsl='file://main1.xsl';

xslt_create();
xslt_process($xsl, $xmldata, $html);
print $html;
?>


Je fais appel à vous pour me filer un petit coup de main ... histoire que je voit ce qui cloche.

Merci !
chon
C'est quelle version du Sablotron que tu utilises ?
Je vais essayer de voir ça de mon côté, pas facile mais je vais essayer ...



Gfx
http://jext.free.fr/progx.tgz j'ai fait un beau fichier include/ pour gérer ça en PHP avec un cache :-)
Guepi
je regarde ça Gfx smile.gif

Merci chon !
Cependant, je ne sais pas comment trouver ma version du Sablotron ...
Guepi
La doc de la fonction xslt_process() n'a pas été traduite en français.
d'où mon petit soucis smile.gif

Je vais voir ça de suite !!! happy.gif
Guepi
Bon, je ne pas encore pigé le coup des arguments et des paramètres ...

/me devrait peut-être investir dans un livre, genre : XML in a nutshell ou bien XSLT

chon
Personnellement, j'utilise cooktop pour tester mes scripts XLST sur des pages XML. Ca marche pas trop mal. wink.gif



This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.