Exemple #1
0
 /**
  * Create document from docbook document
  *
  * A document of the docbook format is provided and the internal document
  * structure should be created out of this.
  *
  * This method is required for all formats to have one central format, so
  * that each format can be compiled into each other format using docbook as
  * an intermediate format.
  *
  * You may of course just call an existing converter for this conversion.
  * 
  * @param ezcDocumentDocbook $document 
  * @return void
  */
 public function createFromDocbook(ezcDocumentDocbook $document)
 {
     $converter = new ezcDocumentDocbookToEzXmlConverter();
     $converter->options->errorReporting = $this->options->errorReporting;
     $doc = $converter->convert($document);
     $this->document = $doc->getDomDocument();
 }
Exemple #2
0
 /**
  * Create document from docbook document
  *
  * A document of the docbook format is provided and the internal document
  * structure should be created out of this.
  *
  * This method is required for all formats to have one central format, so
  * that each format can be compiled into each other format using docbook as
  * an intermediate format.
  *
  * You may of course just call an existing converter for this conversion.
  *
  * @param ezcDocumentDocbook $document
  * @return void
  */
 public function createFromDocbook(ezcDocumentDocbook $document)
 {
     if ($this->options->validate && $document->validateString($document) !== true) {
         $this->triggerError(E_WARNING, "You try to convert an invalid docbook document. This may lead to invalid output.");
     }
     $this->path = $document->getPath();
     $converter = new ezcDocumentDocbookToEzXmlConverter();
     $converter->options->errorReporting = $this->options->errorReporting;
     $doc = $converter->convert($document);
     $this->document = $doc->getDomDocument();
 }
 /**
  * @dataProvider getTestDocuments
  */
 public function testLoadXmlDocumentFromFile($from, $to)
 {
     if (!is_file($to)) {
         $this->markTestSkipped("Comparision file '{$to}' not yet defined.");
     }
     $doc = new ezcDocumentDocbook();
     $doc->loadFile($from);
     $converter = new ezcDocumentDocbookToEzXmlConverter();
     $created = $converter->convert($doc);
     $this->assertTrue($created instanceof ezcDocumentEzXml, 'Not of expected document type ezcDocumentEzXml,');
     // Store test file, to have something to compare on failure
     $tempDir = $this->createTempDir('docbook_ezxml_custom_') . '/';
     file_put_contents($tempDir . basename($to), $xml = $created->save());
     $this->assertTrue(($errors = $created->validateString($xml)) === true, is_array($errors) ? implode(PHP_EOL, $errors) : 'Expected true');
     $this->assertEquals(file_get_contents($to), $xml);
     // Remove tempdir, when nothing failed.
     $this->removeTempDir();
 }