Jump to content

xslt undefined function, still it's enabled


forzatio

Recommended Posts

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.