After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 346414 - Relax NG validation errors sent to stderr rather than registered error callback
Relax NG validation errors sent to stderr rather than registered error callback
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: relaxng
2.6.x
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-07-02 20:14 UTC by Todd Ditchendorf
Modified: 2019-01-30 11:16 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Todd Ditchendorf 2006-07-02 20:14:21 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));
Comment 1 Todd Ditchendorf 2006-07-04 01:50:29 UTC
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.