Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scabug opened this issue Jan 7, 2013 · 1 comment
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jan 7, 2013

h3.steps

  • 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

h3.problem

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

h3.expectation

  • 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/"""")

h3.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.

@scabug
Copy link
Author

scabug commented Jan 7, 2013

Imported From: https://issues.scala-lang.org/browse/SI-6939?orig=1
Reporter: Eugene Yokota (eed3si9n)
Affected Versions: 2.10.0

@scabug scabug closed this as completed Jan 30, 2013
@scabug scabug added this to the 2.11.0-M2 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants