Ejemplo n.º 1
0
 public function rootMember()
 {
     with($t = new Tree('formresult'), $r = $t->root());
     $this->assertClass($r, 'xml.Node');
     $this->assertFalse($r->hasChildren());
     $this->assertEmpty($r->getAttributes());
     $this->assertEquals('formresult', $r->getName());
 }
Ejemplo n.º 2
0
 /**
  * Returns an XML tree for use in further test cases
  *
  * @return  xml.Tree
  */
 protected function personTree()
 {
     $t = new Tree('person');
     $t->root()->setAttribute('id', '1549');
     $t->addChild(new Node('firstName', 'Timm'));
     $t->addChild(new Node('lastName', 'Friebe'));
     $t->addChild(new Node('location', 'Karlsruhe'));
     $t->addChild(new Node('location', 'Germany'));
     return $t;
 }
Ejemplo n.º 3
0
 /**
  * Marshal an object to xml
  *
  * @param   lang.Object instance
  * @param   xml.QName qname default NULL
  * @return  string xml
  * @deprecated  Use marshalTo() instead
  */
 public static function marshal($instance, $qname = NULL)
 {
     $class = $instance->getClass();
     // Create XML tree and root node. Use the information provided by the
     // qname argument if existant, use the class` non-qualified (and
     // lowercased) name otherwise.
     $tree = new Tree();
     if ($qname) {
         $prefix = $qname->prefix ? $qname->prefix : $qname->localpart[0];
         $tree->root()->setName($prefix . ':' . $qname->localpart);
         $tree->root()->setAttribute('xmlns:' . $prefix, $qname->namespace);
     } else {
         if ($class->hasAnnotation('xmlns')) {
             $tree->root()->setName($class->getSimpleName());
         } else {
             $tree->root()->setName(strtolower($class->getSimpleName()));
         }
     }
     self::recurse($instance, $class, $tree->root(), array());
     return $tree->getSource(INDENT_DEFAULT);
 }
 public function setXSLTree()
 {
     $t = new Tree('xsl:stylesheet');
     $t->root()->setAttribute('xmlns:xsl', 'http://www.w3.org/1999/XSL/Transform');
     $this->processor->setXSLTree($t);
 }