summaryrefslogtreecommitdiff
path: root/test/files/run/t6939.scala
Commit message (Collapse)AuthorAgeFilesLines
* SI-6939 Fix namespace binding (xmlns) not overriding outer bindingEugene Yokota2013-01-271-0/+13
Given a nested XML literal to the compiler Elem instance is generated with namespace binding of the inner element copying that of the outer element: val foo = <x:foo xmlns:x="http://foo.com/"> <x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo> With the above example, `foo.child.head.scope.toString` returns " xmlns:x="http://bar.com/" xmlns:x="http://foo.com/"" This is incorrect since the outer xmls:x should be overridden by the inner binding. XML library also parses XML document in a similar manner: val foo2 = scala.xml.XML.loadString("""<x:foo xmlns:x="http://foo.com/"><x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo>""") Despite this erroneous behavior, since the structure of NamespaceBinding class is designed to be singly-linked list, the stacking of namespace bindings allows constant-time creation with simple implementation. Since the inner namespace binding comes before the outer one, query methods like `getURI` method behave correctly. Because this bug is manifested when Elem is turned back into XML string, it could be fixed by shadowing the redefined namespace binding right when buildString is called. With this change `foo.child.head.scope.toString` now returns: " xmlns:x="http://bar.com/""