Exemplo n.º 1
0
 public function testDefaultEmptyNamespace()
 {
     $dom = $this->getTestDomWithoutRootNamespace();
     $source = new Source\XPath(new Source\Pointer\XPath('/root/bar:a', array('bar' => $this->barNamespace)), $dom);
     $this->assertEquals(1, $source->getData()->length);
     $this->assertEquals('a', $source->getFirstNode()->nodeName);
 }
Exemplo n.º 2
0
 /**
  * Extracts DOMNodeList from any kind of DOM objects
  *
  * @param $DOMObject
  * @param \DOMElement|\DOMNode|\DOMNodeList|\DomDocument $DOMObject
  * @throws \MDA\DDU\Exception
  * @return \DOMNodeList
  */
 public static function extract($DOMObject)
 {
     if ($DOMObject instanceof \DOMNodeList) {
         return $DOMObject;
     } elseif ($DOMObject instanceof \DOMDocument) {
         return $DOMObject->childNodes;
     } elseif ($DOMObject instanceof \DOMNode) {
         return Source\XPath::create(new Source\Pointer\XPath('.'), $DOMObject)->getData();
     }
     throw new Exception(Exception::ERR_UNSUPPORTED_DOM_OBJECT);
 }
Exemplo n.º 3
0
 public function testXpathWithNodeNamespace()
 {
     $defaultNamespace = 'http://foo';
     $nestedNamespace = 'http://bar';
     $value = array('table' => array('@attr' => array('xmlns' => $defaultNamespace, 'xmlns:test' => $nestedNamespace), 'test:row' => array()));
     $dom = ToDOM::extract($value);
     $this->assertEquals('row', DOM\Source\XPath::create(new DOM\Source\Pointer\XPath('/xmlns:table/test:row', array('test' => $nestedNamespace)), $dom)->getFirstNode()->localName);
 }