[xsd-users] std::ostream setprecision() causes invalid output for ::xml_schema::date_time

Jeroen N. Witmond jeroennwitmond at gmail.com
Sun May 10 15:49:41 EDT 2020


Greetings!

When using setprecision(std::numeric_limits<long double>::digits10 + 1) on
the output stream, the ::xml_schema::date_time value written to it will
fail validation when the number of seconds is less than 10. Note that the
call to setprecision() need not be in the same statement as the output of
the ::xml_schema::date_time value; it can even be in a different source
file.

For instance: The value "2020-05-01T06:06:04.000Z" will be written as
"2020-05-01T06:06:4.0000000000000000000Z" which will result in error
message "error: invalid character encountered" when parsed. Adding a zero
between the colon and the four removes the error.

I'm aware that careless use of setprecision() can be regarded as a user
error; in that case this message will serve as a warning.

I'm using C++/Tree version 4.0.0 with Xerces-C 3.1.4. A full testcase can
be provided on request.

Regards,

Jeroen.


More information about the xsd-users mailing list