GNOME Bugzilla – Bug 346414
Relax NG validation errors sent to stderr rather than registered error callback
Last modified: 2019-01-30 11:16:11 UTC
Please describe the problem: I'm using the C RELAX NG API with xmlTextReader. I'm trying to register error callback functions for validity errors encoundtered in my instance document. These are the validity errors that arrise because the instance doc does not conform to my RNG. I seem to be able to register handlers for all types of errors when parsing my RNG schema, and also well- formedness errors in my instance document. I can't seem to register error callbacks for *validity* errors in my instance doc as mandated by my RNG schema. PS. thanks for the great toolkit! Steps to reproduce: 1. create xmlTextReader 2. associate Relax NG schema with xmlTextReader 3. assign error and warning handlers to xmlTextReader (xmlTextReaderSetErrorHandler, etc) 4. Parse instance doc with validity errors Actual results: Relax NG validation errors are reported to stderr, but my callback functions are not called. Note that after the document has been parse, the reader *does* report correctly whether it was valid or not. Expected results: Would expect validity error callbacks to be called Does this happen every time? yes Other information: char *docfurl = ".../golf.xml"; char *schemafurl = ".../golf.rng"; // RELAX NG Parser Context xmlRelaxNGParserCtxtPtr ctxt = xmlRelaxNGNewParserCtxt(schemafurl); xmlRelaxNGSetParserErrors(ctxt, (xmlRelaxNGValidityErrorFunc)rngErr, (xmlRelaxNGValidityWarningFunc)rngWarn, NULL); // Parse schema xmlRelaxNGPtr schema = xmlRelaxNGParse(ctxt); // create reader xmlTextReaderPtr reader = xmlNewTextReaderFilename(docfurl); // associtate schema with reader xmlTextReaderRelaxNGSetSchema(reader, schema); // register some callbacks (apparently not the right ones) // never seems to be called xmlTextReaderSetErrorHandler(reader, (xmlTextReaderErrorFunc) readerErr, NULL); while (xmlTextReaderRead(reader)) ; NSLog(@"done. isValid: %i", xmlTextReaderIsValid(reader));
To Daniel/friendly neighborhood libxml2 developers, Please accept my apologies. I believe I was mistaken about this bug. This bug does *not* exist in 2.6.26 as I reported. I *does* exist in 2.6.16 which I believe is the version that shipped with Mac OS X 10.4 Tiger. I was using this built-in version (2.6.16) mistakenly when running my tests. I had thought I was using 2.6.26, but I was wrong. The bug no longer exists in 2.6.26 as far as I can tell. Apparently it was fixed sometime between the two versions. In 2.6.26, the "xmlStructuredErrorFunc" reports RNG validity errors. I had assumed that the "xmlTextReaderErrorFunc" would report these, but I guess I was wrong about that too. Thanks again for all your work on this great product.