[xsd-users] Serialization Methods For Polymorphic Types

Boris Kolpackov boris at codesynthesis.com
Tue Oct 4 09:47:18 EDT 2011


Hi Jason,

Friess, Jason <jason.friess at lmco.com> writes:

> xml_schema::namespace_infomap map;
> std::ostringstream oss;
> Parent_(oss, obj, map); // "Parent_" would be a serialization method generated for the element associated with the parent type,
> //"obj" is an object which has a type which is one of the child types of the parent type
> std::string xml(oss.str()); //"xml" is the resulting XML string
> 
> Is this possible?  

Yes, as Erik mentioned, this works out of the box and you don't need to
do anything special.


> If so - will it result in XML that is appropriate for the child type?

Yes, if there is a substitution group element available for this child
type, then that element will be used. Otherwise, the parent element
will be used and xsi:type attribute will be added.

Boris



More information about the xsd-users mailing list