[xsde-users] Porting Xerces/XSD project to XSD/e and differences in
generated code
Andrey Filimonov
andrey.v.filimonov at gmail.com
Sun Nov 8 08:05:30 EST 2015
Hello,
I'm trying to port an existing project which uses XSD as a XSD to C++
converter to an embedded environment. So I made an attempt to replace code,
generated by XSD, to code, produced by XSD/e, keeping the rest of
implementation as is.
The attempt failed due to differences in code generated by XSD and XSD/e.
I'm now trying to udnerstand is these differences are becasue of core
features of XSD and XSD/e or i missed something in XSD/e configuration and
these differences can be eliminated.
I'm trying to compile a somewhat XSD containing these relevant parts:
<xs:element name="date-time" type="xcal:DateTimeType"/>
<!-- ******* DateTimeType ******** -->
<xs:simpleType name="DateTimeType">
<xs:restriction base="xs:dateTime">
<xs:pattern
value="(\-|\+)?\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}(\.\d*)?Z?"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="dtstart">
<xs:annotation>
<xs:documentation>The starting time for the activity, data, or
state change</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="xcal:date-time"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Both XSD and XSD/e produce a named type called dtstart, but the content is
different. For XSD it's
class dtstart: public ::xml_schema::type
{
public:
// date-time
//
typedef ::icalendar_2_0::DateTimeType date_time_type;
typedef ::xsd::cxx::tree::traits< date_time_type, char >
date_time_traits;
const date_time_type&
date_time () const;
date_time_type&
date_time ();
void
date_time (const date_time_type& x);
void
date_time (::std::auto_ptr< date_time_type > p);
// Constructors.
//
dtstart (const date_time_type&);
dtstart (::std::auto_ptr< date_time_type >);
dtstart (const ::xercesc::DOMElement& e,
::xml_schema::flags f = 0,
::xml_schema::container* c = 0);
dtstart (const dtstart& x,
::xml_schema::flags f = 0,
::xml_schema::container* c = 0);
virtual dtstart*
_clone (::xml_schema::flags f = 0,
::xml_schema::container* c = 0) const;
dtstart&
operator= (const dtstart& x);
virtual
~dtstart ();
// Implementation.
//
protected:
void
parse (::xsd::cxx::xml::dom::parser< char >&,
::xml_schema::flags);
protected:
::xsd::cxx::tree::one< date_time_type > date_time_;
};
For XSD/e it's
class dtstart
{
public:
dtstart ();
dtstart (const dtstart&);
dtstart& operator= (const dtstart&);
~dtstart ();
// date-time
//
const ::icalendar_2_0::DateTimeType&
date_time () const;
::icalendar_2_0::DateTimeType&
date_time ();
void
date_time (const ::icalendar_2_0::DateTimeType&);
private:
::icalendar_2_0::DateTimeType date_time_;
};
The difference breaking the further project compilation is in XSD/e's
output not containing a constructor for constructing from DateTimeType
while XSD's version do contain.
Is there a way to eliminate such a difference?
XSD code originally is generated with the following options:
cxx-tree --file-per-type --generate-serialization --generate-polymorphic
--polymorphic-type-all
The XSD/e code is generated with
cxx-hybrid --file-per-type --generate-polymorphic --no-stl --no-exceptions
--custom-allocator --no-iostream --no-long-long --generate-serializer
--generate-parser --suppress-serializer-val
Andrey.
More information about the xsde-users
mailing list