forzatio Posted February 25, 2007 Share Posted February 25, 2007 Hi there, I want to process a sample xml file with its xsl, when I run the script below it gives me. Fatal error: Call to undefined function xslt_create() I looked up in phpinfo to see if xsl is enabled (it is) still with multiple variations of the code I always get the undefined function. I'm using xampp php5 on windows xp pro. <?php // Allocate a new XSLT processor $xh = xslt_create(); // Process the document if (xslt_process($xh, 'sample.xml', 'sample.xsl', 'result.html')) { print "SUCCESS, sample.xml was transformed by sample.xsl into result.html"; print ", result.html has the following contents <br>"; print "<pre>"; readfile('result.html'); print "</pre>"; } else { print "Sorry, sample.xml could not be transformed by sample.xsl into"; print " result.html the reason is that " . xslt_error($xh) . " and the "; print "error code is " . xslt_errno($xh); } xslt_free($xh); ?> how could I fix the above problem or else transform the xml with it's xslt another way. Link to comment https://forums.phpfreaks.com/topic/40019-xslt-undefined-function-still-its-enabled/ Share on other sites More sharing options...
forzatio Posted February 25, 2007 Author Share Posted February 25, 2007 I found some useful information about XSL and PHP here: http://devzone.zend.com/node/view/id/1713/ <?php $xp = new XsltProcessor(); // create a DOM document and load the XSL stylesheet $xsl = new DomDocument; $xsl->load('cdcatalog.xsl'); // import the XSL stylesheet into the XSLT process $xp->importStylesheet($xsl); // create a DOM document and load the XML data $xml_doc = new DomDocument; $xml_doc->load('cdcatalog.xml'); // transform the XML into HTML using the XSL file if ($html = $xp->transformToXML($xml_doc)) { echo $html; } else { trigger_error('XSL transformation failed.', E_USER_ERROR); } // if ?> This code works fine for the transformation. Link to comment https://forums.phpfreaks.com/topic/40019-xslt-undefined-function-still-its-enabled/#findComment-193558 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.