2 // This file adds xslt_xxx emulation functions.
3 // It is intended for systems, e.g. those running PHP 5, where:
4 // 1) The XSLT library is not installed.
5 // 2) The XSL library is installed.
7 // Note that not everything is implemented.
8 // In particular, only the bare minimum to support the BB conversion is here.
10 // This silliness is required to prevent PHP from evaluating the function() blocks before processing the return;s
14 if(function_exists('xslt_create')) return; // xslt_create() already exists, so emulation isn't needed.
15 if(!class_exists('XSLTProcessor')) return; // There is no XSLTProcessor class, so emulation isn't possible.
16 if(!class_exists('DOMDocument')) return; // There is no DOMDocument class, so emulation isn't possible.
20 function xslt_create() {
21 return new XSLTProcessor();
24 // We don't support arguments or parameters because the Bb import doesn't use them
25 function xslt_process($proc, $xmlfile, $xslfile, $resultfile = null, $unsupported_args = null, $unsupported_params = null) {
26 $doc = new DOMDocument;
28 $xsl = new DOMDocument;
30 $proc->importStylesheet($xsl);
32 // Squash warnings here because xsl complains about COURSE_ACCESS tags which really are invalid XML (multiple root elements)
33 if($resultfile !== null) {
34 $fp = fopen($resultfile, 'w');
35 fwrite($fp, @$proc->transformToXML($doc));
39 return @$proc->transformToXML($doc);