/**
  * @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 ezcDocumentDocbookToRstConverter();
     $created = $converter->convert($doc);
     $this->assertTrue($created instanceof ezcDocumentRst);
     // Store test file, to have something to compare on failure
     $tempDir = $this->createTempDir('docbook_rst_') . '/';
     file_put_contents($tempDir . basename($to), $text = $created->save());
     $this->assertTrue(($errors = $created->validateString($text)) === true, is_array($errors) ? implode(PHP_EOL, $errors) : 'Expected true');
     $this->assertEquals(file_get_contents($to), $text);
     // Remove tempdir, when nothing failed.
     $this->removeTempDir();
 }
Beispiel #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 ezcDocumentDocbookToRstConverter();
     $converter->options->errorReporting = $this->options->errorReporting;
     $this->contents = $converter->convert($document)->save();
 }
<?php

require 'tutorial_autoload.php';
$docbook = new ezcDocumentDocbook();
$docbook->loadFile('address.xml');
class myAddressElementHandler extends ezcDocumentDocbookToRstBaseHandler
{
    public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root)
    {
        $root .= $this->renderDirective('address', $node->textContent, array());
        return $root;
    }
}
$converter = new ezcDocumentDocbookToRstConverter();
$converter->setElementHandler('docbook', 'address', new myAddressElementHandler());
$rst = $converter->convert($docbook);
echo $rst->save();
Beispiel #4
0
function fodt2text($filename,$id) {    
    Env::useLibrary('ezcomponents');
    
    $odt = new ezcDocumentOdt();
    $odt->loadFile( $filename );

    $docbook = $odt->getAsDocbook();

    $converter = new ezcDocumentDocbookToRstConverter();
    $rst = $converter->convert( $docbook );
    
    $file_path_txt = 'tmp/fodt2text_' . $id . '.txt';
    file_put_contents( $file_path_txt, $rst );
    $content = file_get_contents($file_path_txt); //Guardamos archivo.txt en $archivo
    unlink($file_path_txt);
    return $content;
}
Beispiel #5
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 ezcDocumentDocbookToRstConverter();
     $converter->options->errorReporting = $this->options->errorReporting;
     $this->contents = $converter->convert($document)->save();
 }