diff --git a/src/xercesc/framework/XMLValidator.cpp b/src/xercesc/framework/XMLValidator.cpp index 119cac2980ed211ee9dc2e9043c96b4f12a7920f..9c3d434fc8a87f5e518ef9ebb8606d9a3e7cf044 100644 --- a/src/xercesc/framework/XMLValidator.cpp +++ b/src/xercesc/framework/XMLValidator.cpp @@ -270,6 +270,64 @@ void XMLValidator::emitError(const XMLValid::Codes toEmit } } +void XMLValidator::emitError(const XMLValid::Codes toEmit + , const XMLExcepts::Codes originalExceptCode + , const XMLCh* const text1 + , const XMLCh* const text2 + , const XMLCh* const text3 + , const XMLCh* const text4) +{ + // Bump the error count if it is not a warning + if (XMLValid::errorType(toEmit) != XMLErrorReporter::ErrType_Warning) + fScanner->incrementErrorCount(); + + // Call error reporter if we have one + if (fErrorReporter) + { + // + // Load the message into alocal and replace any tokens found in + // the text. + // + const unsigned int maxChars = 2047; + XMLCh errText[maxChars + 1]; + + // load the text + if (!getMsgLoader().loadMsg(toEmit, errText, maxChars, text1, text2, text3, text4, fScanner->getMemoryManager())) + { + // <TBD> Should probably load a default message here + } + + // + // Create a LastExtEntityInfo structure and get the reader manager + // to fill it in for us. This will give us the information about + // the last reader on the stack that was an external entity of some + // sort (i.e. it will ignore internal entities. + // + ReaderMgr::LastExtEntityInfo lastInfo; + fReaderMgr->getLastExtEntityInfo(lastInfo); + + fErrorReporter->error + ( + originalExceptCode + , XMLUni::fgExceptDomain //XMLUni::fgValidityDomain + , XMLValid::errorType(toEmit) + , errText + , lastInfo.systemId + , lastInfo.publicId + , lastInfo.lineNumber + , lastInfo.colNumber + ); + } + + // Bail out if its fatal an we are to give up on the first fatal error + if (((XMLValid::isError(toEmit) && fScanner->getValidationConstraintFatal()) + || XMLValid::isFatal(toEmit)) + && fScanner->getExitOnFirstFatal() + && !fScanner->getInException()) + { + throw toEmit; + } +} // --------------------------------------------------------------------------- // XMLValidator: Hidden Constructors diff --git a/src/xercesc/framework/XMLValidator.hpp b/src/xercesc/framework/XMLValidator.hpp index b00f108a014fd427222eddb40ff73290b81cbc4d..3b61e790b6b9ca8391469fbc2320cb0807f28b5c 100644 --- a/src/xercesc/framework/XMLValidator.hpp +++ b/src/xercesc/framework/XMLValidator.hpp @@ -304,6 +304,16 @@ public: , const char* const text2 = 0 , const char* const text3 = 0 , const char* const text4 = 0 + ); + void emitError + ( + const XMLValid::Codes toEmit + , const XMLExcepts::Codes originalErrorCode + , const XMLCh* const text1 = 0 + , const XMLCh* const text2 = 0 + , const XMLCh* const text3 = 0 + , const XMLCh* const text4 = 0 + ); //@}