public function testDocumentStringValidationErrors()
 {
     $xhtml = new ezcDocumentXhtml();
     $errors = $xhtml->validateString(file_get_contents(dirname(__FILE__) . '/files/xhtml/validation/invalid_markup.html'));
     $this->assertTrue(is_array($errors), 'Expected an array of errors to be returned');
     $this->assertTrue($errors[0] instanceof ezcDocumentValidationError, 'Expected an array of ezcDocumentValidationError objects to be returned');
     $this->assertSame(10, count($errors), 'Expected three errors to be found in validated document.');
     $this->assertTrue($errors[0]->getOriginalError() instanceof LibXMLError, 'Expected an array of LibXMLError objects to be returned');
     $this->assertSame('Fatal error in 38:7: Opening and ending tag mismatch: a line 36 and h1.', (string) $errors[0]);
 }
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
        $this->links = array();
        // Append directive targets to paragraph
        foreach ($this->directives as $directive) {
            $root .= $directive;
            $appended = true;
        }
        $this->directives = array();
        return $root . ($appended ? "\n" : '');
    }
}
$ext = new ReflectionExtension('xdebug');
ksort($settings);
echo "; This is a generated file, do not modify by hand\n\n";
foreach ($settings as $name => $info) {
    $w = str_repeat('-', 77);
    $xhtml = new ezcDocumentXhtml();
    $xhtml->loadString(ignore_links($info[3]));
    $docbook = $xhtml->getAsDocbook();
    // echo $docbook->save(), "\n\n";
    $convertor = new drDocumentDoctookToTextConvertor();
    $rst = $convertor->convert($docbook);
    $d = $rst->save();
    $d = join("\n; ", explode("\n", $d));
    echo <<<ENDL
; {$w}
; xdebug.{$name}
;
; Type: {$info[0]}, Default value: {$info[1]}
;
; {$d}
;
 /**
  * @dataProvider getTestDocuments
  */
 public function testCommonConversions($from, $to)
 {
     if (!is_file($to)) {
         $this->markTestSkipped("Comparision file '{$to}' not yet defined.");
     }
     $document = new ezcDocumentXhtml();
     $document->setFilters(array(new ezcDocumentXhtmlElementFilter(), new ezcDocumentXhtmlMetadataFilter(), new ezcDocumentXhtmlTablesFilter()));
     $document->loadFile($from);
     $docbook = $document->getAsDocbook();
     $xml = $docbook->save();
     // Store test file, to have something to compare on failure
     $tempDir = $this->createTempDir('xhtml_tests_') . '/';
     file_put_contents($tempDir . basename($to), $xml);
     $this->assertTrue($docbook->validateString($xml));
     $this->assertEquals(file_get_contents($to), $xml, 'Document not visited as expected.');
     // Remove tempdir, when nothing failed.
     $this->removeTempDir();
 }
Example #5
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 #6
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;
 }
<?php

require 'tutorial_autoload.php';
$xhtml = new ezcDocumentXhtml();
$xhtml->setFilters(array(new ezcDocumentXhtmlElementFilter(), new ezcDocumentXhtmlMetadataFilter(), new ezcDocumentXhtmlXpathFilter('//div[@class="document"]')));
$xhtml->loadFile('ez_components_introduction.html');
$docbook = $xhtml->getAsDocbook();
echo $docbook->save();
Example #8
0
<?php

require 'tutorial_autoload.php';
$xhtml = new ezcDocumentXhtml();
$xhtml->loadFile('ez_components_introduction.html');
$docbook = $xhtml->getAsDocbook();
echo $docbook->save();
Example #9
0
<?php

require 'tutorial_autoload.php';
$docbook = new ezcDocumentDocbook();
$docbook->loadFile('docbook.xml');
$html = new ezcDocumentXhtml();
$html->createFromDocbook($docbook);
echo $html->save();