[xsd-users] Validation results not as expected.

Boris Kolpackov boris at codesynthesis.com
Wed Jan 27 07:30:26 EST 2010


Hi Stephen,

Stephen James <Stephen.James at genband.com> writes:

> I basically copied the code from your driver example for initializing
> the DOM and parsing, the only difference I could find was that I was
> reading the xml document from a buffer, rather than from a stream. Note,
> my DOMLSParser* object and my tree::error_handler objects are file local
> static objects.

I can't think of any reason this would cause the errors to disappear.


> >From the working standalone code
>                 xml::sax::std_input_source isrc (ifs, argv[j]);
>                 Wrapper4InputSource wrap (&isrc, false);
> 
> Code that is not detecting all errors:
> 	XMLCh bufid;
> 	MemBufInputSource mem(buffer, len, &bufid);
> 	Wrapper4InputSource wrap (&mem, false);

Passing uninitialized bufid as a buffer id string is a bad idea. This 
id is used in diagnostics to identify the document being parsed. Rather,
do something like this:

MemBufInputSource mem(buffer, len, "<buffer>");

This way you will get diagnostics like this:

<buffer>:12:34 error: unterminated element tag


> Also, how would I reset the error handler in the error_handler_proxy
> object?

There is no way to reset the error_handler object in 3.2.0 (this has
been fixed for the upcoming 3.3.0). So you can either create a new
error_handler instance for each parse episode (this is cheap) or
I can send you a patch for 3.2.0 that implements the reset functions.

Can you also make sure you have this line after the call to 
DOMLSParser::parse():

eh.throw_if_failed<tree::parsing<char> > ();

Boris



More information about the xsd-users mailing list