1--TEST--
2Reconciliation of 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$root->setAttributeNS("urn:a", "a:root3", "bar");
16$root3 = $root->getAttributeNodeNS("urn:a", "root3");
17
18$child = $root->appendChild($dom->createElement("child"));
19$child->setAttributeNS("urn:x", "a:child1", "bar");
20$child1 = $child->getAttributeNodeNS("urn:x", "child1");
21$child->setAttributeNS("urn:a", "a:child2", "bar");
22$child2 = $child->getAttributeNodeNS("urn:a", "child2");
23
24echo $dom->saveXml(), "\n";
25
26var_dump($root1->prefix, $root1->namespaceURI);
27var_dump($root2->prefix, $root2->namespaceURI);
28var_dump($root3->prefix, $root3->namespaceURI);
29
30$child->removeAttribute("a:child1");
31$root->setAttributeNodeNS($child1);
32
33var_dump($child1->prefix, $child1->namespaceURI);
34var_dump($child2->prefix, $child2->namespaceURI);
35
36echo $dom->saveXml(), "\n";
37
38?>
39--EXPECT--
40<?xml version="1.0" encoding="UTF-8"?>
41<root xmlns:a="urn:a" a:root1="bar" xmlns:ns1="urn:b" ns1:root2="bar" a:root3="bar"><child xmlns:a="urn:x" a:child1="bar" xmlns:ns2="urn:a" ns2:child2="bar"/></root>
42string(1) "a"
43string(5) "urn:a"
44string(1) "a"
45string(5) "urn:b"
46string(1) "a"
47string(5) "urn:a"
48string(1) "a"
49string(5) "urn:x"
50string(1) "a"
51string(5) "urn:a"
52<?xml version="1.0" encoding="UTF-8"?>
53<root xmlns:a="urn:a" a:root1="bar" xmlns:ns1="urn:b" ns1:root2="bar" a:root3="bar" xmlns:ns2="urn:x" ns2:child1="bar"><child a:child2="bar"/></root>
54