XML Code Generator Code
Status: Inactive
Brought to you by:
rnstech
ABOUT ===== XCG is a command line utility for transforming the structure of an XML instance into some kind of structure. It was created to help me generate wrappers for several dozen different XML formats that I was working with. As a result of the need, the first version generated c++ code wrappers around libxml2, which after a lot of research appeared to be the best solution for my XML reading and writing needs. The current version is much more powerful than just described. Instead of just generating c++ wrapper code, it now generates based on the contents of its configuration, which is contained within XML. In fact, it uses itself to generate the code to read the XML configuration file (well, not directly, but its the same end result). It could be self hosting simply by embedding a copy of the default XML configuration in the executable; I chose to keep it external to make it easier for others to modify the default code generation. I didn't use an XSD or DTD as the basis of the transformation for the simple reason that most of the formats I was working with either didn't have one, or it was very out of date. In my experience, most XML instances I work with seem to be in a similar state and in actual real world use I found myself creating a lot of last minute simple XML instances with all kinds of short little formats for things that would only be modified rarely, and only by myself (look at <a href="example3.html">example3</a> for a real world example). I could have used XSL to do these translations, but in the end, I think what made me choose this method was a library named <a href="http://sourceforge.net/projects/tinyxml">TinyXML</a> that has a pretty faithful following because it is <em>so</em> easy to use (alas, it has a few issues that make it unusable for me). I also wanted something that was as easy to use, but which would be much more flexible. This is where I ended up, and I am actually quite happy with the result! If one is familiar with stl, then the default code generation is pretty easy to use; Because all elements are wrapped in objects, and those objects don't allow direct acess to any data, it actually is highly maintainable as well. As always, there are a few things I still want from it, but its a great start. As a result of using a configuration file (called a template), there are very few limitations on what can be generated. INSTALL ======= For more complete installation instructions, please see file named INSTALL in the source directory. The quickest way to get this going is to do the standard GNU autotools commands: cd xcg-1.2.0.6 ./configure make sudo make install If you want to do the same from the git repo instead you need to add a single step first: cd xcg-1.2.0.6 ./bootstrap ./configure make sudo make install DEPENDS ======= For distribution installs, the following libraries are required. The format of the list is "library name", "minimum version", ("version currently developed with"). It is actually possible that it will work with earlier versions of some of the libraries, but I haven't tested the current code against anything before the minimal versions. boost >= 1.55 (1.57) (at least these: algorithm bind date_time filesystem ref system) libxml2 >= 2.9.0 (2.9.2) libxml2-dev (same as libxml2) If you you use the git repo, you'll also need these: autoconf >= 2.69 (2.69) automake >= 1.14.1 (1.14.1) libtool >= 2.4.2 (2.4.2) m4 >= 1.4.17 (1.4.17) For debian systems, the following line will get the needed libraries if not already installed: sudo apt-get install libxml2-dev libboost-all-dev pkg-config autoconf m4 automake