public function testCustomeElementHandler() { $doc = new ezcDocumentDocbook(); $doc->loadFile(dirname(__FILE__) . '/files/docbook/rst/h_001_address.xml'); $converter = new ezcDocumentDocbookToRstConverter(); $converter->setElementHandler('docbook', 'address', new myAddressElementHandler()); $wiki = $converter->convert($doc); $this->assertSame($wiki->save(), file_get_contents(dirname(__FILE__) . '/files/docbook/rst/h_001_address.txt')); }
<?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();