Scala Programming Language
  1. Scala Programming Language
  2. SI-6939

Namespace binding (xmlns) is duplicated if a child redefines a prefix

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.11.0-M2
    • Component/s: XML Support
    • Labels:
      None

      Description

      steps

      1. Define an XML literal that redefines a namespace binding (xmlns attribute) within a child element.
      Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_33).
      Type in expressions to have them evaluated.
      Type :help for more information.
      
      scala> val foo = <x:foo xmlns:x="http://foo.com/"><x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo>
      foo: scala.xml.Elem = <x:foo xmlns:x="http://foo.com/"><x:bar xmlns:x="http://bar.com/"><x:baz/></x:bar></x:foo>
      
      scala> foo.child.head.scope.toString
      res0: String = " xmlns:x="http://bar.com/" xmlns:x="http://foo.com/""
      
      scala> assert(foo.child.head.scope.toString == """ xmlns:x="http://bar.com/"""")
      java.lang.AssertionError: assertion failed
      

      problem

      1. The child element duplicates namespace binding. In the above example, xmlns:x is duplicated.

      expectation

      1. The outer namespace binding with the same prefix should be overridden by the inner namespace binding.
      scala> assert(foo.child.head.scope.toString == """ xmlns:x="http://bar.com/"""")
      

      notes

      This is caused Scala compiler stacking outer namespace binding when defining inner Elem. See ast.parser.SymbolicXMLBuilder.

      The same bug is duplicated in Scala library when XML document is created using scala.xml.XML.loadString(...) again due to outer namespace binding stacked in scala.xml.parsing.FactoryAdapter.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jason Zaugg
            Reporter:
            Eugene Yokota
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development