Martian eyrie

January 16, 2007

xmlcodec a XML importer/exporter framework for Ruby

Filed under: RubyOnRails

xmlcodec a XML importer/exporter framework for Ruby

xmlcodec - a XML importer/exporter framework for Ruby

What is this? This is a framework to create importers/exporters of XML formats for Ruby. To create a new importer/exporter all you have to do is create a ruby class for each of the XML elements.

Where do I get it? This project is hosted on RubyForge. You can see the project page or go straight to the files section to get the latest version. If you have RubyGems installed you can just do "gem install xmlcodec" and it will fetch the latest version from the network.

What features does it have? The basic model of the framework is that an importer/exporter maps a XML tree into a Ruby object tree. To do this you write Ruby classes for each of the XML format’s elements. After that you get several API’s for free:

  • Import/Export XML text
  • Import/Export REXML DOM
  • A stream parser whose events are whole elements imported into a Ruby object
  • A partial export API that can be used to create huge XML files with constant memory usage

The first two API’s treat the XML as a whole tree at once.

The stream parser allows you to parse a very big XML file as a stream but with more meaningfull events than a regular XML stream parser.

The partial export API allows you to create huge XML files the same way you’d create a small one (by putting elements in the Ruby tree) but without having to create the whole tree in memory. This is done by exporting an element into the output file and then removing it from the tree. This is not done automatically, but it’s pretty easy to do.

Comments »

The URI to TrackBack this entry is: http://eyrie.blogsome.com/2007/01/16/xmlcodec-a-xml-importerexporter-framework-for-ruby/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham