bug43364.phpt 914 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Bug #43364 (recursive xincludes don't remove internal xml nodes properly)
  3. --EXTENSIONS--
  4. dom
  5. --FILE--
  6. <?php
  7. function loopElements($nodes)
  8. {
  9. $count = 0;
  10. foreach($nodes as $node) {
  11. if($node instanceof DOMElement) {
  12. $count++;
  13. if($node->childNodes->length > 0) {
  14. $count += loopElements($node->childNodes);
  15. }
  16. }
  17. }
  18. return $count;
  19. }
  20. $xml = <<<DOC
  21. <?xml version="1.0" encoding="UTF-8"?>
  22. <root xmlns:xi="http://www.w3.org/2001/XInclude">
  23. <a>
  24. <a_child1>ac1</a_child1>
  25. <a_child2>ac2</a_child2>
  26. </a>
  27. <b><xi:include xpointer="xpointer(/root/a)" /></b>
  28. <c><xi:include xpointer="xpointer(/root/b)" /></c>
  29. </root>
  30. DOC;
  31. $doc = new DomDocument();
  32. $doc->loadXml($xml);
  33. $doc->xinclude();
  34. $count = loopElements(array($doc->documentElement));
  35. var_dump($count == 13 || $count == 11);
  36. ?>
  37. --EXPECT--
  38. bool(true)