From: Marcin Raczkowski Date: 2007-07-13T19:02:14+09:00 Subject: [ANN] xml-map Hello. Thanks to my bas from softwarelab.eu (little advert) I'm starting to release code that i wrote so far :) for now there's little - or no- documentation but i'll be working on it back to the topic: xml-map is easy to use XML to ruby object library with rails-like models, validators and more ^^, it uses vary fast libxml instead of slow and old REXML, you need version 0.4 of libxml to work properly you can grab it from svn from xml-map.rubyforge.org What is done: - Import valid XML - autogenerate models - some validators what i'm working on: - all validators from XmlSchema - autogenerating models with validators from xsd require 'rubygems' require 'xml/libxml' require '../lib/xml_models' require 'pp' ============================================ > cat sample/sample.rb tfile = ARGV.shift || "test.xml" # auogenerate required models xm=XmlMapper.new({:generate=>true, :file=> $stdout}) #load xml file doc = XML::Document.file(tfile) root_node = doc.root # parase xml and create model instances rn = xm.parse_xml(root_node) pp rn rn.content[0].content<<"dwa" rn.save(out.xml) ============================================ > cat sample/test.xml raz dwa trzy ============================================ ruby sample.rb class RootNode < XmlNode end class SimpleNode < XmlNode end class ComplicatedNode < XmlNode end #===== class generation ends here, you can copy above classes add attr_accessors for desired attributes #, #, #], @node_name="Complicated", @param1="string", @param2="2", @param3="3">], @node_name="root"> ====================================== soon i'm going to provide more documentation and more compleate support for xsd and validators, if anyone is interested in helping in this easy but time consuming work, please let me know ^^ =================================== Marcin Raczkowski --- Friends teach what you should know Enemies Teach what you have to know