I'm not an expert in PHP, I prefer classic PHP or asp.NET, but I've tried to do xml/xsl transformations in as many languages as possible - and PHP seems to about the worst option.
First problem - PHP uses an "add-on" xsl processor called Sablotron, with which you need to compile PHP if you're running your own server. If you're using shared hosting you might find that its there, you might find that it isn't it's worth checking if you're setting up a new account.
Second problem - ASP, JSP, Perl, asp.NET can all create XML objects. PHP can't, so the standard method/hack of pulling a remote XML source seems to be to write a script which writes the XML to a local file, then use Sablotron to read the file.
Try the following code
<?php
$open = fopen("
"r");
$xmlstring = fread($open, 10000);
fclose($open);
$fp = fopen ("./localsource.xml", "w");
fputs ($fp, $xmlstring, strlen($xmlstring));
fclose ($fp);
?>
<?php
$xh = xslt_create();
$result = xslt_process($xh, 'localsource.xml', 'transform.xsl');
if ($result) {
echo $result;
}
else {
echo xslt_error($xh);
}
xslt_free($xh);
?>
You'll probably need to create an empty file called localsource.xml and chmod it to 666.
Sometimes this script works, sometimes it falls over in the middle of writing the remote XML to the local file.
If anyone knows a better method then I'd like to know. Personally I've given up on PHP for this particular task, if I have to transform a remote source on a UNIX platform I use Perl.