I’ve been doing a lot of World of Warcraft addon development lately using Komodo and one of the main reasons I love this IDE is the powerful autocomplete functionality it has for some of my favorite languages (including some specific libraries like jQuery as well). Although I know Lua fairly well, I still have to look up a fair portion of the attributes when doing XML layouts. I knew that Komodo could do XML autocompletion based on using it for HTML, so I decided to try to figure out how to do it. Turns out it’s pretty simple, but there was a bit of trial and error in this particular case.
XML autocompletion in Komodo is handled by using catalog files that link external links to a local file. The local file is in either .dtd or .rng format. Initially I ran into some problems with this because WoW uses schema (.xsd) which is apparently not supported. So it’s a bit trickier in this case, but I got it figured out with some help from Komodo’s outstanding technical support crew (thanks Troy).
Get the .xsd file. It doesn’t ship with WoW, at least not in an uncompressed form. So go to http://us.blizzard.com/support/article.xml?locale=en_US&articleId=21466 and grab the http://us.media.blizzard.com/wow/interface/WoW_Interface_enUS.zip file or if you’re not in the US, a more appropriate version. You can also grab the WoW artwork from this page if you want to get a feel for how the WoW graphics files are laid out or you want to do some customization. Once you get the file, unzip it wherever. To keep things tidy, I unzipped it in my WoW directory. It will expand into two folders: AddOns and FrameXML (inside the top level directory: WoW_Interface_enUS). FrameXML is what we’re interested in. Inside FrameXML is a file called UI.xsd. This is the XML Schema for World of Warcraft’s User Interface libraries.
Convert the .xsd. Initially I tried this project with the .xsd and it didn’t work at all. So I was curious as to why, so I fired off an email at Komodo tech support, and found out that Komodo doesn’t actually support catalog files linked to an xsd file. So the options they do support are DTD and RelaxNG. Well I knew DTD better than RelaxNG, so I decided to convert the file from Schema to DTD and then try that. But for some reason this didn’t work, so I decided to try the original suggestion I received from ActiveState and convert the file into .rng (RelaxNG) format. So I created a stub file called UI.rng, then I went to this website: http://debeissat.nicolas.free.fr/XSDtoRNG.php and copied the contents of the UI.xsd file into the left panel of their schema conversion tool, hit convert, then copy/pasted the contents of the right panel into UI.rng. There were some problems with the conversion between WoW’s schema and RelaxNG because RelaxNG doesn’t understand the substitutionGroup mechanism. So I modified the .rng file to accommodate for this, you can get the working file here or view the code for modifications here.
Create the catalog. This part is really really easy. So easy in fact, there is a lot of room to over-complicate it if you’re not careful. The typical XML declaration at the beginning of a WoW XML file contains a few urls, initially I tried to use the url in my xsi:schemaLocation. Don’t. The url we’re linking on here is the xmlns url, which for these files should always be http://www.blizzard.com/wow/ui/ and then beyond that you just have to remember that the local uri you’re linking to has to be relevant to the location of the catalog file. So we create a catalog.xml file (I’m not sure if the name is mandatory, I didn’t test it, but every default Komodo catalog used it, so I did as well) and fill it with the following contents:
<?xml version="1.0" encoding="UTF-8"?> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="public"> <uri name="http://www.blizzard.com/wow/ui/" uri="UI.rng"/> </catalog>
With the UI.rng file being in the same directory in this case.
Tell Komodo about your catalog. Open up your preferences (location will vary based on OS), then go to Languages->XML Catalogs. Click the green plus (+) button, and browse to your catalog.xml file. Open it, then click OK at the bottom of the preferences pane. Restart Komodo, and you should be granted with fancy new autocompletion.
Anyway, hopefully this helps some others who are using Komodo for their WoW development, and if you’re not using Komodo, you should definitely check it out. It’s definitely the best multi platform (Linux, Windows, Mac OSX), multi language IDE I’ve ever used.