[opensource-dev] XUI Cleanup Project

Kadah kadah.coba at gmail.com
Fri Aug 3 15:32:41 PDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This weekend I was working on some XUI files and my OCD (I don't
actually have OCD) was getting very frustrated over the random
formatting, lack of consistent indentation, trailing whitespace,
random/missing newlines and wildly differently sorted arguments.
Usually I'd either completely retab the file or give up, but I was
lazy and tired of not doing anything. So needless to say I got nothing
done on in XUI and spent the few days writing a script to reformat XUI
files to some level of code standards.

There is no XML code standards on
http://wiki.secondlife.com/wiki/Coding_standard
So I used my own, which were as such:
* Unix EOLs
* Child elements indented +4 spaces
* Each argument on onw line and indented +1
* Arguments sorted by defined list then alpha order
 (eg. 'name' and composting before random control specific args)
* Comments must be preserved

Initially I looked for existing tools/libs that can do XML cleanup,
but I had the same results I found the last time I looked, that none
of them could cover all the requirements. Surprisingly comment support
was actually hardest to find support for, unsurprisingly argument
sorting is extremely uncommon and the ones that did were poor.
After that I attempted to find an XML lib for parsing, but found that
pretty much all of them did not support comments or the tabled output
was unstable.

So I ended up writing the XML parser and reserializer myself.
Everything appears to output correctly, but I lack a diff tool that
supports XML to be able to do verification. The text diff tools I'm
familiar with can only do word/character comparisons and the reordered
args, and sometimes drastically improved whitespace, make manual
checking tedious.

So does anyone know of a, preferably, open source XML diff tool?

I'm guessing it could be possible to extract some of the XML/XUI file
parsing from the viewer and make one, but it would be a pain in the rear.


If this works out, I'll release the scripts (MIT licensed), and submit
the requisite jira/RB to push upstream XUI cleaned up, which would be
really nice.

Samples:
Input:
http://hg.secondlife.com/viewer-release/raw/24c6da14256c/indra/newview/skins/default/xui/en/panel_preferences_general.xml
Output: http://pastebin.com/9K40N49w

Input:
http://hg.secondlife.com/viewer-release/raw/24c6da14256c/indra/newview/skins/default/xui/en/menu_login.xml
Output: http://pastebin.com/i16De7xU

- -Kadah
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJQHFGJAAoJEIdLfPRu7qE2jtwIAKFh7Xe7GJD97ar9kuaQAx13
Iaj8ZaRB9HVfjdOiJJiT6aaTodEag0B23i19WH0fvq23kgZOGzXgiUppsw3TeiLr
eTX0bnct/CqmTDx+afYJY9QExhb0osC8FuFzjxVld6KtQk46Wn6a58ljNvyc459e
ySBCUgoivg+1oa5XqPP2UmUHE5OK0oqnhALKEfcLpW0AFpbv1yLzrJNEZYE3iIRn
3/g0mAhcpMtC6Um8XjR3+l/lTi50iTz2T5APnxWX8LNepwOvT2muffHgwGDGRwCt
6/e1SZjP9AI4hfVf4HM7Rn0JIc87Vp3zODf5KtCsw93er0Qmhi99OBZfn8DriXI=
=GHbm
-----END PGP SIGNATURE-----


More information about the opensource-dev mailing list