[wp-hackers] Shared Knowledge for Developers

Stephane Daury wordpress at tekartist.org
Wed Sep 5 23:55:57 GMT 2007

On Sep 05, 2007, at 13:10, Computer Guru wrote:

>> PHP 5 XSLT doesn't seem to like for PHP in the XML file, and if  
>> you can
>> fix this problem, then please I would like to see the code.

Note the code below is assuming you mean the PHP5/libxslt-based XSL  
features (not the older Sablotron-based ones)

That's because the XML is not pre-processed when loaded through  
DOMDocument (before being forked off to XSLTProcessor).

The only way to process an XML file with PHP in it (that I know of)  
is to use DOMDocument->loadXML() coupled with a file_get_contents()  
call on a URL, instead of DOMDocument->load() on a local file. That  
forces it to pass though httpd+php and your XSLT process therefore  
only gets the rendered output.

This said, it's obviously not the best performance, but I've used it  
once in the past and coupled with caching, it's not bad at all when  
you benchmark it against a similar DB query or so.


More information about the wp-hackers mailing list