[xsd-users] Help me: How do I redirect the exception message from console output to a memory buffer

Boris Kolpackov boris at codesynthesis.com
Fri Oct 16 04:52:44 EDT 2009


Hi James,

James Mei <jxmei3 at gmail.com> writes:

> May I know how do I get/redirect the exception message (mainly for
> validation), from cerr to a memory buffer so that I can pipe to a file 
> or reformat it on the screen ?

You can use std::ostringstream to serialize the diagnostics to a string.
You can also programmatically access each parsing/serialization diagnostics
message by catching the xml_schema::parsing and/or xml_schema::validation
exceptions and using their accessors to extract this information. For
details, see Section 3.3, "Error Handling" in the C++/Tree Mapping User 
Manual:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#3.3

Boris



More information about the xsd-users mailing list