-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDOMErrorHandler.cc
More file actions
66 lines (60 loc) · 1.76 KB
/
DOMErrorHandler.cc
File metadata and controls
66 lines (60 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <cstdio>
#include <xercesc/util/XMLString.hpp>
#include "Error.h"
#include "UnicodeTools.h"
#include "XMLException.h"
#include "DOMErrorHandler.h"
#define XN XERCES_CPP_NAMESPACE_QUALIFIER
namespace flux {
namespace xml {
bool DOMErrorHandler::handleError(XN DOMError const & domError)
{
U2A asc_msg(domError.getMessage());
U2A asc_uri(domError.getLocation()->getURI());
switch (domError.getSeverity())
{
case XN DOMError::DOMError::DOM_SEVERITY_WARNING:
fWARNING("XML parser (warning): %s in %s; row: %i, column: %i",
(char const *)asc_msg,
(char const *)asc_uri,
int(domError.getLocation()->getLineNumber()),
int(domError.getLocation()->getColumnNumber())
);
break;
case XN DOMError::DOMError::DOM_SEVERITY_ERROR:
{
XMLException E(
#if XERCES_VERSION_MAJOR >= 3
domError.getLocation()->getRelatedNode(),
#endif
"XML parser (error): %s in %s; row: %i, column: %i",
(char const *)asc_msg,
(char const *)asc_uri,
int(domError.getLocation()->getLineNumber()),
int(domError.getLocation()->getColumnNumber())
);
E.setXMLLine(domError.getLocation()->getLineNumber());
E.setXMLColumn(domError.getLocation()->getColumnNumber());
throw E;
}
case XN DOMError::DOMError::DOM_SEVERITY_FATAL_ERROR:
{
XMLException E(
#if XERCES_VERSION_MAJOR >= 3
domError.getLocation()->getRelatedNode(),
#endif
"XML parser (fatal error): %s in %s; row: %i, column: %i",
(char const *)asc_msg,
(char const *)asc_uri,
int(domError.getLocation()->getLineNumber()),
int(domError.getLocation()->getColumnNumber())
);
E.setXMLLine(domError.getLocation()->getLineNumber());
E.setXMLColumn(domError.getLocation()->getColumnNumber());
throw E;
}
}
return true;
}
} // namespace flux::xml
} // namespace flux