See the XML docs for xmlSetGenericErrorFunc(), xmlRelaxNGSetParserErrors(), and xmlRelaxNGSetValidErrors()