[xsd-users] How to set custom C++ base-classes when generating from an xsd file

András Bondor lbandy3 at gmail.com
Fri Feb 1 10:38:17 EST 2019


Hi everyone,

I found this thread pretty old thread from 2006 (
https://www.codesynthesis.com/pipermail/xsd-users/2006-February/000220.html)
which says there was no support for it by the time, but I assume in the
past few years things might have changed. I'm working on converting a
pretty big xsd scheme to c++ code with multiple types and all, and later in
code I'd need to traverse the constructed tree in a way that I can
implement custom actions in some of the objects/classes contained in an
xml. I went trough the documentation multiple times but still I was unable
to see a way to do that. I was thinking of adding a base node class as the
default base so each class can inherit from this, which would be a pretty
straightforward oneliner change in the generated code, however I'd still
need to distinguish between different object types on the fly and write all
the class login in the same place, not very OOP in my opinion. Is there any
better way to do that? Since the generated code is huge, making manual
adjustments to each type would be a tremendous amount of work. Also if no
custom classes can be provided as base classes or a method to add custom
functionality to the generated objects I could manually go trough the
generated hierarchy and construct the same tree with custom objects by
hand, but then in this case I could simply use a header-only xml library
and do the parsing the same way I'm iterating over the generated classes
anyway.

Any advice is appreciated!

Thank you,
Andras


More information about the xsd-users mailing list