Example #1
0
 /**
  * Build document
  *
  * Build document of appropriate type from the DOMDocument, created by the
  * XSLT transformation.
  *
  * @param DOMDocument $document
  * @return ezcDocumentXmlBase
  */
 protected function buildDocument(DOMDocument $document)
 {
     $doc = new ezcDocumentXhtml();
     $doc->setDomDocument($document);
     return $doc;
 }
Example #2
0
 /**
  * Create document from structure
  *
  * Build a ezcDocumentDocument object from the structure created during the
  * visiting process.
  *
  * @param mixed $content
  * @return ezcDocumentDocument
  */
 protected function createDocument($content)
 {
     $document = $content->ownerDocument;
     $this->appendFootnotes($content);
     // Ensure a title is set in the document header, as this is required by
     // XHtml
     $xpath = new DOMXPath($document);
     $title = $xpath->query('/*[local-name() = "html"]/*[local-name() = "head"]/*[local-name() = "title"]');
     if ($title->length < 1) {
         $title = $document->createElement('title', 'Empty document');
         $this->head->appendChild($title);
     }
     $html = new ezcDocumentXhtml();
     $html->setDomDocument($document);
     return $html;
 }
Example #3
0
 /**
  * Return document compiled to the HTML format
  *
  * The internal document structure is compiled to the HTML format and the
  * resulting HTML document is returned.
  *
  * This is an optional interface for document markup languages which
  * support a direct transformation to HTML as a shortcut.
  *
  * @return ezcDocumentXhtml
  */
 public function getAsXhtml()
 {
     $tokenizer = new ezcDocumentRstTokenizer();
     $parser = new ezcDocumentRstParser();
     $parser->options->errorReporting = $this->options->errorReporting;
     $this->ast = $parser->parse($tokenizer->tokenizeString($this->contents));
     $document = new ezcDocumentXhtml();
     $visitorClass = $this->options->xhtmlVisitor;
     $visitor = new $visitorClass($this, $this->path);
     $visitor->options = $this->options->xhtmlVisitorOptions;
     $document->setDomDocument($visitor->visit($this->ast, $this->path));
     // Merge errors from converter
     $this->errors = array_merge($this->errors, $parser->getErrors(), $visitor->getErrors());
     return $document;
 }