This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Re: PHP integration with XSLT


Hi dfour.
I appreciate your hint, I've solved the problem using a system a little 
bit different from yours, but equally functional!
Simply, I've made a PHP script (named, for example, OKFORALL.PHP), that 
read it's script name (in this case OKFORALL).
Then, with a simple httpClient function, the script sends and HTTP 
request to OKFORALL.XML, storing the response into a file named
OKFORALL.TMP.PHP. Obviously, the HTTP request send to the servlet engine 
(Tomcat with Cocoon in my case) is interpreted by the XSL transformator 
and produce a valid PHP file. At last, the script redirect to 
OKFORALL.TMP.PHP, and the web server run this as a PHP file.

I think that this method, similar to yours, is an example of bad IT 
programming style. The reasons is: 1st) I must call a PHP file instead 
of an XML file to run the PHP output produced by the XSL (isn't it an 
horrible programming style?); 2nd) the entire process is definitely too 
slow, and I can't use it on a production server!

>access from a php script the xml file (including the xslt stylesheet 
>declaration to transform it) thru an http fopen():
>$fp = fopen("http://yourserverpath/yourfile.xml";, "r");
>read it :
>while(!feof($fp)) $content .= fgets($fp, 1024);
>1024 is an arbitrary buffer size (NB: you can't use sizeof("yourfile.xml") 
>with a remote access)
>save it as a php file :
>$fp = fopen("yourtransformedfile.php", "w");
>fwrite($fp);
>fclose($fp);
>and load that file :
>header("Location: http://yourserverpath/yourtransformedfile.php";);
>
Thanks for all, but I want a simply method to: 1) request an XML file; 
2) transforming it with the related XSL document (server side by Cocoon) 
that produce a valid PHP file; 3) make it processed from Apache to 
execute the PHP script.

Isn't it simple? :)

Alessio Mazzieri


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]