diff --git a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp index 5ea7d734b1302d9917e38ad4fbe7e187bcc92149..a2f0788ea5d1123d06986f82af2edd1e04d6fcab 100644 --- a/src/xercesc/validators/schema/GeneralAttributeCheck.cpp +++ b/src/xercesc/validators/schema/GeneralAttributeCheck.cpp @@ -14,10 +14,6 @@ * limitations under the License. */ -/* - * $Id $ - */ - // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- @@ -432,7 +428,7 @@ void GeneralAttributeCheck::validate(const DOMElement* const elem, dv->validate(attValue, fValidationContext, fMemoryManager); } catch(const XMLException& excep) { - schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); + schema->reportSchemaError(elem, excep); } catch(const OutOfMemoryException&) { diff --git a/src/xercesc/validators/schema/SchemaValidator.cpp b/src/xercesc/validators/schema/SchemaValidator.cpp index 7327a78a56672f508d7a883a7a30f7c8b57cb984..5ac25aeefb6dfb6fb380af3f851a7ba376b8888b 100644 --- a/src/xercesc/validators/schema/SchemaValidator.cpp +++ b/src/xercesc/validators/schema/SchemaValidator.cpp @@ -14,10 +14,6 @@ * limitations under the License. */ -/* - * $Id $ - */ - // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- @@ -909,7 +905,7 @@ void SchemaValidator::preContentValidation(bool, baseGroup->getContentSpec(), baseGroup->getScope()); } catch (const XMLException& excep) { - fSchemaErrorReporter.emitError(XMLErrs::DisplayErrorMessage, XMLUni::fgXMLErrDomain, curGroup.getLocator(), excep.getMessage(), 0, 0, 0, fMemoryManager); + fSchemaErrorReporter.emitError(excep, curGroup.getLocator()); } } @@ -1093,7 +1089,7 @@ void SchemaValidator::checkParticleDerivation(SchemaGrammar* const currentGramma baseTypeInfo->getScopeDefined(), baseTypeInfo); } catch (const XMLException& excep) { - fSchemaErrorReporter.emitError(XMLErrs::DisplayErrorMessage, XMLUni::fgXMLErrDomain, curTypeInfo->getLocator(), excep.getMessage(), 0, 0, 0, fMemoryManager); + fSchemaErrorReporter.emitError(excep, curTypeInfo->getLocator()); } } } diff --git a/src/xercesc/validators/schema/TraverseSchema.cpp b/src/xercesc/validators/schema/TraverseSchema.cpp index dc837783eb2d0f5f39f3fbc76effd4634d6869fd..d4326f2b78eb9302ee726a4d468bccfd6434b067 100644 --- a/src/xercesc/validators/schema/TraverseSchema.cpp +++ b/src/xercesc/validators/schema/TraverseSchema.cpp @@ -14,10 +14,6 @@ * limitations under the License. */ -/* - * $Id$ - */ - // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- @@ -1986,7 +1982,7 @@ TraverseSchema::traverseAny(const DOMElement* const elem) { , fMemoryManager); } catch(const XMLException& excep) { - reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(elem, excep); } uriIndex = fURIStringPool->addOrFind(tokenElem); } @@ -2429,7 +2425,7 @@ void TraverseSchema::traverseAttributeDecl(const DOMElement* const elem, , fMemoryManager); } catch (const XMLException& excep) { - reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(elem, excep); } catch(const OutOfMemoryException&) { @@ -3007,7 +3003,7 @@ TraverseSchema::traverseByList(const DOMElement* const rootElem, qualifiedName, baseValidator, 0, 0, true, finalSet, true, fGrammarPoolMemoryManager); } catch (const XMLException& excep) { - reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(contentElem, excep); } catch(const OutOfMemoryException&) { @@ -3277,7 +3273,7 @@ TraverseSchema::traverseByRestriction(const DOMElement* const rootElem, newDV = fDatatypeRegistry->createDatatypeValidator(qualifiedName, baseValidator, janFacets.release(), enums.release(), false, finalSet, true, fGrammarPoolMemoryManager); } catch (const XMLException& excep) { - reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(contentElem, excep); } catch(const OutOfMemoryException&) { @@ -3411,7 +3407,7 @@ TraverseSchema::traverseByUnion(const DOMElement* const rootElem, newDV = fDatatypeRegistry->createDatatypeValidator(qualifiedName, validators, finalSet, true, fGrammarPoolMemoryManager); } catch (const XMLException& excep) { - reportSchemaError(contentElem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(contentElem, excep); } catch(const OutOfMemoryException&) { @@ -3783,7 +3779,7 @@ void TraverseSchema::traverseSimpleContentDecl(const XMLCh* const typeName, typeInfo->setDatatypeValidator(simpleDV); } catch (const XMLException& excep) { - reportSchemaError(simpleContent, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(simpleContent, excep); } catch(const OutOfMemoryException&) { @@ -4092,7 +4088,7 @@ SchemaAttDef* TraverseSchema::traverseAnyAttribute(const DOMElement* const elem) , fMemoryManager); } catch(const XMLException& excep) { - reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(elem, excep); } uriIndex = fURIStringPool->addOrFind(token); } @@ -4426,7 +4422,7 @@ bool TraverseSchema::traverseIdentityConstraint(IdentityConstraint* const ic, } catch (const XPathException& e) { - reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, e.getMessage()); + reportSchemaError(elem, e); return false; } @@ -4499,7 +4495,7 @@ bool TraverseSchema::traverseIdentityConstraint(IdentityConstraint* const ic, } catch (const XPathException& e) { - reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::DisplayErrorMessage, e.getMessage()); + reportSchemaError(elem, e); return false; } } @@ -5855,7 +5851,7 @@ void TraverseSchema::processAttributeDeclRef(const DOMElement* const elem, , fMemoryManager); } catch(const XMLException& excep) { - reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(elem, excep); } catch(const OutOfMemoryException&) { @@ -8468,6 +8464,16 @@ void TraverseSchema::reportSchemaError(const DOMElement* const elem, fXSDErrorReporter.emitError(errorCode, msgDomain, fLocator, text1, text2, text3, text4, fMemoryManager); } +void TraverseSchema::reportSchemaError(const DOMElement* const elem, + const XMLException& except) +{ + fLocator->setValues(fSchemaInfo->getCurrentSchemaURL(), 0, + ((XSDElementNSImpl*) elem)->getLineNo(), + ((XSDElementNSImpl*) elem)->getColumnNo()); + + fXSDErrorReporter.emitError(except, fLocator); +} + // --------------------------------------------------------------------------- // TraverseSchema: Init/CleanUp methods // --------------------------------------------------------------------------- @@ -8663,7 +8669,7 @@ TraverseSchema::checkElemDeclValueConstraint(const DOMElement* const elem, } catch(const XMLException& excep) { - reportSchemaError(elem, XMLUni::fgValidityDomain, XMLValid::DisplayErrorMessage, excep.getMessage()); + reportSchemaError(elem, excep); } catch(const OutOfMemoryException&) { diff --git a/src/xercesc/validators/schema/TraverseSchema.hpp b/src/xercesc/validators/schema/TraverseSchema.hpp index 0387d971bb58338016a81aee54be461038878dd0..7bc0e3d4ed1e3dc012cb9a3b29027e490c3ef235 100644 --- a/src/xercesc/validators/schema/TraverseSchema.hpp +++ b/src/xercesc/validators/schema/TraverseSchema.hpp @@ -14,10 +14,6 @@ * limitations under the License. */ -/* - * $Id$ - */ - #if !defined(TRAVERSESCHEMA_HPP) #define TRAVERSESCHEMA_HPP @@ -227,6 +223,8 @@ private: const XMLCh* const text2 = 0, const XMLCh* const text3 = 0, const XMLCh* const text4 = 0); + void reportSchemaError(const DOMElement* const elem, + const XMLException& except); // ----------------------------------------------------------------------- // Private Helper methods diff --git a/src/xercesc/validators/schema/XSDErrorReporter.cpp b/src/xercesc/validators/schema/XSDErrorReporter.cpp index bf64ce01cfcd1ef4c0d823847066fff1dffad18d..8b0ca8b0eb86e912803933d375d1f0f56713e511 100644 --- a/src/xercesc/validators/schema/XSDErrorReporter.cpp +++ b/src/xercesc/validators/schema/XSDErrorReporter.cpp @@ -14,11 +14,6 @@ * limitations under the License. */ -/* - * $Id$ - */ - - // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- @@ -230,4 +225,21 @@ void XSDErrorReporter::emitError(const unsigned int toEmit, throw (XMLErrs::Codes) toEmit; } +void XSDErrorReporter::emitError(const XMLException& except, + const Locator* const aLocator) +{ + const XMLCh* const errText = except.getMessage(); + const unsigned int toEmit = except.getCode(); + XMLErrorReporter::ErrTypes errType = XMLErrs::errorType((XMLErrs::Codes) toEmit); + + if (fErrorReporter) + fErrorReporter->error(toEmit, XMLUni::fgExceptDomain, errType, errText, aLocator->getSystemId(), + aLocator->getPublicId(), aLocator->getLineNumber(), + aLocator->getColumnNumber()); + + // Bail out if its fatal an we are to give up on the first fatal error + if (errType == XMLErrorReporter::ErrType_Fatal && fExitOnFirstFatal) + throw (XMLErrs::Codes) toEmit; +} + XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/validators/schema/XSDErrorReporter.hpp b/src/xercesc/validators/schema/XSDErrorReporter.hpp index 6cfc7ca2d6ab59d35738cb24f858f6513ca64a6d..106cd9eb9ff69b821fdce8806932e0e56237542c 100644 --- a/src/xercesc/validators/schema/XSDErrorReporter.hpp +++ b/src/xercesc/validators/schema/XSDErrorReporter.hpp @@ -14,11 +14,6 @@ * limitations under the License. */ - /* - * $Id$ - */ - - #if !defined(XSDERRORREPORTER_HPP) #define XSDERRORREPORTER_HPP @@ -71,6 +66,8 @@ public: const XMLCh* const text4 = 0, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); + void emitError(const XMLException& except, + const Locator* const aLocator); private: // -----------------------------------------------------------------------