[xsd-users] Support for a sequence of choice elements of polymorphic type

Boris Kolpackov boris at codesynthesis.com
Thu Oct 10 11:50:43 EDT 2013


Hi Damon,

Damon Southworth <xsd at cloudydaze.co.uk> writes:

> Can the xsd cxx XML compiler also produce a single list of objects
> with a type of the common parent class for the polymorphic choices
> with a common parent class rather than a sperate list of each
> choice.?

Yes, but you will need to modify the schema a bit (you can do it
only for the XSD-to-C++ compilation): you will need to create
an abstract substitution group root element (of type Element_Type)
and use it as the only element in MyListType. Then derive Element_A
and Element_B from this root element (in the substitution groups
sense). This way they can be substituted for the element in
MyListType. Once this is done, compile your schema with the
--generate-polymorphic --polymorphic-type Element_Type options,
and you will get a sequence that will contain either Element_A
or Element_B, polymorphically

Boris



More information about the xsd-users mailing list