XML架构(XSD)到Rails的ActiveRecord映射? [英] XML Schema (XSD) to Rails ActiveRecord Mapping?

查看:115
本文介绍了XML架构(XSD)到Rails的ActiveRecord映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来转换XML模式定义文件到一个ActiveRecord模型数据库中。有谁知道这种情况要做到这一点的工具?

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?

到目前为止,我已经找到了最好的方法是首先加载XSD到类似的Postgres或MySQL的关系型数据库,然后有轨连接到做耙分贝:模式:转储。然而,这只是给我留下一个数据库而不轨道模型。

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.

什么是导入/加载此基础XSD数据库进入轨道?最好的办法

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

推荐答案

你尝试宝石magic_model_generator生成从数据库模型?

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

请参阅: http://magicmodels.rubyforge.org/magic_model_generator/

此外,你怎么加载XSD到您的RDBMS?似乎有很多的讨论,在这里: <一href="http://stackoverflow.com/questions/138575/how-can-i-create-database-tables-from-xsd-files">http://stackoverflow.com/questions/138575/how-can-i-create-database-tables-from-xsd-files <一href="http://stackoverflow.com/questions/403420/convert-xsd-into-sql-relational-tables">http://stackoverflow.com/questions/403420/convert-xsd-into-sql-relational-tables

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

更新: 我使用的XML间谍(30免费试用,在Windows上,UG)从一个MySQL数据库的XSD建表,然后跑magic_model_generator上创建的ActiveRecord类。这似乎已经做你所期望的,生成的基础上,DB​​模式的字段验证。

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.

这篇关于XML架构(XSD)到Rails的ActiveRecord映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆