Пример #1
0
 public function testAlreadyExistentNamespacePrefix()
 {
     // Document has already a namespace prefixed as 'dt' (the default Xpath prefix, if not specified in construtor)
     // 'Namespaced' value should not be retrieved; its prefix
     //      will be the same as the already defined in the parents
     // 'Conflicting' should not be retrieved as well
     //      cause 'dt' will corresponds to two namespaces
     $dom_document = new Document('1.0', 'utf-8');
     $dom_document->loadXML('<any_container
             xmlns="http://berlinonline.net/trellis/1.0/schema"
             xmlns:on="urn:other:namespace"
             xmlns:dt="urn:conflicting:prefix:namespace">
             <dt:option name="types">
                 <option>Namespaced</option>
                 <on:option>OtherNamespace</on:option>
                 <dt:option>Conflicting</dt:option>
                 <option xmlns="">NonNamespaced</option>
             </dt:option>
         </any_container>');
     $xpath = new Xpath($dom_document);
     $xpath->registerNamespace('dt', 'urn:conflicting:prefix:namespace');
     $options_nodelist = $xpath->query('/any_container/dt:option/option', $dom_document->documentElement);
     $this->assertEquals(0, $options_nodelist->length);
 }