I just noticed something strange. If I have this XML:
<level number="7" background="background_5">
and I press CTRL-SHIFT-F (Format) the code suddenly changes to this:
<level background="background_5" number="7" >
I can hardly imagine that the changing of the file is done on purpose, since I got some serious problems while parsing the files, since I access the attributes by index.
Is there a reason, except that it’s being ordered by alphabet, that it’s being formatted like this, and more importantly, how do I turn it off?
The XML spec explicitly says that the order of attributes is not guaranteed:
You might find a way to change the behavior of the XML formatter in Eclipse, but the most robust solution is to access attributes by name instead of index. Otherwise your code will remain sensitive to changes that are perfectly legal according to the XML spec.
See also: