How PHP can be annoying

On a PHP 4 project, I need to use XSLT, but the interfaces seem far more complicated than they should be. Check out this declaration for the function to run an XSLT:

mixed xslt_process ( resource xh, string xmlcontainer, string xslcontainer [, string resultcontainer [, array arguments [, array parameters]]] )

Wow, it returns a “mixed”, that’s some helpful documentation worth looking up. And all I have to do is pass in an “xmlcontainer” and “xslcontainer”. In practice, you end up with hard-to-read code like this:

$arguments = array('/_xml' => $xml, '/_xsl' => $xsl);
$xslproc = $xslt_create();
$result = xslt_process($xslproc, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);

Too bad I have already-parsed objects. And then there’s this:

Warning: As of PHP 4.0.6, this function no longer takes XML strings in xmlcontainer or xslcontainer. Passing a string containing XML to either of these parameters will result in a segmentation fault in Sablotron versions up to and including version 0.95.

Whatever. In fairness, this falls mainly to the XSLT engine and not the language and the PHP 5 interfaces are much different and much improved. But still.. -m

Comments are closed.