Use CatchErrorHandler to report errors

This commit is contained in:
jez_higgins 2003-10-29 15:52:28 +00:00
parent b7d79f2144
commit 78c3ddc505

View file

@ -5,6 +5,7 @@
#include <string> #include <string>
#include <DOM/SAX2DOM/SAX2DOM.h> #include <DOM/SAX2DOM/SAX2DOM.h>
#include <SAX/helpers/CatchErrorHandler.h>
#include <DOM/Utils/Stream.h> #include <DOM/Utils/Stream.h>
//////////////////////////////////////////////// ////////////////////////////////////////////////
@ -18,6 +19,8 @@ int main(int argc, char* argv[])
{ // narrow { // narrow
SAX2DOM::Parser<std::string> domParser; SAX2DOM::Parser<std::string> domParser;
SAX::CatchErrorHandler<std::string> eh;
domParser.setErrorHandler(eh);
for(int i = 1; i < argc; ++i) for(int i = 1; i < argc; ++i)
{ {
@ -35,9 +38,16 @@ int main(int argc, char* argv[])
domParser.parse(is); domParser.parse(is);
} // if(file != "-") } // if(file != "-")
DOM::Document<std::string> doc = domParser.getDocument(); if(!eh.errorsReported())
{
std::cout << doc; DOM::Document<std::string> doc = domParser.getDocument();
std::cout << doc;
}
else
{
std::cerr << eh.errors() << std::endl;
eh.reset();
} // if ...
} // for ... } // for ...
} }