コード例 #1
0
ファイル: XMLVisitorTest.php プロジェクト: sysvyz/anan
 public function testRender2()
 {
     $node = Tree::mult(Tree::add('x', 67), Tree::pow(Tree::mult('x', Tree::mult(4, 'x'), Tree::add(Tree::mult('x', 67), Tree::pow(Tree::mult('x', 24), 2))), 2));
     $xml = XMLVisitor::init();
     $str = $xml->visit($node);
     echo $str;
     $xml = new \DOMDocument();
     $xml->loadXML($str);
     $this->assertTrue($xml->schemaValidate(__DIR__ . '/../../../resources/tree-schema.xsd'));
 }
コード例 #2
0
ファイル: XMLVisitor.php プロジェクト: sysvyz/anan
 public function visitPowerNode(PowerNode $node)
 {
     $v = new XMLVisitor($this->depth + 3);
     return $this->_renderNode($this->_indent($this->depth + 1) . '<power>' . PHP_EOL . $this->_indent($this->depth + 2) . '<base>' . PHP_EOL . $v->visit($node->getBase()) . PHP_EOL . $this->_indent($this->depth + 2) . '</base>' . PHP_EOL . $this->_indent($this->depth + 2) . '<exponent>' . PHP_EOL . $v->visit($node->getExponent()) . PHP_EOL . $this->_indent($this->depth + 2) . '</exponent>' . PHP_EOL . $this->_indent($this->depth + 1) . '</power>');
 }