[xsd-users] Preserving XML element order

Boris Kolpackov boris at codesynthesis.com
Thu Feb 18 15:30:47 EST 2010


Hi Barrie,

Barrie Kovish <barrie.kovish at singularsoftware.com> writes:

> How do I customize the object model?  

Take a look at the C++/Tree Mapping Customization Guide:

http://wiki.codesynthesis.com/Tree/Customization_guide

There is also a bunch of examples in the examples/cxx/tree/custom/
directory.


> I had actually wanted to do something like the following:
> 
> class angle: public ::xml_schema::type, public MyClass<angle> 
> 
> Then I can use class template specialization to add specific 
> methods to various Code Synthesis generated classes.

The best approach would be to request the generation of the
'base' type and make the actual type a typedef to a template
instantiation, for example:

--custom-type angle=MyClass<angle_base>/angle_base

This way you will get something like this in the generated code:

class angle_base: ...
{
  // Standard mapping
};

typedef MyClass<angle_base> angle;

The MyClass class template would normally look like this:

template <typename X>
class MyClass: public X
{
  ...
};

Boris



More information about the xsd-users mailing list