/** * Transform current node and return the result * * Will take advantage of {@link http://pecl.php.net/package/xslcache PECL's xslcache} * if available * * @param string $filepath Path to stylesheet * @param bool $use_xslcache If TRUE, use the XSL Cache extension if available * * @return string Result * @throws RokCommon_Exception */ public function XSLT($filepath, $use_xslcache = true) { if (!extension_loaded('xsl')) { throw new RokCommon_Exception('XSL PHP extension is not loaded. Unable to use XSLT Function.'); } if ($use_xslcache && extension_loaded('xslcache')) { $xslt = new XSLTCache(); $xslt->importStylesheet($filepath); } else { $xsl = new DOMDocument(); $xsl->load($filepath); $xslt = new XSLTProcessor(); $xslt->importStylesheet($xsl); } return $xslt->transformToXML(dom_import_simplexml($this)); }
/** * Transform current node and return the result * * Will take advantage of {@link http://pecl.php.net/package/xslcache PECL's xslcache} * if available * * @param string $filepath Path to stylesheet * @param bool $use_xslcache If TRUE, use the XSL Cache extension if available * @return string Result */ public function XSLT($filepath, $use_xslcache = true) { if ($use_xslcache && extension_loaded('xslcache')) { $xslt = new XSLTCache(); $xslt->importStylesheet($filepath); } else { $xsl = new DOMDocument(); $xsl->load($filepath); $xslt = new XSLTProcessor(); $xslt->importStylesheet($xsl); } return $xslt->transformToXML(dom_import_simplexml($this)); }
/** * * * @param Transformation $transformation * * @return \XSLTCache|\XSLTProcessor */ protected function getXslProcessor(Transformation $transformation) { $xslTemplatePath = $transformation->getSourceAsPath(); $this->logger->debug('Loading XSL template: ' . $xslTemplatePath); if (!file_exists($xslTemplatePath)) { throw new Exception('Unable to find XSL template "' . $xslTemplatePath . '"'); } if (extension_loaded('xslcache')) { $proc = new \XSLTCache(); $proc->importStyleSheet($xslTemplatePath, true); return $proc; } else { $xsl = new \DOMDocument(); $xsl->load($xslTemplatePath); $proc = new \XSLTProcessor(); $proc->importStyleSheet($xsl); return $proc; } }