[xsd-users] Boost date customization in xsd
Boris Kolpackov
boris at codesynthesis.com
Thu May 14 09:05:31 EDT 2009
Hi,
vherard at alphasqr.com <vherard at alphasqr.com> writes:
> I added a constructor to the example you provide that takes a Boost
> date as input and I'm concerned that the simple_type base class is
> not correctly initialized.
>
> date::
> date (const gregorian :: date& d)
> : simple_type ( boost :: gregorian :: to_extended_iso_string (d) , NULL , 0 , 0 ) ,
> gregorian::date (d)
> {
> }
The simple_type type has the default c-tor which should be used in this
case:
date::
date (const gregorian::date& d)
: gregorian::date (d)
{
}
> When I serialize classes that use customized dates, I get incorrect
> output.
You need to implement serialization operators for the custom date type,
something along these lines:
namespace xml_schema
{
void
operator<< (xercesc::DOMElement& e, const date& d)
{
e << to_extended_iso_string (d);
}
void
operator<< (xercesc::DOMAttr& a, const date& d)
{
a << to_extended_iso_string (d);
}
void
operator<< (xml_schema::list_stream& ls, const date& d)
{
ls.os_ << to_extended_iso_string (d);
}
}
Boris
More information about the xsd-users
mailing list