static function __static()
 {
     self::$instance = new self();
 }
 /**
  * Run the XSL transformation
  *
  * @return  bool success
  * @throws  xml.TransformerException
  */
 public function run()
 {
     libxml_get_last_error() && libxml_clear_errors();
     $this->processor = new XSLTProcessor();
     $this->processor->importStyleSheet($this->stylesheet);
     $this->processor->setParameter('', $this->params);
     // If we have registered instances, register them in XSLCallback
     if (sizeof($this->_instances)) {
         $cb = XSLCallback::getInstance();
         foreach ($this->_instances as $name => $instance) {
             $cb->registerInstance($name, $instance);
         }
     }
     $this->processor->registerPHPFunctions(array('XSLCallback::invoke'));
     if (NULL === ($this->outputEncoding = $this->determineOutputEncoding($this->stylesheet->documentElement, $this->baseURI))) {
         $this->outputEncoding = 'utf-8';
         // Use default
     }
     // Start transformation
     $this->output = $this->processor->transformToXML($this->document);
     // Perform cleanup when necessary (free singleton for further use)
     sizeof($this->_instances) && XSLCallback::getInstance()->clearInstances();
     // Check for transformation errors
     if (FALSE === $this->output) {
         // Check for errors, also non-fatal errors, otherwise indicate unknown
         // transformation error
         $this->_checkErrors(NULL, TRUE);
         throw new TransformerException('Unknown XSL transformation error while transforming ' . $this->baseURI);
     }
     // Check for left-over errors that did not make the transformation fail
     $this->_checkErrors('<transformation>');
     return TRUE;
 }