1 | /*
|
---|
2 | * Copyright 1999-2000,2004 The Apache Software Foundation.
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | */
|
---|
16 |
|
---|
17 | /*
|
---|
18 | * $Log: ErrorHandler.hpp,v $
|
---|
19 | * Revision 1.6 2004/09/08 13:56:19 peiyongz
|
---|
20 | * Apache License Version 2.0
|
---|
21 | *
|
---|
22 | * Revision 1.5 2003/12/01 23:23:26 neilg
|
---|
23 | * fix for bug 25118; thanks to Jeroen Witmond
|
---|
24 | *
|
---|
25 | * Revision 1.4 2003/05/30 16:11:44 gareth
|
---|
26 | * Fixes so we compile under VC7.1. Patch by Alberto Massari.
|
---|
27 | *
|
---|
28 | * Revision 1.3 2003/03/07 18:10:06 tng
|
---|
29 | * Return a reference instead of void for operator=
|
---|
30 | *
|
---|
31 | * Revision 1.2 2002/11/04 14:56:25 tng
|
---|
32 | * C++ Namespace Support.
|
---|
33 | *
|
---|
34 | * Revision 1.1.1.1 2002/02/01 22:22:08 peiyongz
|
---|
35 | * sane_include
|
---|
36 | *
|
---|
37 | * Revision 1.6 2000/04/27 19:33:15 rahulj
|
---|
38 | * Included <util/XercesDefs.hpp> as suggested by David N Bertoni.
|
---|
39 | *
|
---|
40 | * Revision 1.5 2000/02/24 20:12:55 abagchi
|
---|
41 | * Swat for removing Log from API docs
|
---|
42 | *
|
---|
43 | * Revision 1.4 2000/02/12 03:31:55 rahulj
|
---|
44 | * Removed duplicate CVS Log entries.
|
---|
45 | *
|
---|
46 | * Revision 1.3 2000/02/12 01:27:19 aruna1
|
---|
47 | * Documentation updated
|
---|
48 | *
|
---|
49 | * Revision 1.2 2000/02/06 07:47:57 rahulj
|
---|
50 | * Year 2K copyright swat.
|
---|
51 | *
|
---|
52 | * Revision 1.1.1.1 1999/11/09 01:07:45 twl
|
---|
53 | * Initial checkin
|
---|
54 | *
|
---|
55 | * Revision 1.2 1999/11/08 20:45:00 rahul
|
---|
56 | * Swat for adding in Product name and CVS comment log variable.
|
---|
57 | *
|
---|
58 | */
|
---|
59 |
|
---|
60 |
|
---|
61 | #ifndef ERRORHANDLER_HPP
|
---|
62 | #define ERRORHANDLER_HPP
|
---|
63 |
|
---|
64 | #include <xercesc/util/XercesDefs.hpp>
|
---|
65 |
|
---|
66 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
67 |
|
---|
68 | class SAXParseException;
|
---|
69 |
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Basic interface for SAX error handlers.
|
---|
73 | *
|
---|
74 | * <p>If a SAX application needs to implement customized error
|
---|
75 | * handling, it must implement this interface and then register an
|
---|
76 | * instance with the SAX parser using the parser's setErrorHandler
|
---|
77 | * method. The parser will then report all errors and warnings
|
---|
78 | * through this interface.</p>
|
---|
79 | *
|
---|
80 | * <p> The parser shall use this interface instead of throwing an
|
---|
81 | * exception: it is up to the application whether to throw an
|
---|
82 | * exception for different types of errors and warnings. Note,
|
---|
83 | * however, that there is no requirement that the parser continue to
|
---|
84 | * provide useful information after a call to fatalError (in other
|
---|
85 | * words, a SAX driver class could catch an exception and report a
|
---|
86 | * fatalError).</p>
|
---|
87 | *
|
---|
88 | * <p>The HandlerBase class provides a default implementation of this
|
---|
89 | * interface, ignoring warnings and recoverable errors and throwing a
|
---|
90 | * SAXParseException for fatal errors. An application may extend
|
---|
91 | * that class rather than implementing the complete interface
|
---|
92 | * itself.</p>
|
---|
93 | *
|
---|
94 | * @see Parser#setErrorHandler
|
---|
95 | * @see SAXParseException#SAXParseException
|
---|
96 | * @see HandlerBase#HandlerBase
|
---|
97 | */
|
---|
98 |
|
---|
99 | class SAX_EXPORT ErrorHandler
|
---|
100 | {
|
---|
101 | public:
|
---|
102 | /** @name Constructors and Destructor */
|
---|
103 | //@{
|
---|
104 | /** Default constructor */
|
---|
105 | ErrorHandler()
|
---|
106 | {
|
---|
107 | }
|
---|
108 |
|
---|
109 | /** Desctructor */
|
---|
110 | virtual ~ErrorHandler()
|
---|
111 | {
|
---|
112 | }
|
---|
113 | //@}
|
---|
114 |
|
---|
115 | /** @name The error handler interface */
|
---|
116 | //@{
|
---|
117 | /**
|
---|
118 | * Receive notification of a warning.
|
---|
119 | *
|
---|
120 | * <p>SAX parsers will use this method to report conditions that
|
---|
121 | * are not errors or fatal errors as defined by the XML 1.0
|
---|
122 | * recommendation. The default behaviour is to take no action.</p>
|
---|
123 | *
|
---|
124 | * <p>The SAX parser must continue to provide normal parsing events
|
---|
125 | * after invoking this method: it should still be possible for the
|
---|
126 | * application to process the document through to the end.</p>
|
---|
127 | *
|
---|
128 | * @param exc The warning information encapsulated in a
|
---|
129 | * SAX parse exception.
|
---|
130 | * @exception SAXException Any SAX exception, possibly
|
---|
131 | * wrapping another exception.
|
---|
132 | * @see SAXParseException#SAXParseException
|
---|
133 | */
|
---|
134 | virtual void warning(const SAXParseException& exc) = 0;
|
---|
135 |
|
---|
136 | /**
|
---|
137 | * Receive notification of a recoverable error.
|
---|
138 | *
|
---|
139 | * <p>This corresponds to the definition of "error" in section 1.2
|
---|
140 | * of the W3C XML 1.0 Recommendation. For example, a validating
|
---|
141 | * parser would use this callback to report the violation of a
|
---|
142 | * validity constraint. The default behaviour is to take no
|
---|
143 | * action.</p>
|
---|
144 | *
|
---|
145 | * <p>The SAX parser must continue to provide normal parsing events
|
---|
146 | * after invoking this method: it should still be possible for the
|
---|
147 | * application to process the document through to the end. If the
|
---|
148 | * application cannot do so, then the parser should report a fatal
|
---|
149 | * error even if the XML 1.0 recommendation does not require it to
|
---|
150 | * do so.</p>
|
---|
151 | *
|
---|
152 | * @param exc The error information encapsulated in a
|
---|
153 | * SAX parse exception.
|
---|
154 | * @exception SAXException Any SAX exception, possibly
|
---|
155 | * wrapping another exception.
|
---|
156 | * @see SAXParseException#SAXParseException
|
---|
157 | */
|
---|
158 | virtual void error(const SAXParseException& exc) = 0;
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * Receive notification of a non-recoverable error.
|
---|
162 | *
|
---|
163 | * <p>This corresponds to the definition of "fatal error" in
|
---|
164 | * section 1.2 of the W3C XML 1.0 Recommendation. For example, a
|
---|
165 | * parser would use this callback to report the violation of a
|
---|
166 | * well-formedness constraint.</p>
|
---|
167 | *
|
---|
168 | * <p>The application must assume that the document is unusable
|
---|
169 | * after the parser has invoked this method, and should continue
|
---|
170 | * (if at all) only for the sake of collecting addition error
|
---|
171 | * messages: in fact, SAX parsers are free to stop reporting any
|
---|
172 | * other events once this method has been invoked.</p>
|
---|
173 | *
|
---|
174 | * @param exc The error information encapsulated in a
|
---|
175 | * SAX parse exception.
|
---|
176 | * @exception SAXException Any SAX exception, possibly
|
---|
177 | * wrapping another exception.
|
---|
178 | * @see SAXParseException#SAXParseException
|
---|
179 | */
|
---|
180 | virtual void fatalError(const SAXParseException& exc) = 0;
|
---|
181 |
|
---|
182 | /**
|
---|
183 | * Reset the Error handler object on its reuse
|
---|
184 | *
|
---|
185 | * <p>This method helps in reseting the Error handler object
|
---|
186 | * implementational defaults each time the Error handler is begun.</p>
|
---|
187 | *
|
---|
188 | */
|
---|
189 | virtual void resetErrors() = 0;
|
---|
190 |
|
---|
191 |
|
---|
192 | //@}
|
---|
193 |
|
---|
194 | private :
|
---|
195 | /* Unimplemented constructors and operators */
|
---|
196 |
|
---|
197 | /* Copy constructor */
|
---|
198 | ErrorHandler(const ErrorHandler&);
|
---|
199 |
|
---|
200 | /* Assignment operator */
|
---|
201 | ErrorHandler& operator=(const ErrorHandler&);
|
---|
202 |
|
---|
203 | };
|
---|
204 |
|
---|
205 | XERCES_CPP_NAMESPACE_END
|
---|
206 |
|
---|
207 | #endif
|
---|