Skip to content

namespace attributes in XML literals are reversed #12684

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

Open
lrytz opened this issue Nov 3, 2022 · 0 comments
Open

namespace attributes in XML literals are reversed #12684

lrytz opened this issue Nov 3, 2022 · 0 comments
Labels
Milestone

Comments

@lrytz
Copy link
Member

lrytz commented Nov 3, 2022

This one was always OK:

scala> <t a="1" b="2"/>
val res0: scala.xml.Elem = <t a="1" b="2"/>

This one was fixed in scala-xml 2.x (scala/scala-xml#172), the attributes are reversed when using 1.x:

scala> scala.xml.XML.loadString("""<t a="1" b="2"/>""")
val res1: scala.xml.Elem = <t a="1" b="2"/>

The fix also applies here:

scala> scala.xml.XML.loadString("""<t xmlns="xmlns-url" xmlns:xsd="xmlns-xsd-url"/>""")
val res0: scala.xml.Elem = <t xmlns="xmlns-url" xmlns:xsd="xmlns-xsd-url"/>

But for literals, namespace attributes are handled by the compiler and they are (and always were) reversed:

scala> <t xmlns="xmlns-url" xmlns:xsd="xmlns-xsd-url"/>

[[syntax trees at end of                    parser]] // <console>
...
        var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
        $tmpscope = new _root_.scala.xml.NamespaceBinding(null, "xmlns-url", $tmpscope);
        $tmpscope = new _root_.scala.xml.NamespaceBinding("xsd", "xmlns-xsd-url", $tmpscope);
        {
          val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
          new _root_.scala.xml.Elem(null, "t", _root_.scala.xml.Null, $scope, true)
        }
...
val res0: scala.xml.Elem = <t xmlns:xsd="xmlns-xsd-url" xmlns="xmlns-url"/>

scala> res0.scope
val res1: scala.xml.NamespaceBinding =  xmlns:xsd="xmlns-xsd-url" xmlns="xmlns-url"

scala> res0.scope.parent
val res2: scala.xml.NamespaceBinding =  xmlns="xmlns-url"
@lrytz lrytz added the parser label Nov 3, 2022
@lrytz lrytz changed the title namespace attributes in XML are reversed namespace attributes in XML literals are reversed Nov 3, 2022
@lrytz lrytz added this to the Backlog milestone Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant