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

xml namesapce (scope) not handled correctly when mixing xml literal and scala code #4865

Closed
scabug opened this issue Aug 2, 2011 · 2 comments

Comments

@scabug
Copy link

scabug commented Aug 2, 2011

in scala console

following code works correctly:

scala> val e = <ns:elems xmlns:ns="http://">{List(1, 2, 3).map(x => <ns:elem>{x}</ns:elem>) ++ List(4, 5, 6).map(x => <ns:elem>{x}</ns:elem>)}</ns:elems>
e: scala.xml.Elem = <ns:elems xmlns:ns="http://"><ns:elem>1</ns:elem><ns:elem>2</ns:elem><ns:elem>3</ns:elem><ns:elem>4</ns:elem><ns:elem>5</ns:elem><ns:elem>6</ns:elem></ns:elems>

scala> e \\ "elem"
res0: scala.xml.NodeSeq = NodeSeq(<ns:elem xmlns:ns="http://">1</ns:elem>, <ns:elem xmlns:ns="http://">2</ns:elem>, <ns:elem xmlns:ns="http://">3</ns:elem>, <ns:elem xmlns:ns="http://">4</ns:elem>, <ns:elem xmlns:ns="http://">5</ns:elem>, <ns:elem xmlns:ns="http://">6</ns:elem>)

namespace is correct in each child node.

while if using method call, namespace gets lost:

scala> def f(l: List[Int]) = l.map(x => <ns:elem>{x}</ns:elem>)
f: (l: List[Int])List[scala.xml.Elem]

scala> val e = <ns:elems xmlns:ns="http://">{f(List(1, 2, 3)) ++ f(List(4, 5, 6))}</ns:elems>
e: scala.xml.Elem = <ns:elems xmlns:ns="http://"><ns:elem>1</ns:elem><ns:elem>2</ns:elem><ns:elem>3</ns:elem><ns:elem>4</ns:elem><ns:elem>5</ns:elem><ns:elem>6</ns:elem></ns:elems>

scala> e \\ "elem"
res2: scala.xml.NodeSeq = NodeSeq(<ns:elem>1</ns:elem>, <ns:elem>2</ns:elem>, <ns:elem>3</ns:elem>, <ns:elem>4</ns:elem>, <ns:elem>5</ns:elem>, <ns:elem>6</ns:elem>)
@scabug
Copy link
Author

scabug commented Aug 2, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4865?orig=1
Reporter: Hongxin Liang (honnix)
Affected Versions: 2.9.0

@scabug
Copy link
Author

scabug commented Jul 17, 2015

@SethTisue said:
The scala-xml library is now community-maintained. Issues with it are now tracked at https://github.com/scala/scala-xml/issues instead of here in the Scala JIRA.

Interested community members: if you consider this issue significant, feel free to open a new issue for it on GitHub, with links in both directions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant