[xsd-users] XSD compiler generate bad constructor. Ambiguous call to overloaded function

Boris Kolpackov boris at codesynthesis.com
Thu Jan 31 07:09:50 EST 2013


Hi Ulf,

Haga, Ulf <Ulf.Haga at gyros.com> writes:

>             <xs:element name="GyrolabContent" minOccurs="0" maxOccurs="1">
>                 <xs:complexType>
>                     <xs:sequence>
>                         <xs:any processContents="skip">
>                         </xs:any>
>                     </xs:sequence>
>                 </xs:complexType>
>             </xs:element>

Yes, in this special case (i.e., a type with a single wildcard and no
other required elements or attributes), XSD-generated constructors are
ambiguous:

    GyrolabContent (const ::xercesc::DOMElement&);

    GyrolabContent (const ::xercesc::DOMElement& e,
                    ::xml_schema::flags f = 0,
                    ::xml_schema::container* c = 0);

The first constructor is meant to set the wildcard while the second
is the standard parsing constructor.

Unfortunately, there doesn't seem to be a good way to fix this. So
in this special case you can use the following work around:

1. Generate the default constructor with the --generate-default-ctor

2. Initialize the element in two steps:

   const DOMElement& e = ...

   GyrolabContent x;
   x.any (e);

Note also that calling the second constructor does not have the same
semantics.

Thanks for reporting this!

Boris



More information about the xsd-users mailing list