[xsd-users] Visitor pattern automatically generated/ and/or
boris at codesynthesis.com
Sat Jul 18 01:56:46 EDT 2009
Markus Hummel <Markus.Hummel at gmx.de> writes:
> But I am requiring some kind of a "traverser" to get a simplified but
> predefined access to the different information.
> Is it possible on using
> > XSD cxx-tree --generate-serialization --generated-visitor-pattern
> to add the visitor pattern to all the generated classes?
> An according empty default Visitor would also be very helpful.
> If the according Visit()s and Accept()s are generated by the cxx-tree
> it would be very simple to implement any traverser on the model.
The problem with automatically generating the Visitor mechanism is
that the Visitor class needs to define the visit() function for each
type in the object model. When you have separate compilation of
schemas that are included or imported, this becomes a very tricky
The other part of the Visitor mechanism, the accept() functions,
should be fairly easy to generate.
So it looks like the best bet to get this automated would be to
define the Visitor class manually and then customize the code
generator in XSD to emit the accept() function implementation
for each object model class. If you would like, I can give you
some pointers on how to do the customization.
BTW, is anybody else interested in this functionality?
More information about the xsd-users