--- libxml2/error.c.fix 2010-12-31 01:43:40.137387477 +0300 +++ libxml2/error.c 2010-12-31 02:45:14.973378106 +0300 @@ -464,16 +464,11 @@ __xmlRaiseError(xmlStructuredErrorFunc s } /* * Check if structured error handler set */ - if (schannel == NULL) { + if (schannel == NULL) schannel = xmlStructuredError; - /* - * if user has defined handler, change data ptr to user's choice - */ - if (schannel != NULL) - data = xmlStructuredErrorContext; - } + if ((domain == XML_FROM_VALID) && ((channel == xmlParserValidityError) || (channel == xmlParserValidityWarning))) { ctxt = (xmlParserCtxtPtr) ctx; @@ -483,8 +478,14 @@ __xmlRaiseError(xmlStructuredErrorFunc s } if (code == XML_ERR_OK) return; /* + * if user has defined handler, change data ptr to user's choice + */ + if (schannel != NULL) + data = xmlStructuredErrorContext; + + /* * Formatting the message */ if (msg == NULL) { str = (char *) xmlStrdup(BAD_CAST "No error message provided");