Jump to content

PHP in XSL document


vchris

Recommended Posts

This is getting weirder by the second :) .Start tag... hmm... could it be....:

$xml = new DomDocument(file_get_contents($xmlFile));

and of course:

$xsl = new DomDocument(file_get_contents($xsltFile));

Remove the if's and die's below those.I wouldn't be surprised if that doesn't work, but right now, everything seems to be odd.To be exact, the DOM implementation that your host is using is odd. Custom built perhaps?

Link to comment
Share on other sites

You mean like this? If so I got Fatal error: Cannot instantiate non-existent class: xsltprocessor in...

//Prepare the XML file			$xml = new DomDocument(file_get_contents($xmlFile));			/*$xml = new DomDocument('1.0');			if (!$xml->loadXML(file_get_contents($xmlFile))) {			die('XML file at "' . $xmlFile . '" is not well-formed');			}*/			//Prepare the XSLT file			$xsl = new DomDocument(file_get_contents($xsltFile));			/*$xsl = new DomDocument('1.0');			if (!$xsl->loadXML(file_get_contents($xsltFile))) {			die('XSLT file at "' . $xsltFile . '" is not well-formed');			}*/

Link to comment
Share on other sites

Yes. That is what I meant, and it seems the files are finally loaded as they should, but that last error... it is as if your XSLT processor is actually disabled or simply not started this way. I guess you'll need to ask your host how to construct the XSLTprocessor class if not with the method described in the PHP manual.One possible solution would be to enable it yourself with dl(). However, it is unclear what is the filename you need. On windows it's "php_xsl.dll", but scince the server is on a UNIX based environment, it could be almost anything. Besides, if it's already loaded, this won't help.

Link to comment
Share on other sites

OK. It's been a week, so I've gone curious. What happened? Did you asked the host? What did they say?

Link to comment
Share on other sites

Yeah I asked the host but they didn't reply... It's been a week since I emailed them... Usually they're very fast to reply. I'm sending another email.

Link to comment
Share on other sites

Finally got a response:

Chris,Sorry for the slow response, I had to do some research myself on this one.It appears to me that xml support is already compiled in:php -m
bcmathbz2calendarctypecurldbadbxdiodomxmlexifftpgdgettextgmpiconvimapldapmbstringmime_magicmysqlncursesodbcopenssloverloadpcntlpcrepgsqlposixpspellsessionshmopsnmpsocketsstandardsysvsemsysvshmtokenizerwddxxmlxmlrpcypZend OptimizerzlibI put a php file in your site (http://www.vchris.net/xslt.php) that doesnothing more than instantiate an xslt processor and then free it. It doesn'tgive any errors. You should test further by trying to use it.http://us2.php.net/manual/en/function.xslt-create.phpTomUnderstand anything?
Link to comment
Share on other sites

Yup. Got it all. They're using the PHP4 XSLT processor API. If what you see in phpinfo() is true, this means libxslt is used with Salbotron's (PHP4's XSLT processor) API. If not, then Salbotron is used with PHP5, which though kind'a odd is still possible.The link from the PHP manual they are showing you is a sample code that you should use to get the XSLT processor running. It reduces all to a single function call with the XML and XSLT file as arguments. Try it, after adding this function call to it:

xml2html('gallery.xml','gallery.xsl');

What's in xslt.php btw? At the time of writing, it doesn't return any errors, but it doesn't also return any output (a default HTML instead), which could mean there's still an error in the PHP file. Either that, or the function call above is just missing resulting in no real content.That's all kind'a dissapoining though. With PHP5's API, you have more freedom and possibilities over the whole thing. Oh well, for testing, you won't need much.P.S. If there comes a need for another mail, having XML support compiled in is different then having XSL (libxslt) or XSLT (Salbotron) support being compiled in. Also, if you haven't, show him a link to this page, as I believe I have some good stuff for them here :) . I mean, their build is just odd.

Link to comment
Share on other sites

Haha. Without actually setting display_errors to On, there's no proof all of that works. Anyhow, try this:

<?php//Turn on error display.ini_set('display_errors','On');ini_set('error_reporting',1);//Prepare the variables.$xsltFile = "test.xsl";$xmlFile = "test.xml";//Load the XSLT processor$engine = xslt_create();$args = array();//Execute the transformation$output = xslt_process($engine, $xmlFile, $xsltFile, NULL, NULL, $args);//Show the transformation in the browser.print $output;xslt_free($engine);?>

If it doesn't work... I believe there will be a need for another mail.

Link to comment
Share on other sites

I copied exactly the code above and I get this:

Fatal error: Call to undefined function: xslt_create() in /var/www/html/xslt.php on line 11
Was I suppose to create test.xml and test.xsl?
Link to comment
Share on other sites

I copied exactly the code above and I get this:Was I suppose to create test.xml and test.xsl?
Sorry. I use text.xml and test.xsl for default names in such cases. I forgot you have gallery.xml and gallery.xsl instead. Try it with your existing files in the same directory of course.If it still doesn't work (as I suppose it won't) you'll have to give another mail, and this time, tell that guy to turn on error display in the PHP file as we do.
Link to comment
Share on other sites

Same error.
Long live the email :) . And really, give a link to this page and tell him to turn on error display next time :) .
Link to comment
Share on other sites

  • 2 weeks later...

Still didn't get any response lol... I had an email problem but I'll try to send them the message again today.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...