public static function init($xslOptions)
 {
     self::$styles = array();
     self::$fontFaces = array();
     self::$listStyles = array();
     self::$xslOptions = $xslOptions;
 }
 /**
  * Converts the currently opened document to XHTML.
  *
  * This function does not modify the original document, but
  * modifications on the document will reflect on the result of
  * the conversion.
  *
  * You may want to call setXSLTransformation() and/or
  * setXSLOption() before calling this function to optimize the
  * result of the conversion for particular purposes.
  *
  * @param filename Filename of the resulting XHTML document.
  *
  * @return @c true if the document was successfully converted,
  *         @c false otherwise.
  *
  * @sa setXSLTransformation(), setXSLOption()
  */
 public function convertToXHTML($filename)
 {
     if ($this->filename == '') {
         trigger_error('No document was loaded for conversion to XHTML');
         return false;
     }
     $xslDocument = new DOMDocument();
     if ($xslDocument->load(LIBOPENDOCUMENT_PATH . "/xsl/{$this->xslTransformation}/document2xhtml.xsl") === false) {
         trigger_error('Could not open the selected XSL transformation');
         return false;
     }
     $xsltProcessor = new XSLTProcessor();
     if ($xsltProcessor->hasExsltSupport() == false) {
         trigger_error('EXSLT support in PHP is required for converting OpenDocument files');
         return false;
     }
     if ($this->package == false) {
         $sourceDocument = $this->metaDocument;
     } else {
         if ($this->xslOptions['export-objects'] == 'true') {
             $this->exportObjects(dirname($filename));
         }
         $preprocessXSLDocument = new DOMDocument();
         if (copy(LIBOPENDOCUMENT_PATH . "/xsl/package2document.xsl", "{$this->tmpdir}/package2document.xsl") === false || $preprocessXSLDocument->load("{$this->tmpdir}/package2document.xsl") === false) {
             trigger_error('Could not open the XSL transformation for pre-processing');
             return false;
         }
         $xsltProcessor->importStyleSheet($preprocessXSLDocument);
         $contentDocument = new DOMDocument();
         if ($contentDocument->load("{$this->tmpdir}/content.xml") == false) {
             trigger_error('Could not load content XML document');
             return false;
         }
         $xsltProcessor->setParameter('', 'mimetype', file_get_contents("{$this->tmpdir}/mimetype"));
         $sourceDocument = $xsltProcessor->transformToDoc($contentDocument);
         if ($sourceDocument === false) {
             trigger_error('Could not open source document');
             return false;
         }
         unlink("{$this->tmpdir}/package2document.xsl");
     }
     if (file_exists(LIBOPENDOCUMENT_PATH . "/xsl/{$this->xslTransformation}/document2xhtml.php") == true) {
         include_once LIBOPENDOCUMENT_PATH . "/xsl/{$this->xslTransformation}/document2xhtml.php";
         OpenDocument2XHTML::init($this->xslOptions);
         $xsltProcessor->registerPHPFunctions();
     }
     $xsltProcessor->importStyleSheet($xslDocument);
     foreach ($this->xslOptions as $key => $value) {
         $xsltProcessor->setParameter('', $key, $value);
     }
     if ($xsltProcessor->transformToURI($sourceDocument, $filename) == false) {
         trigger_error('XSL transformation failed to run');
         return false;
     }
     return true;
 }