The Room Do I dare disturb the universe?

The XML::Toolkit Story Part 1 - The Early Years

So one of the talks I had accepted to YAPC is on XML::Toolkit, and I thought I’d give a bit of a preview of what it is.

XML::Toolkit was created for a project that required de-serializing XML in to Perl data, exposing that data to be edited, and then re-serializing it so a Flash client could read it. Because of assumptions made by the Flash script, child order was vital, so the XML had to not only round-trip semantically, it had to round-trip structurally. The second fun fact was there was no DTD and no schema. Some of the XML wouldn’t even parse because it wasn’t well formed, but some work with the client sorted that.

So hard requirements:

1) Round-Trip XML 2) Guess the Schema

Add to this some soft requirements:

  1. Use Moose (we were a nearly 100% Moose company)
  2. Be fast
  3. Do XML properly (ie Not XML::Simple / XML::Smart which IMHO “fake it”1)

So I dipped into some latent XML knowledge. I’ve been hanging out with the AxKit people since I started with Perl, and while I haven’t done a ton of XML work in the last 8 years, I have soaked up a few things. Particularly the knowledge of Kip Hampton’s Perl/XML column from 2002. I knew that I wanted something that would perform adequately and that I wanted something flexible, so I reached for the SAX tools on CPAN. I knew that you could write drivers for non-sax data, and I assumed I could do the inverse.

After some hacking I came up with a sax parser that would build Moose Meta Classes from SAX streams. A little extra tweaking and I had something useable for the work project. I will try to get a second post up that details the second major project I had for XML::Toolkit which caused me to clean it up and release it.

  1. Sometimes faking it is good enough.