1--TEST--
2Import of namespace-conflicting attributes
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\XMLDocument::createEmpty();
9$root = $dom->appendChild($dom->createElement('root'));
10
11$root->setAttributeNS("urn:a", "a:root1", "bar");
12$root1 = $root->getAttributeNodeNS("urn:a", "root1");
13$root->setAttributeNS("urn:b", "a:root2", "bar");
14$root2 = $root->getAttributeNodeNS("urn:b", "root2");
15
16$child = $root->appendChild($dom->createElement("child"));
17$child->setAttributeNS("urn:x", "a:child1", "bar");
18$child1 = $child->getAttributeNodeNS("urn:x", "child1");
19
20echo $dom->saveXml(), "\n";
21
22var_dump($root1->prefix, $root1->namespaceURI);
23var_dump($root2->prefix, $root2->namespaceURI);
24
25$child->removeAttribute("a:child1");
26$root->setAttributeNodeNS($child1);
27
28$importer = Dom\XMLDocument::createEmpty();
29$imported = $importer->importNode($root, true);
30echo $importer->saveXml($imported), "\n";
31
32var_dump($imported->getAttributeNodeNS("urn:a", "root1")->prefix);
33var_dump($imported->getAttributeNodeNS("urn:a", "root1")->namespaceURI);
34var_dump($imported->getAttributeNodeNS("urn:b", "root2")->prefix);
35var_dump($imported->getAttributeNodeNS("urn:b", "root2")->namespaceURI);
36var_dump($imported->getAttributeNodeNS("urn:x", "child1")->prefix);
37var_dump($imported->getAttributeNodeNS("urn:x", "child1")->namespaceURI);
38
39?>
40--EXPECT--
41<?xml version="1.0" encoding="UTF-8"?>
42<root xmlns:a="urn:a" a:root1="bar" xmlns:ns1="urn:b" ns1:root2="bar"><child xmlns:a="urn:x" a:child1="bar"/></root>
43string(1) "a"
44string(5) "urn:a"
45string(1) "a"
46string(5) "urn:b"
47<root xmlns:a="urn:a" a:root1="bar" xmlns:ns1="urn:b" ns1:root2="bar" xmlns:ns2="urn:x" ns2:child1="bar"><child/></root>
48string(1) "a"
49string(5) "urn:a"
50string(1) "a"
51string(5) "urn:b"
52string(1) "a"
53string(5) "urn:x"
54