Slug: generating-python-from-xml-schema Date: 2003-11-23 Title: Generating Python from XML Schema layout: post

I've been toying with the idea of writing a python library for Apple's Keynote file format, APXL.

After slogging through 4 objects and realizing that to do it right was going to be a LONG process, I started looking around for code generators that might read an XML Schema (which Apple provides for APXL - see the above link) and spit out python code.

Well, here it is: generateDS - generate data structures from XSL.

It seems fast enough, though I've had to hack it a good bit to work around Apple's element names, many of which have dashes in them (ie, 'font-styling','outlined-drawable-style-type') and are not valid python identifier names. So I had to add a function to remove the dashes and camelCase them, then make sure that the code calls my function every time it uses the name. I also modifed it to not put "get" in front of get accessors, but that's personal preference.

Still, it spits out 3500 lines of python in about .75 seconds. Once I've got it tweaked and played around with it some, I'll post the code.