Definition at line 168 of file XmlFileReader.h. References Impala::Persistency::DOMTreeErrorReporter::getSawErrors(), and mParser. Referenced by Read(). 00169 { 00170 // 00171 // Create a parser, then attach an error handler to it. 00172 // The parser will call back to methods of the ErrorHandler if it 00173 // discovers errors during the course of parsing the XML document. 00174 // 00175 mParser = new XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser; 00176 mParser->setValidationScheme(XERCES_CPP_NAMESPACE_QUALIFIER XercesDOMParser::Val_Auto); 00177 mParser->setDoNamespaces(false); 00178 mParser->setDoSchema(false); 00179 mParser->setValidationSchemaFullChecking(false); 00180 mParser->setCreateEntityReferenceNodes(false); 00181 00182 DOMTreeErrorReporter *errReporter = new DOMTreeErrorReporter(); 00183 mParser->setErrorHandler(errReporter); 00184 00185 // 00186 // Parse the XML file, catching any XML exceptions that might propagate 00187 // out of it. 00188 // 00189 bool errorsOccured = false; 00190 00191 typedef XERCES_CPP_NAMESPACE_QUALIFIER MemBufInputSource MemBufInputSource; 00192 MemBufInputSource memBuf(ioBuf->GetBuffer(), ioBuf->Size(), 00193 filePath.c_str(), false); 00194 try 00195 { 00196 mParser->parse(memBuf); 00197 //mParser->parse(filePath.c_str()); // SK: error handling is niet goed, want geen exception wanneer verkeerd adres. 00198 } 00199 00200 catch (const XERCES_CPP_NAMESPACE_QUALIFIER OutOfMemoryException&) 00201 { 00202 // log something 00203 std::cout << "OutOfMemoryException!!!" << std::endl; 00204 errorsOccured = true; 00205 } 00206 00207 catch (const XERCES_CPP_NAMESPACE_QUALIFIER XMLException& /*e*/) 00208 { 00209 // log something 00210 // std::cout << "XMLException occurred while parsing; message: " << StrX(e.getMessage()) << std::endl; 00211 errorsOccured = true; 00212 } 00213 00214 catch (const XERCES_CPP_NAMESPACE_QUALIFIER DOMException& e) 00215 { 00216 // log something 00217 std::cout << "\nDOM Error during parsing: '" << filePath << "'\n" 00218 << "DOMException code is: " << e.code << std::endl; 00219 00220 // const unsigned int maxChars = 2047; 00221 // XMLCh errText[maxChars + 1]; 00222 // if (DOMImplementation::loadDOMExceptionMsg(e.code, errText, maxChars)) 00223 // std::cout << "Message is: " << StrX(errText) << std::endl; 00224 00225 errorsOccured = true; 00226 } 00227 00228 catch (...) 00229 { 00230 std::cout << "An error occurred during parsing\n " << std::endl; 00231 errorsOccured = true; 00232 } 00233 00234 // If the parse was successful, get the document data from the DOM tree 00235 XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *repositoryDoc = 0; 00236 if (!errorsOccured && !errReporter->getSawErrors()) 00237 { 00238 repositoryDoc = mParser->getDocument(); 00239 } 00240 00241 // 00242 // Clean up the error handler. The parser does not adopt handlers 00243 // since they could be many objects or one object installed for multiple 00244 // handlers. 00245 // 00246 delete errReporter; 00247 00248 return repositoryDoc; 00249 }
Here is the call graph for this function:
|