2

I'm not sure what exactly the right term is, kind of like ORM using XML as the data store. Are there any decent tools which will autogenerate C++ classes (including data and serialization/deserialization) based on an XML schema? Or will create XML-sync code and schema based on a C++ class definition?

TinyXML is great but it's so old-school to spend all that time writing code to load/save XML data to classes. I've seen similar tools focused on SOAP/WSDL, but they generated all kinds of other code on top of the basics.

Any good open-source libraries out there?

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • Auto-generating C++ classes based on an XML schema is not a good idea in my experience, especially if the schema is large and/or subject to change. Every time the schema changes you have to regenerate all of the classes, which typically entails a full rebuild of the remainder of your system. – jon hanson Jul 08 '10 at 15:27
  • 3
    Better I have to rebuild than my code is wrong. And time to rebuild is better than days writing and testing ultra-dull XML (de)serialization code. – Mr. Boy Jul 08 '10 at 15:41

3 Answers3

2

If you are looking for an open source and commercial licensed tool to auto-generate C++ classes, including data and serialization/deserialization, based on an XML schema, then I strongly recommend GSOAP. It is easy to use, compliant to industry standards, and actively maintained.

See also http://www.rpbourret.com/xml/XMLDataBinding.htm

I was disappointed with many other C++ XML tools that promise full data bindings but will fail to process more extensive sets of WSDLs and schemas such as ONVIF. Having to retool an entire project was a pain. I know that GSOAP will do the job. A winner IMHO.

Dr. Alex RE
  • 1,772
  • 1
  • 15
  • 23
2

The only thing I've seen that attempts to do this is CodeSynthesisXSD.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111
  • 1
    We tried this and about 5 other products, this was the winner. Good support too. – Greg Domjan Jul 08 '10 at 15:56
  • Greg doesn't mention which other products that he and his collaborators tried, but a number of other possibilities are offered in response to [XML Schema to C++ Classes](http://stackoverflow.com/q/445905/1497596). – DavidRR Oct 23 '13 at 13:40
0

Not open source, but won't XML Thunder work for you?

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341