1 | /*
|
---|
2 | * The Apache Software License, Version 1.1
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
|
---|
5 | * reserved.
|
---|
6 | *
|
---|
7 | * Redistribution and use in source and binary forms, with or without
|
---|
8 | * modification, are permitted provided that the following conditions
|
---|
9 | * are met:
|
---|
10 | *
|
---|
11 | * 1. Redistributions of source code must retain the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer.
|
---|
13 | *
|
---|
14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
15 | * notice, this list of conditions and the following disclaimer in
|
---|
16 | * the documentation and/or other materials provided with the
|
---|
17 | * distribution.
|
---|
18 | *
|
---|
19 | * 3. The end-user documentation included with the redistribution,
|
---|
20 | * if any, must include the following acknowledgment:
|
---|
21 | * "This product includes software developed by the
|
---|
22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
25 | *
|
---|
26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
27 | * not be used to endorse or promote products derived from this
|
---|
28 | * software without prior written permission. For written
|
---|
29 | * permission, please contact apache\@apache.org.
|
---|
30 | *
|
---|
31 | * 5. Products derived from this software may not be called "Apache",
|
---|
32 | * nor may "Apache" appear in their name, without prior written
|
---|
33 | * permission of the Apache Software Foundation.
|
---|
34 | *
|
---|
35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
46 | * SUCH DAMAGE.
|
---|
47 | * ====================================================================
|
---|
48 | *
|
---|
49 | * This software consists of voluntary contributions made by many
|
---|
50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
51 | * originally based on software copyright (c) 1999, International
|
---|
52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
53 | * on the Apache Software Foundation, please see
|
---|
54 | * <http://www.apache.org/>.
|
---|
55 | */
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * $Log: ErrorHandler.hpp,v $
|
---|
59 | * Revision 1.5 2003/12/01 23:23:26 neilg
|
---|
60 | * fix for bug 25118; thanks to Jeroen Witmond
|
---|
61 | *
|
---|
62 | * Revision 1.4 2003/05/30 16:11:44 gareth
|
---|
63 | * Fixes so we compile under VC7.1. Patch by Alberto Massari.
|
---|
64 | *
|
---|
65 | * Revision 1.3 2003/03/07 18:10:06 tng
|
---|
66 | * Return a reference instead of void for operator=
|
---|
67 | *
|
---|
68 | * Revision 1.2 2002/11/04 14:56:25 tng
|
---|
69 | * C++ Namespace Support.
|
---|
70 | *
|
---|
71 | * Revision 1.1.1.1 2002/02/01 22:22:08 peiyongz
|
---|
72 | * sane_include
|
---|
73 | *
|
---|
74 | * Revision 1.6 2000/04/27 19:33:15 rahulj
|
---|
75 | * Included <util/XercesDefs.hpp> as suggested by David N Bertoni.
|
---|
76 | *
|
---|
77 | * Revision 1.5 2000/02/24 20:12:55 abagchi
|
---|
78 | * Swat for removing Log from API docs
|
---|
79 | *
|
---|
80 | * Revision 1.4 2000/02/12 03:31:55 rahulj
|
---|
81 | * Removed duplicate CVS Log entries.
|
---|
82 | *
|
---|
83 | * Revision 1.3 2000/02/12 01:27:19 aruna1
|
---|
84 | * Documentation updated
|
---|
85 | *
|
---|
86 | * Revision 1.2 2000/02/06 07:47:57 rahulj
|
---|
87 | * Year 2K copyright swat.
|
---|
88 | *
|
---|
89 | * Revision 1.1.1.1 1999/11/09 01:07:45 twl
|
---|
90 | * Initial checkin
|
---|
91 | *
|
---|
92 | * Revision 1.2 1999/11/08 20:45:00 rahul
|
---|
93 | * Swat for adding in Product name and CVS comment log variable.
|
---|
94 | *
|
---|
95 | */
|
---|
96 |
|
---|
97 |
|
---|
98 | #ifndef ERRORHANDLER_HPP
|
---|
99 | #define ERRORHANDLER_HPP
|
---|
100 |
|
---|
101 | #include <xercesc/util/XercesDefs.hpp>
|
---|
102 |
|
---|
103 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
104 |
|
---|
105 | class SAXParseException;
|
---|
106 |
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * Basic interface for SAX error handlers.
|
---|
110 | *
|
---|
111 | * <p>If a SAX application needs to implement customized error
|
---|
112 | * handling, it must implement this interface and then register an
|
---|
113 | * instance with the SAX parser using the parser's setErrorHandler
|
---|
114 | * method. The parser will then report all errors and warnings
|
---|
115 | * through this interface.</p>
|
---|
116 | *
|
---|
117 | * <p> The parser shall use this interface instead of throwing an
|
---|
118 | * exception: it is up to the application whether to throw an
|
---|
119 | * exception for different types of errors and warnings. Note,
|
---|
120 | * however, that there is no requirement that the parser continue to
|
---|
121 | * provide useful information after a call to fatalError (in other
|
---|
122 | * words, a SAX driver class could catch an exception and report a
|
---|
123 | * fatalError).</p>
|
---|
124 | *
|
---|
125 | * <p>The HandlerBase class provides a default implementation of this
|
---|
126 | * interface, ignoring warnings and recoverable errors and throwing a
|
---|
127 | * SAXParseException for fatal errors. An application may extend
|
---|
128 | * that class rather than implementing the complete interface
|
---|
129 | * itself.</p>
|
---|
130 | *
|
---|
131 | * @see Parser#setErrorHandler
|
---|
132 | * @see SAXParseException#SAXParseException
|
---|
133 | * @see HandlerBase#HandlerBase
|
---|
134 | */
|
---|
135 |
|
---|
136 | class SAX_EXPORT ErrorHandler
|
---|
137 | {
|
---|
138 | public:
|
---|
139 | /** @name Constructors and Destructor */
|
---|
140 | //@{
|
---|
141 | /** Default constructor */
|
---|
142 | ErrorHandler()
|
---|
143 | {
|
---|
144 | }
|
---|
145 |
|
---|
146 | /** Desctructor */
|
---|
147 | virtual ~ErrorHandler()
|
---|
148 | {
|
---|
149 | }
|
---|
150 | //@}
|
---|
151 |
|
---|
152 | /** @name The error handler interface */
|
---|
153 | //@{
|
---|
154 | /**
|
---|
155 | * Receive notification of a warning.
|
---|
156 | *
|
---|
157 | * <p>SAX parsers will use this method to report conditions that
|
---|
158 | * are not errors or fatal errors as defined by the XML 1.0
|
---|
159 | * recommendation. The default behaviour is to take no action.</p>
|
---|
160 | *
|
---|
161 | * <p>The SAX parser must continue to provide normal parsing events
|
---|
162 | * after invoking this method: it should still be possible for the
|
---|
163 | * application to process the document through to the end.</p>
|
---|
164 | *
|
---|
165 | * @param exc The warning information encapsulated in a
|
---|
166 | * SAX parse exception.
|
---|
167 | * @exception SAXException Any SAX exception, possibly
|
---|
168 | * wrapping another exception.
|
---|
169 | * @see SAXParseException#SAXParseException
|
---|
170 | */
|
---|
171 | virtual void warning(const SAXParseException& exc) = 0;
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Receive notification of a recoverable error.
|
---|
175 | *
|
---|
176 | * <p>This corresponds to the definition of "error" in section 1.2
|
---|
177 | * of the W3C XML 1.0 Recommendation. For example, a validating
|
---|
178 | * parser would use this callback to report the violation of a
|
---|
179 | * validity constraint. The default behaviour is to take no
|
---|
180 | * action.</p>
|
---|
181 | *
|
---|
182 | * <p>The SAX parser must continue to provide normal parsing events
|
---|
183 | * after invoking this method: it should still be possible for the
|
---|
184 | * application to process the document through to the end. If the
|
---|
185 | * application cannot do so, then the parser should report a fatal
|
---|
186 | * error even if the XML 1.0 recommendation does not require it to
|
---|
187 | * do so.</p>
|
---|
188 | *
|
---|
189 | * @param exc The error information encapsulated in a
|
---|
190 | * SAX parse exception.
|
---|
191 | * @exception SAXException Any SAX exception, possibly
|
---|
192 | * wrapping another exception.
|
---|
193 | * @see SAXParseException#SAXParseException
|
---|
194 | */
|
---|
195 | virtual void error(const SAXParseException& exc) = 0;
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * Receive notification of a non-recoverable error.
|
---|
199 | *
|
---|
200 | * <p>This corresponds to the definition of "fatal error" in
|
---|
201 | * section 1.2 of the W3C XML 1.0 Recommendation. For example, a
|
---|
202 | * parser would use this callback to report the violation of a
|
---|
203 | * well-formedness constraint.</p>
|
---|
204 | *
|
---|
205 | * <p>The application must assume that the document is unusable
|
---|
206 | * after the parser has invoked this method, and should continue
|
---|
207 | * (if at all) only for the sake of collecting addition error
|
---|
208 | * messages: in fact, SAX parsers are free to stop reporting any
|
---|
209 | * other events once this method has been invoked.</p>
|
---|
210 | *
|
---|
211 | * @param exc The error information encapsulated in a
|
---|
212 | * SAX parse exception.
|
---|
213 | * @exception SAXException Any SAX exception, possibly
|
---|
214 | * wrapping another exception.
|
---|
215 | * @see SAXParseException#SAXParseException
|
---|
216 | */
|
---|
217 | virtual void fatalError(const SAXParseException& exc) = 0;
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * Reset the Error handler object on its reuse
|
---|
221 | *
|
---|
222 | * <p>This method helps in reseting the Error handler object
|
---|
223 | * implementational defaults each time the Error handler is begun.</p>
|
---|
224 | *
|
---|
225 | */
|
---|
226 | virtual void resetErrors() = 0;
|
---|
227 |
|
---|
228 |
|
---|
229 | //@}
|
---|
230 |
|
---|
231 | private :
|
---|
232 | /* Unimplemented constructors and operators */
|
---|
233 |
|
---|
234 | /* Copy constructor */
|
---|
235 | ErrorHandler(const ErrorHandler&);
|
---|
236 |
|
---|
237 | /* Assignment operator */
|
---|
238 | ErrorHandler& operator=(const ErrorHandler&);
|
---|
239 |
|
---|
240 | };
|
---|
241 |
|
---|
242 | XERCES_CPP_NAMESPACE_END
|
---|
243 |
|
---|
244 | #endif
|
---|