Description
This issue is copied across from https://issues.scala-lang.org/browse/SI-6341
The original person who raised the issue attached a patch to add a failing test case.
When parsing XML and then writing it out again, the order of attributes is reversed.
This prevents certain use cases where one wants to modify an XML file and have a minimal amount of changes. E.g. adding a new element to a file causes all existing attributes to get reversed.
The cause is here:
aMap: MetaData is built by prepending new attributes to the linked list, causing the reversal.
The attached patch adds a failing test case. (It failed when I wrote it originally, now I can't test it because the build fails).
commit 272ed40345c9f8f4af878f15299155cecfd8db2e
Author: Robin Stocker [email protected]
Date: Sat Sep 8 19:11:50 2012 +0200
Add failing test for scala.xml attribute order problem
diff --git a/test/files/run/xml-attribute-order-parse.check b/test/files/run/xml-attribute-order-parse.check
new file mode 100644
index 0000000..6637a4f
--- /dev/null
+++ b/test/files/run/xml-attribute-order-parse.check
@@ -0,0 +1 @@
+
diff --git a/test/files/run/xml-attribute-order-parse.scala b/test/files/run/xml-attribute-order-parse.scala
new file mode 100644
index 0000000..3be386c
--- /dev/null
+++ b/test/files/run/xml-attribute-order-parse.scala
@@ -0,0 +1,9 @@
+import xml.XML
+
+object Test {
- def main(args: Array[String]): Unit = {
- val input = """"""
- val doc = XML.loadString(input)
- println(doc)
- }
+}