views:

1254

answers:

3

Is there a way to generate Ruby classes (maybe even ActiveResource classes) from an XSD so that they contain a way to serialize the classes to xml valid for the initial XSD?

I know that soap4r has xsd2ruby but it appears that the generated ruby classes cannot be easily serialized to xml.

+1  A: 

Maye you can steal some ideas from this article about converting QuickBooks schemas to ruby classes.

krusty.ar
+1  A: 

It appears that this might work.

require 'xsd/mapping' XSD::Mapping.obj2xml(xsdBasedObject)

+1  A: 

Shameless self promotion (hope this is okay on stackoverflow) but I'm working on an open source project to do just that

Its still a work in progress (feel free to send patches) but the ultimate goal is to convert XSD to/from Ruby classes (which it does now) and convert XML conforming to that XSD to/from instances of those classes.

Mo