[xsd-users] XSD Generate Extraction and Ordered Type

Southworth Damon (AA-AS/EOS32) damon.southworth at uk.bosch.com
Thu Sep 22 05:49:09 EDT 2016


Hi Boris,

> The new version generates _clone() as pure virtual for abstract (in XML Schema sense) types.

Ah yes, that makes sense.

So I have looked a bit further now into the compilation problem with the abstract classes generated by this updated compiler. The problem is related to the code generated for the binary deserialization.

There is a common block that is generated for de-serializing polymorphic types. I have shown it here with a type of XXX_type. XXX_type is an abstract class.

    bool d;
    ::std::unique_ptr< XXX_type > r;
    s >> d;

    if (!d)
        r.reset(new XXX_type(s, f, this));
    else {
        ::std::unique_ptr< ::xsd::cxx::tree::type > tmp(
            ::xsd::cxx::tree::stream_extraction_map_instance< 0, ACE_InputCDR, char >().extract(
                    s, f, this));
        r.reset(dynamic_cast<XXX_type*> (tmp.get()));
        if (r.get())
            tmp.release();
        else
            throw ::xsd::cxx::tree::not_derived< char >();
    }

There is a bool that appears to be used to indicate the presence (or not) of a following polymorphic type to be de-serialized. The problem comes in that if it is false then it instantiates a default version of XXX_type rather than the one de-serialized from the stream. However the XXX_type is abstract so it can't be instantiated.

In the schema the class member that is being de-serialized is not optional, so there will ALWAYS be one in the stream so the bool should not be required.

<xsd:element name="parameter1" type="XXX_type" minOccurs="1" maxOccurs="1"/>

Regards,

Damon.




More information about the xsd-users mailing list