1--TEST--
2Attribute entity expansion in a legacy document
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7$doc = new DOMDocument;
8$elt = $doc->createElement('elt');
9$doc->appendChild($elt);
10$elt->setAttribute('a','&');
11print $doc->saveXml($elt) . "\n";
12
13$attr = $elt->getAttributeNode('a');
14$attr->value = '&amp;';
15print "$attr->value\n";
16print $doc->saveXml($elt) . "\n";
17
18$attr->removeChild($attr->firstChild);
19print $doc->saveXml($elt) . "\n";
20
21// Note: since libxml2 commit aca16fb3d45e0b2c45364ffc1cea8eb4abaca87d this no longer explicitly warns. This seems intentional.
22@$attr->nodeValue = '&';
23print "$attr->nodeValue\n";
24print $doc->saveXml($elt) . "\n";
25
26$attr->nodeValue = '&amp;';
27print "$attr->nodeValue\n";
28print $doc->saveXml($elt) . "\n";
29
30$elt->removeAttributeNode($attr);
31$elt->setAttributeNS('http://www.w3.org/2000/svg', 'svg:id','&amp;');
32print $doc->saveXml($elt) . "\n";
33
34$attr = $elt->getAttributeNodeNS('http://www.w3.org/2000/svg', 'id');
35$attr->value = '&lt;&amp;';
36print "$attr->value\n";
37print $doc->saveXml($elt) . "\n";
38?>
39--EXPECTF--
40<elt a="&amp;"/>
41&
42<elt a="&amp;"/>
43<elt a=""/>
44
45<elt a=""/>
46&
47<elt a="&amp;"/>
48<elt xmlns:svg="http://www.w3.org/2000/svg" svg:id="&amp;amp;"/>
49<&
50<elt xmlns:svg="http://www.w3.org/2000/svg" svg:id="&lt;&amp;"/>
51