views:

324

answers:

1

I'm looking for a way to convert an XML Schema definition file into an ActiveRecord modeled database. Does anyone know of a tool that happens to do this?

So far the best way I've found is to first load the XSD into an RDBMS like postgres or mysql and then have rails connect to do a rake db:schema:dump. This however, only leaves me with a database without rails Models.

What would be the best way to import/load this xsd based database into rails?

A: 

Did you try gem magic_model_generator to generate the model from the db?

See: http://magicmodels.rubyforge.org/magic_model_generator/

Also, how did you load the XSD into your RDBMS? There seems to be plenty of discussion here: http://stackoverflow.com/questions/138575/how-can-i-create-database-tables-from-xsd-files http://stackoverflow.com/questions/403420/convert-xsd-into-sql-relational-tables

Update: I used Xml Spy (30 free trail, on windows, ug) to build tables from the xsd in a mysql db, then ran magic_model_generator on it to create ActiveRecord classes. It appears to have worked as you would expect, generating validators on the fields based on the the db schema.

Ryan