[xsd-users] Problem with assymmetry in serialization/deserialization
Bielik, Robert
Robert.Bielik at gyros.com
Wed Dec 12 08:53:08 EST 2012
Hi all,
I'm trying to use template functions to make for transparent serialization/deserialization, however, without -generate-element-map I can only make deserialization work through:
template<typename ObjectType>
std::auto_ptr<ObjectType> getTypedObject(DOMDocument* doc)
{
std::auto_ptr<ObjectType> ret;
try
{
ret.reset(new ObjectType(*doc->getDocumentElement()));
}
catch (std::exception&)
{
// Catch all
}
return ret;
}
which works nicely. However serializing is a whole other matter. To serialize the object CObjectXml I need to:
schema_namespace::CObjectXml value(...);
::xml_schema::dom::auto_ptr< ::xercesc::DOMDocument > domdoc = schema_namespaces::CObjectXml_(value, contentMap);
As you can see, there is no way to templatize this since the serialization relies on a static function named ObjectType_ (!)
And with -generate-element-map I have no way to create a DOMDocument directly, since the serialization operators work on a DOMElement. Besides, it seems that
whereas the ObjectType_ function correctly generated the top level DOMElement with name == "ObjectType", the latter serialization operators only serialize the
CONTENT of ObjectType (i.e. no top element with name == "ObjectType").
I could really use some suggestions as how to accomplish what I want since the codebase is getting sickeningly large due to this...
TIA
/Rob
More information about the xsd-users
mailing list