swigxml is a SWIG extension that enables SWIG to generate XML.
What is it good for? Here are several suggestions:
What is included?
Follow these steps:
##############################################################################
*** Makefile Mon Mar 18 14:15:05 2002
--- tmp Sat Mar 23 09:38:36 2002
***************
*** 13,20 ****
RANLIB = ranlib
TARGET = libmodules11.a
! OBJS = main.o emit.o lang.o typepass.o allocate.o browser.o contract.o sw
! SRCS = main.cxx emit.cxx lang.cxx typepass.cxx allocate.cxx browser.cxx c
INCLUDE = -I$(srcdir)/../Include \
-I$(srcdir)/../DOH/Include \
--- 13,20 ----
RANLIB = ranlib
TARGET = libmodules11.a
! OBJS = main.o emit.o lang.o typepass.o allocate.o browser.o contract.o sw
! SRCS = main.cxx emit.cxx lang.cxx typepass.cxx allocate.cxx browser.cxx c
INCLUDE = -I$(srcdir)/../Include \
-I$(srcdir)/../DOH/Include \
##############################################################################
-xml - Generate XML description doc.
You should now be able to generate XML output (and optionally pipe it to a file) with something like the following:
swig -xml -c++ myclass.i > myclass.xml
Back to top
In order to use the generated XML, you will need to write an application.
Python is an excellent language for writing XML applications.
A good place to start in writing that application in Python is with swigxml.py, which comes with the swigxml distribution.
Here is a simple test of swigxml.py -- It parses a file containing XML output from SWIG, creates a tree of instances of Python classes, then exports the stdout:
python swigxml.py myclass.xml
So, a reasonable next step is to make a copy of swigxml.py, then modify the classes in it until they do what you need. If you need to walk the tree of objects, consider copying, renaming, and modifying the export method in each of the data representation classes.
Back to topswigxml itself is implemented as an extension to SWIG. So, in order to extend my extension, you just keep on doing what I was doing in implementing swigxml.
Here is where to look:
The SWIG1.3 Development Documentation contains a bit of help on how to write extensions to SWIG and more is promised for the future. You can find this documentation at http://www.swig.org /Doc1.3/Extending.html
If you make significant additions to the generated output (e.g by modifying xml.cxx), then you may want to consider modifying the data structure definitions in swigxml.xsd and re-generating swigxml.py (or something to replace it). In order to do so, edit swigxml.xsd, then run generateDS.py (also described at http://www.rexx.com/~dkuhlman). Something like the following should do it:
python generateDS.py swigxml.xsd > my_new_swigxml.py
Back to top