[xsd-users] Issue on parsing of one element which is of different types

Boris Kolpackov boris at codesynthesis.com
Wed Apr 2 05:52:22 EDT 2008


Hi Sirigiri,

Sirigiri Madhavi <smadhavi at prokarma.com> writes:

> When I generate driver (notifications_v200701-driver.cxx) file
> automatically I didn't get any parser calls in that except the
> below one :
>
>  EventMessages_p.parsers (EventMessage_p);

The generated sample test driver does not instantiate and connect
parsers for polymorphic cases. It is generally not possible to do
since there is no way to know which types can and cannot be used
in xsi:type. You will need to add extra parser() calls with derived
types yourself.


> If  I give manually EventMessages_p.parsers (AlertClosure_p); it is
> printing the values.
>
> But I want to connect both types (AlertOpen and AlertClosure) of
> EventMessage parser automatically with the EventMessages parser.

Then you need to add:

EventMessages_p.parser (AlertOpen_p);
EventMessages_p.parser (AlertClosure_p);

To the call for EventMessage_p that is generated automatically. This
is all covered in Section 5.4, "Support for Polymorphism" in the
C++/Parser Getting Started Guide:

http://codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.4

As we all in the 'polymorphism' example.

Boris




More information about the xsd-users mailing list