XML Schema to C++ Classes

39,934

Solution 1

Sounds to me like CodeSynthesis is exactly what you are looking for. It's open source and c++.

Solution 2

See XmlPlus-xsd2cpp at Google:

XmlPlus xsd2cpp provides "simple to use" C++ XML data-binding through W3C XML-Schema.

Usage of XmlPlus is covered by the GNU Lesser General Public License

Solution 3

gSOAP Toolkit can do this too! Its is lightweight, and supports C/C++. I have already used it in very demanding projects with success. Also, its licensed under GPL2.

Portability: gSOAP supports most platforms, including embedded systems and small OS (for example WinCE, Symbian, and PalmOS). Portability is tested for Windows (98, XP, Vista), Linux, Unix, Mac OS X, Solaris, HP-UX, AIX, FreeBSD, TRU64, Irix, QNX, and VxWorks.

Solution 4

Objective Systems, Inc. XBinder XML Schema Compiler (not only für C++).

Solution 5

Altova XML Spy can generate C++ from an XSD, it's commercial but there's a 30 day free trial if you want to try it out.

Share:
39,934
Andre
Author by

Andre

Updated on July 13, 2020

Comments

  • Andre
    Andre almost 4 years

    I have to write a C++ Application (using the Qt Framework for the GUI) that can edit data stored in xml files described by a xsd schema file. Is there a tool to convert the xsd schema into C++ Classes?

  • Andre
    Andre over 15 years
    I could be wrong, but it seems this doesn't support C++, only .Net C#, VB and J#
  • Jarekczek
    Jarekczek over 11 years
    It's worth noting that open source is a bit tricky here. The code generated by CodeSynthesis is also covered by GPL license, so you can't use it in your application without distributing the source code of your whole application. There are exceptions for low volume usage or proprietary license to buy though.
  • Matthew
    Matthew over 11 years
    xsd.exe does not support standard C++, only Microsoft's "managed" C++ which uses the CLR XML stuff.
  • Jan Hudec
    Jan Hudec almost 11 years
    Appears to have the same licensing limitation as the CodeSynthesis generator.
  • Beginner
    Beginner over 9 years
    Please note that the tool is not BY Google, it is just hosted at Google Code.
  • Ira Baxter
    Ira Baxter almost 8 years
    Can you show us an example of what the "bad tools" produce and explain why you think it is bad?
  • user6269400
    user6269400 almost 8 years
    Can't in a response since I'm stuck in "mini-Markdown formatting" here. I gave you an example schema - go ahead and run the Altova XML spy on it and compare that to the example MY hand rolled XSD->C++ lex/bison/hack produces. Go ahead. I am not the LEAST impressed with the tools available. XJC does produce fairly good code, however, it's in Java so it's not suitable for me. I feel like I'm working with stone knives and bearskins.
  • Ira Baxter
    Ira Baxter almost 8 years
    Don't have Altova spy... do see your proposed class structure and agree it looks reasonable. Maybe you can explain in 1-2 sentences what Altova does that you dislike.
  • user6269400
    user6269400 almost 8 years
    Well, my AltovaSpy trial license is expired, and although I could backdate my computer to make it work, I'm not going to bother. If you really want to know how terrible the tools are, just get the trial license. Altova was alright at visual representation. I can say this, it's extremely verbose, they make extensive use of extremely long prefix names, they use their own internally defined types instead of obvious things like "string", or even "int", data isn't stored in the class itself, but instead inside of a stream so this amounts to a parser not a set of containers.
  • Ira Baxter
    Ira Baxter almost 8 years
    Is the use of streams intended to handle the problem of really huge XML files?
  • user6269400
    user6269400 almost 8 years
    I don't know, but the end result is you have a bunch of classes which are very difficult to work with.
  • ruuns
    ruuns over 4 years
    Looks promising. Unfortanetely xsd2cpp is not supporting every xsd specification :/ e.g. attributeGroups are not supported.
  • Nguyễn Đức Tâm
    Nguyễn Đức Tâm over 4 years
    I cannot use CodeSynthesis in VS2019
  • Nguyễn Đức Tâm
    Nguyễn Đức Tâm over 4 years
    xsd.exe can also generate .xsd to Cpp code.stackoverflow.com/questions/59132321/…
  • Kevin Chou
    Kevin Chou over 2 years
    The tool use Expat parser that was based on SAX (stream parsing with callbacks), which made parsing some documents like COLLADA very inconvenient. ref to : installation institution