Page 1 of 1

Using XSL : undefined function: xslt_process()

Posted: Sat Feb 01, 2003 8:16 am
by Haryon
I'm trying to use XML and XSL from PHP.

1/ I used PHP 4.3.0.
--> couldn't load the extension php_domxml.dll and xstl extensions.
I found somewhere in the Zend site that 4.3.0 just can't load the XML extension :(
So I installed php 4.2.0

2/ Using PHP 4.2.0
I have that uncommented only in the extensions.
extension=php_domxml.dll
extension=php_xslt.dll
I'm under windows (and my server is apache). Everything is local.

My code is :

Code: Select all

<?php

// store XML and XSL content as variables
$xmlstring = join('', file('page.xml'));
$xslstring = join('', file('fod.xsl'));

// call the XSLT processor directly
xslt_process($xslstring, $xmlstring, $result);

// output the result
echo $result;
?>
and I get the following error :
Fatal error: Call to undefined function: xslt_process() in D:\Dev\htdocs\xmltest.php on line 8

I tried using xslt_create and it does (as I expected it) the same.

Code: Select all

// the files
$xmlfile = "page.xml";
$xslfile = "fod.xsl";

// create the XSLT processor
$xslthandler = xslt_create() or die("No XSLT handler available.");

// process the two files to get the desired output
xslt_run($xslthandler, $xslfile, $xmlfile);

// get and print the result
echo xslt_fetch_result($xslthandler);

// free the resources occupied by the handlers
xslt_free($xslthandler);
?>
Fatal error: Call to undefined function: xslt_create() in D:\Dev\htdocs\xmltest.php on line 18

If I understood right Sablotron or whatever should be integrated with PHP 4 and over.

Can I have guidelines as where I missed something ? ty.

PS : I don't think it's the extension php.ini parameter which fails, because I have 'can't find extension blabla.dll' if I modify the extension_dir to a wrong one, for example.

thank you in advance.

Posted: Sat Feb 01, 2003 11:15 am
by DeGauss
Silly questions:

1) Are the dlls in the right directory?

2) If they are, did you restart apache after you made changes to the php.ini?

Posted: Sat Feb 01, 2003 11:24 am
by Stoker
..and does phpinfo() list XSLT and sablotron?

In the days of 4.0.x and 4.1.x on Posix platforms I had oddities and difficulties compiling php with XSLT and Sablotron, and there was great confusion of what configure options where the right ones to use... At some point, the syntax for some functions changed and was not documented, I don't recall all the details just that I had several oddities.. Now i am just using Debian's packages with removes all pain of managing having the correct versions of everything myself :8

Posted: Sat Feb 01, 2003 12:33 pm
by Haryon
Yeah, configuring the stuff is a pain. You can find tons of article telling you how easy, how good, how whatever else, php/xml is, how powerful sablotron is etc. but you can't find a bloody simple documentation to tell you what you have to do exactly.

For the location of the extensions, yes they are in the right directory. As I wrote above I tried to change the extensions directory and I get a complete different message. It stops phpinfo() from running. I checked again now and my extensions are in the right directory.

PhpInfo has no track of XSL, XSLT or Sablotron (CTRL+sab only gave one 'disable').

All I get is :
xml
XML Support active
XML Namespace Support active
EXPAT Version 1.95.2

then there is a section called wddx, and below a section called Additionnal Modules which is totally empty (the following section is Environment).

I'm not on Linux, while some things are way simple on Linux, some other of my activities requires or/and prefers Windows.

Posted: Sat Feb 01, 2003 1:15 pm
by Stoker
hmm that indicates your version has not been compiled with XSLT support, even if the module is not active it should show something about --enable something xslt in the configure string..

Posted: Sat Feb 01, 2003 2:28 pm
by Haryon
no I don't get the configure line.

here is what I get if I check a phpinfo() from a project on sourceforge (using linux)
Configure Command './configure' '--enable-safe-mode' '--enable-memory-limit=yes' '--disable-debug' '--with-gd' '--with-xml' '--with-mysql=/usr/local/mysql' '--with-ttf' '--with-dbm' '--with-gdbm' '--with-zlib' '--enable-track-vars' '--enable-sysvsem' '--enable-sysvshm' '--enable-shmop' '--with-apxs=/usr/local/apache/bin/apxs'
Configuration File (php.ini) Path /usr/local/lib/php.ini

This is what I get when I check on my local apache under windows.
Configuration File (php.ini) Path D:\Dev\Php\php.ini
but I have no "Configure Command" entry :(

Sourceforge is v4.1.2, mine is 4.2.3 so I can't say :(

Posted: Sat Feb 01, 2003 3:20 pm
by Stoker
oh, that's whaty I ment, the configure options used as showed in phpinfo().. if that doesnt show any --enable or --with something XSLT it has not been compiled with the extensions, so yours appears so...

Posted: Sun Feb 02, 2003 4:48 am
by Haryon
What I mean, is not that the configure option doesn't show --enable, but rather that it doesn't show at all.

I'm thinking this is specific to the windows plateform since I couldn't find a configure.exe in my php binaries :(

Posted: Sun Feb 02, 2003 5:17 am
by volka
you should have php_xslt.dll and php_domxml.dll in your extension directory. If you want to enable xslt and xml make sure that sablot.dll and expat.dll can be found by your system either by copying them to your system directory or adding the path to the PATH-enviroment setting. This (and of course loading the extension) was all I had to do to enable it.