[xsde-users] Re: Polymorphic type is serialized as based

Andrey Filimonov andrey.v.filimonov at gmail.com
Sat Nov 28 06:55:09 EST 2015


Sorry for accidentally posting an incomplete message. The full one should
have been as follows:

> Hello,
> I'm facing an issue trying to serialize a polymorphic type. It's
> serialized as the base type.
> XSDE is compiled with polymorphic support.
>


> The serializer is instantiated this way:
>  oadrPayload_saggr oadrPayload_s; oadrPayload_s.pre(*payload);
> xml_schema::document_simpl doc_s (oadrPayload_s.root_serializer(),
> oadrPayload_s.root_namespace(), oadrPayload_s.root_name(), true);
> doc_s.serialize (ss, xml_schema::document_simpl::pretty_print);
> oadrPayload_s.post ();
> meaning it's constructed with polymorphic = true;
>
> Payload contains a polymorphic object down the tree.
>

The initial analysis of the issue:
When serializer serializes the polymorphic part it internally tries to set
the type of the object. This consequently leads to the following function
invocation tree:
bool context::
    set_type (const char* type)
[invokes]
const char* context::
lookup_namespace_prefix (const char* ns)
[invokes]
genxNamespace genxDeclareNamespace(genxWriter w, constUtf8 uri,
  constUtf8 defaultPref,
  genxStatus * statusP)
Adds given namespace to the writer's namespace list.
Then sets ns->declaration to NULL for the allocated genxNamespace
[invokes]
utf8 genxGetNamespacePrefix(genxNamespace ns)
returns NULL as ns->declaration was set to NULL
returned NULL makes lookup_namespace_prefix return false;
return false makes set_type return false;
This further makes serializer serialize the polymorphic type as base type.

Is there something i could do a wrong way or this is a serializer problem?

Andrey.


More information about the xsde-users mailing list