[xsd-users] Cropped data problem due to enforced upcasting in C++.

Boris Kolpackov boris at codesynthesis.com
Tue Mar 24 10:43:20 EDT 2020


Tolga Hakan ODUNCU <thakanoduncu at gmail.com> writes:

> Since this schema includes base and derived types, I generated the C++ 11
> codes with -generate-polymorphic parameter as proposed on Command Line
> Manuel.

Have you also specified --polymorphic-type RequestContainer or,
alternatively, --polymorphic-type-all?


> However, when I push back my ReportTaskIssueRequest object to
> x1RequestMessage_sequence directly or with _clone() function, my object is
> upcasted to X1RequestMessage and properties belonging to
> ReportTaskIssueRequest are cropped and xsi:type attribute is invisible.

You could verify that the object you have pushed retains its dynamic
type with dynamic_cast:

x.x1RequestMessage ().push_back (...);
dynamic_cast<ReportTaskIssueRequest&> (x.x1RequestMessage ().back ());

If this works as expected, then it's definitely something with the
configuration of the generated code (for example, missing
--polymorphic-type*).



More information about the xsd-users mailing list