1 | /* |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | * contributor license agreements. See the NOTICE file distributed with |
---|
4 | * this work for additional information regarding copyright ownership. |
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | * (the "License"); you may not use this file except in compliance with |
---|
7 | * the License. You may obtain a copy of the License at |
---|
8 | * |
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | * |
---|
11 | * Unless required by applicable law or agreed to in writing, software |
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | * See the License for the specific language governing permissions and |
---|
15 | * limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | * $Id: SAX2XMLReader.hpp 569031 2007-08-23 15:05:28Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef SAX2XMLReader_HPP |
---|
23 | #define SAX2XMLReader_HPP |
---|
24 | |
---|
25 | #include <xercesc/util/XercesDefs.hpp> |
---|
26 | #include <xercesc/util/XMLUniDefs.hpp> |
---|
27 | #include <xercesc/framework/XMLValidator.hpp> |
---|
28 | #include <xercesc/framework/XMLPScanToken.hpp> |
---|
29 | |
---|
30 | XERCES_CPP_NAMESPACE_BEGIN |
---|
31 | |
---|
32 | class ContentHandler ; |
---|
33 | class DTDHandler; |
---|
34 | class EntityResolver; |
---|
35 | class ErrorHandler; |
---|
36 | class InputSource; |
---|
37 | class LexicalHandler; |
---|
38 | class DeclHandler; |
---|
39 | class XMLDocumentHandler; |
---|
40 | class Grammar; |
---|
41 | |
---|
42 | class SAX2_EXPORT SAX2XMLReader |
---|
43 | { |
---|
44 | public: |
---|
45 | // ----------------------------------------------------------------------- |
---|
46 | // Class types |
---|
47 | // ----------------------------------------------------------------------- |
---|
48 | /** @name Public constants */ |
---|
49 | //@{ |
---|
50 | |
---|
51 | /** ValScheme enum used in setValidationScheme |
---|
52 | * Val_Never: Do not report validation errors. |
---|
53 | * Val_Always: The parser will always report validation errors. |
---|
54 | * Val_Auto: The parser will report validation errors only if a grammar is specified. |
---|
55 | * |
---|
56 | * @see #setValidationScheme |
---|
57 | */ |
---|
58 | enum ValSchemes |
---|
59 | { |
---|
60 | Val_Never |
---|
61 | , Val_Always |
---|
62 | , Val_Auto |
---|
63 | }; |
---|
64 | //@} |
---|
65 | |
---|
66 | |
---|
67 | // ----------------------------------------------------------------------- |
---|
68 | // Constructors and Destructor |
---|
69 | // ----------------------------------------------------------------------- |
---|
70 | /** @name Constructors and Destructor */ |
---|
71 | //@{ |
---|
72 | /** The default constructor */ |
---|
73 | SAX2XMLReader() |
---|
74 | { |
---|
75 | } |
---|
76 | /** The destructor */ |
---|
77 | virtual ~SAX2XMLReader() |
---|
78 | { |
---|
79 | } |
---|
80 | //@} |
---|
81 | |
---|
82 | //----------------------------------------------------------------------- |
---|
83 | // The XMLReader interface |
---|
84 | //----------------------------------------------------------------------- |
---|
85 | /** @name Implementation of SAX 2.0 XMLReader interface's. */ |
---|
86 | //@{ |
---|
87 | |
---|
88 | /** |
---|
89 | * This method returns the installed content handler. |
---|
90 | * |
---|
91 | * @return A pointer to the installed content handler object. |
---|
92 | */ |
---|
93 | virtual ContentHandler* getContentHandler() const = 0 ; |
---|
94 | |
---|
95 | /** |
---|
96 | * This method returns the installed DTD handler. |
---|
97 | * |
---|
98 | * @return A pointer to the installed DTD handler object. |
---|
99 | */ |
---|
100 | virtual DTDHandler* getDTDHandler() const = 0; |
---|
101 | |
---|
102 | /** |
---|
103 | * This method returns the installed entity resolver. |
---|
104 | * |
---|
105 | * @return A pointer to the installed entity resolver object. |
---|
106 | */ |
---|
107 | virtual EntityResolver* getEntityResolver() const = 0 ; |
---|
108 | |
---|
109 | /** |
---|
110 | * This method returns the installed error handler. |
---|
111 | * |
---|
112 | * @return A pointer to the installed error handler object. |
---|
113 | */ |
---|
114 | virtual ErrorHandler* getErrorHandler() const = 0 ; |
---|
115 | |
---|
116 | /** |
---|
117 | * Query the current state of any feature in a SAX2 XMLReader. |
---|
118 | * |
---|
119 | * @param name The unique identifier (URI) of the feature being set. |
---|
120 | * @return The current state of the feature. |
---|
121 | * @exception SAXNotRecognizedException If the requested feature is not known. |
---|
122 | */ |
---|
123 | virtual bool getFeature(const XMLCh* const name) const = 0; |
---|
124 | |
---|
125 | /** |
---|
126 | * Query the current value of a property in a SAX2 XMLReader. |
---|
127 | * |
---|
128 | * The parser owns the returned pointer. The memory allocated for |
---|
129 | * the returned pointer will be destroyed when the parser is deleted. |
---|
130 | * |
---|
131 | * To ensure assessiblity of the returned information after the parser |
---|
132 | * is deleted, callers need to copy and store the returned information |
---|
133 | * somewhere else; otherwise you may get unexpected result. Since the returned |
---|
134 | * pointer is a generic void pointer, see |
---|
135 | * http://xerces.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn |
---|
136 | * exactly what type of property value each property returns for replication. |
---|
137 | * |
---|
138 | * @param name The unique identifier (URI) of the property being set. |
---|
139 | * @return The current value of the property. The pointer spans the same |
---|
140 | * life-time as the parser. A null pointer is returned if nothing |
---|
141 | * was specified externally. |
---|
142 | * @exception SAXNotRecognizedException If the requested property is not known. |
---|
143 | */ |
---|
144 | virtual void* getProperty(const XMLCh* const name) const = 0 ; |
---|
145 | |
---|
146 | /** |
---|
147 | * Allow an application to register a document event handler. |
---|
148 | * |
---|
149 | * If the application does not register a document handler, all |
---|
150 | * document events reported by the SAX parser will be silently |
---|
151 | * ignored (this is the default behaviour implemented by |
---|
152 | * HandlerBase). |
---|
153 | * |
---|
154 | * Applications may register a new or different handler in the |
---|
155 | * middle of a parse, and the SAX parser must begin using the new |
---|
156 | * handler immediately. |
---|
157 | * |
---|
158 | * @param handler The document handler. |
---|
159 | * @see DocumentHandler#DocumentHandler |
---|
160 | * @see HandlerBase#HandlerBase |
---|
161 | */ |
---|
162 | virtual void setContentHandler(ContentHandler* const handler) = 0; |
---|
163 | |
---|
164 | /** |
---|
165 | * Allow an application to register a DTD event handler. |
---|
166 | * |
---|
167 | * If the application does not register a DTD handler, all DTD |
---|
168 | * events reported by the SAX parser will be silently ignored (this |
---|
169 | * is the default behaviour implemented by HandlerBase). |
---|
170 | * |
---|
171 | * Applications may register a new or different handler in the middle |
---|
172 | * of a parse, and the SAX parser must begin using the new handler |
---|
173 | * immediately. |
---|
174 | * |
---|
175 | * @param handler The DTD handler. |
---|
176 | * @see DTDHandler#DTDHandler |
---|
177 | * @see HandlerBase#HandlerBase |
---|
178 | */ |
---|
179 | virtual void setDTDHandler(DTDHandler* const handler) = 0; |
---|
180 | |
---|
181 | /** |
---|
182 | * Allow an application to register a custom entity resolver. |
---|
183 | * |
---|
184 | * If the application does not register an entity resolver, the |
---|
185 | * SAX parser will resolve system identifiers and open connections |
---|
186 | * to entities itself (this is the default behaviour implemented in |
---|
187 | * DefaultHandler). |
---|
188 | * |
---|
189 | * Applications may register a new or different entity resolver |
---|
190 | * in the middle of a parse, and the SAX parser must begin using |
---|
191 | * the new resolver immediately. |
---|
192 | * |
---|
193 | * @param resolver The object for resolving entities. |
---|
194 | * @see EntityResolver#EntityResolver |
---|
195 | * @see DefaultHandler#DefaultHandler |
---|
196 | */ |
---|
197 | virtual void setEntityResolver(EntityResolver* const resolver) = 0; |
---|
198 | |
---|
199 | /** |
---|
200 | * Allow an application to register an error event handler. |
---|
201 | * |
---|
202 | * If the application does not register an error event handler, |
---|
203 | * all error events reported by the SAX parser will be silently |
---|
204 | * ignored, except for fatalError, which will throw a SAXException |
---|
205 | * (this is the default behaviour implemented by HandlerBase). |
---|
206 | * |
---|
207 | * Applications may register a new or different handler in the |
---|
208 | * middle of a parse, and the SAX parser must begin using the new |
---|
209 | * handler immediately. |
---|
210 | * |
---|
211 | * @param handler The error handler. |
---|
212 | * @see ErrorHandler#ErrorHandler |
---|
213 | * @see SAXException#SAXException |
---|
214 | * @see HandlerBase#HandlerBase |
---|
215 | */ |
---|
216 | virtual void setErrorHandler(ErrorHandler* const handler) = 0; |
---|
217 | |
---|
218 | /** |
---|
219 | * Set the state of any feature in a SAX2 XMLReader. |
---|
220 | * Supported features in SAX2 for xerces-c are: |
---|
221 | * <br>(See http://xerces.apache.org/xerces-c/program-sax2.html#SAX2Features for detail description). |
---|
222 | * |
---|
223 | * <br>http://xml.org/sax/features/validation (default: true) |
---|
224 | * <br>http://xml.org/sax/features/namespaces (default: true) |
---|
225 | * <br>http://xml.org/sax/features/namespace-prefixes (default: false) |
---|
226 | * <br>http://apache.org/xml/features/validation/dynamic (default: false) |
---|
227 | * <br>http://apache.org/xml/features/validation/reuse-grammar (default: false) |
---|
228 | * <br>http://apache.org/xml/features/validation/schema (default: true) |
---|
229 | * <br>http://apache.org/xml/features/validation/schema-full-checking (default: false) |
---|
230 | * <br>http://apache.org/xml/features/nonvalidating/load-external-dtd (default: true) |
---|
231 | * <br>http://apache.org/xml/features/continue-after-fatal-error (default: false) |
---|
232 | * <br>http://apache.org/xml/features/validation-error-as-fatal (default: false) |
---|
233 | * <br>http://apache.org/xml/features/validation/reuse-validator (Deprecated) (default: false) |
---|
234 | * |
---|
235 | * @param name The unique identifier (URI) of the feature. |
---|
236 | * @param value The requested state of the feature (true or false). |
---|
237 | * @exception SAXNotRecognizedException If the requested feature is not known. |
---|
238 | * @exception SAXNotSupportedException Feature modification is not supported during parse |
---|
239 | * |
---|
240 | */ |
---|
241 | virtual void setFeature(const XMLCh* const name, const bool value) = 0; |
---|
242 | |
---|
243 | /** |
---|
244 | * Set the value of any property in a SAX2 XMLReader. |
---|
245 | * Supported properties in SAX2 for xerces-c are: |
---|
246 | * <br>(See http://xerces.apache.org/xerces-c/program-sax2.html#SAX2Properties for detail description). |
---|
247 | * |
---|
248 | * <br>http://apache.org/xml/properties/schema/external-schemaLocation |
---|
249 | * <br>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation. |
---|
250 | * |
---|
251 | * It takes a void pointer as the property value. Application is required to initialize this void |
---|
252 | * pointer to a correct type. See http://xerces.apache.org/xerces-c/program-sax2.html#SAX2Properties |
---|
253 | * to learn exactly what type of property value each property expects for processing. |
---|
254 | * Passing a void pointer that was initialized with a wrong type will lead to unexpected result. |
---|
255 | * If the same property is set more than once, the last one takes effect. |
---|
256 | * |
---|
257 | * @param name The unique identifier (URI) of the property being set. |
---|
258 | * @param value The requested value for the property. See |
---|
259 | * http://xerces.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn |
---|
260 | * exactly what type of property value each property expects for processing. |
---|
261 | * Passing a void pointer that was initialized with a wrong type will lead |
---|
262 | * to unexpected result. |
---|
263 | * @exception SAXNotRecognizedException If the requested property is not known. |
---|
264 | * @exception SAXNotSupportedException Property modification is not supported during parse |
---|
265 | */ |
---|
266 | virtual void setProperty(const XMLCh* const name, void* value) = 0 ; |
---|
267 | |
---|
268 | /** |
---|
269 | * Parse an XML document. |
---|
270 | * |
---|
271 | * The application can use this method to instruct the SAX parser |
---|
272 | * to begin parsing an XML document from any valid input |
---|
273 | * source (a character stream, a byte stream, or a URI). |
---|
274 | * |
---|
275 | * Applications may not invoke this method while a parse is in |
---|
276 | * progress (they should create a new Parser instead for each |
---|
277 | * additional XML document). Once a parse is complete, an |
---|
278 | * application may reuse the same Parser object, possibly with a |
---|
279 | * different input source. |
---|
280 | * |
---|
281 | * @param source The input source for the top-level of the |
---|
282 | * XML document. |
---|
283 | * @exception SAXException Any SAX exception, possibly |
---|
284 | * wrapping another exception. |
---|
285 | * @exception XMLException An exception from the parser or client |
---|
286 | * handler code. |
---|
287 | * @see InputSource#InputSource |
---|
288 | * @see #setEntityResolver |
---|
289 | * @see #setDTDHandler |
---|
290 | * @see #setDocumentHandler |
---|
291 | * @see #setErrorHandler |
---|
292 | */ |
---|
293 | virtual void parse |
---|
294 | ( |
---|
295 | const InputSource& source |
---|
296 | ) = 0; |
---|
297 | |
---|
298 | /** |
---|
299 | * Parse an XML document from a system identifier (URI). |
---|
300 | * |
---|
301 | * This method is a shortcut for the common case of reading a |
---|
302 | * document from a system identifier. It is the exact equivalent |
---|
303 | * of the following: |
---|
304 | * |
---|
305 | * parse(new URLInputSource(systemId)); |
---|
306 | * |
---|
307 | * If the system identifier is a URL, it must be fully resolved |
---|
308 | * by the application before it is passed to the parser. |
---|
309 | * |
---|
310 | * @param systemId The system identifier (URI). |
---|
311 | * @exception SAXException Any SAX exception, possibly |
---|
312 | * wrapping another exception. |
---|
313 | * @exception XMLException An exception from the parser or client |
---|
314 | * handler code. |
---|
315 | * @see #parse(InputSource) |
---|
316 | */ |
---|
317 | virtual void parse |
---|
318 | ( |
---|
319 | const XMLCh* const systemId |
---|
320 | ) = 0; |
---|
321 | |
---|
322 | /** |
---|
323 | * Parse an XML document from a system identifier (URI). |
---|
324 | * |
---|
325 | * This method is a shortcut for the common case of reading a |
---|
326 | * document from a system identifier. It is the exact equivalent |
---|
327 | * of the following: |
---|
328 | * |
---|
329 | * parse(new URLInputSource(systemId)); |
---|
330 | * |
---|
331 | * If the system identifier is a URL, it must be fully resolved |
---|
332 | * by the application before it is passed to the parser. |
---|
333 | * |
---|
334 | * @param systemId The system identifier (URI). |
---|
335 | * @exception SAXException Any SAX exception, possibly |
---|
336 | * wrapping another exception. |
---|
337 | * @exception XMLException An exception from the parser or client |
---|
338 | * handler code. |
---|
339 | * @see #parse(InputSource) |
---|
340 | */ |
---|
341 | virtual void parse |
---|
342 | ( |
---|
343 | const char* const systemId |
---|
344 | ) = 0; |
---|
345 | |
---|
346 | //@} |
---|
347 | |
---|
348 | // ----------------------------------------------------------------------- |
---|
349 | // SAX 2.0-ext |
---|
350 | // ----------------------------------------------------------------------- |
---|
351 | /** @name SAX 2.0-ext */ |
---|
352 | //@{ |
---|
353 | /** |
---|
354 | * This method returns the installed declaration handler. |
---|
355 | * |
---|
356 | * @return A pointer to the installed declaration handler object. |
---|
357 | */ |
---|
358 | virtual DeclHandler* getDeclarationHandler() const = 0 ; |
---|
359 | |
---|
360 | /** |
---|
361 | * This method returns the installed lexical handler. |
---|
362 | * |
---|
363 | * @return A pointer to the installed lexical handler object. |
---|
364 | */ |
---|
365 | virtual LexicalHandler* getLexicalHandler() const = 0 ; |
---|
366 | |
---|
367 | /** |
---|
368 | * Allow an application to register a declaration event handler. |
---|
369 | * |
---|
370 | * If the application does not register a declaration handler, |
---|
371 | * all events reported by the SAX parser will be silently |
---|
372 | * ignored. (this is the default behaviour implemented by DefaultHandler). |
---|
373 | * |
---|
374 | * Applications may register a new or different handler in the |
---|
375 | * middle of a parse, and the SAX parser must begin using the new |
---|
376 | * handler immediately. |
---|
377 | * |
---|
378 | * @param handler The DTD declaration handler. |
---|
379 | * @see DeclHandler#DeclHandler |
---|
380 | * @see SAXException#SAXException |
---|
381 | * @see DefaultHandler#DefaultHandler |
---|
382 | */ |
---|
383 | virtual void setDeclarationHandler(DeclHandler* const handler) = 0; |
---|
384 | |
---|
385 | /** |
---|
386 | * Allow an application to register a lexical event handler. |
---|
387 | * |
---|
388 | * If the application does not register a lexical handler, |
---|
389 | * all events reported by the SAX parser will be silently |
---|
390 | * ignored. (this is the default behaviour implemented by HandlerBase). |
---|
391 | * |
---|
392 | * Applications may register a new or different handler in the |
---|
393 | * middle of a parse, and the SAX parser must begin using the new |
---|
394 | * handler immediately. |
---|
395 | * |
---|
396 | * @param handler The error handler. |
---|
397 | * @see LexicalHandler#LexicalHandler |
---|
398 | * @see SAXException#SAXException |
---|
399 | * @see HandlerBase#HandlerBase |
---|
400 | */ |
---|
401 | virtual void setLexicalHandler(LexicalHandler* const handler) = 0; |
---|
402 | |
---|
403 | //@} |
---|
404 | |
---|
405 | // ----------------------------------------------------------------------- |
---|
406 | // Getter Methods |
---|
407 | // ----------------------------------------------------------------------- |
---|
408 | /** @name Getter Methods (Xerces-C specific) */ |
---|
409 | //@{ |
---|
410 | /** |
---|
411 | * This method is used to get the current validator. |
---|
412 | * |
---|
413 | * <b>SAX2XMLReader assumes responsibility for the validator. It will be |
---|
414 | * deleted when the XMLReader is destroyed.</b> |
---|
415 | * |
---|
416 | * @return A pointer to the validator. An application should not deleted |
---|
417 | * the object returned. |
---|
418 | * |
---|
419 | */ |
---|
420 | virtual XMLValidator* getValidator() const = 0; |
---|
421 | |
---|
422 | /** Get error count from the last parse operation. |
---|
423 | * |
---|
424 | * This method returns the error count from the last parse |
---|
425 | * operation. Note that this count is actually stored in the |
---|
426 | * scanner, so this method simply returns what the |
---|
427 | * scanner reports. |
---|
428 | * |
---|
429 | * @return number of errors encountered during the latest |
---|
430 | * parse operation. |
---|
431 | */ |
---|
432 | virtual int getErrorCount() const = 0 ; |
---|
433 | |
---|
434 | /** |
---|
435 | * This method returns the state of the parser's |
---|
436 | * exit-on-First-Fatal-Error flag. |
---|
437 | * |
---|
438 | * <p>Or you can query the feature "http://apache.org/xml/features/continue-after-fatal-error" |
---|
439 | * which indicates the opposite state.</p> |
---|
440 | * |
---|
441 | * @return true, if the parser is currently configured to |
---|
442 | * exit on the first fatal error, false otherwise. |
---|
443 | * |
---|
444 | * @see #setExitOnFirstFatalError |
---|
445 | * @see #getFeature |
---|
446 | */ |
---|
447 | virtual bool getExitOnFirstFatalError() const = 0; |
---|
448 | |
---|
449 | /** |
---|
450 | * This method returns the state of the parser's |
---|
451 | * validation-constraint-fatal flag. |
---|
452 | * |
---|
453 | * <p>Or you can query the feature "http://apache.org/xml/features/validation-error-as-fatal" |
---|
454 | * which means the same thing. |
---|
455 | * |
---|
456 | * @return true, if the parser is currently configured to |
---|
457 | * set validation constraint errors as fatal, false |
---|
458 | * otherwise. |
---|
459 | * |
---|
460 | * @see #setValidationContraintFatal |
---|
461 | * @see #getFeature |
---|
462 | */ |
---|
463 | virtual bool getValidationConstraintFatal() const = 0; |
---|
464 | |
---|
465 | /** |
---|
466 | * Retrieve the grammar that is associated with the specified namespace key |
---|
467 | * |
---|
468 | * @param nameSpaceKey Namespace key |
---|
469 | * @return Grammar associated with the Namespace key. |
---|
470 | */ |
---|
471 | virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) = 0; |
---|
472 | |
---|
473 | /** |
---|
474 | * Retrieve the grammar where the root element is declared. |
---|
475 | * |
---|
476 | * @return Grammar where root element declared |
---|
477 | */ |
---|
478 | virtual Grammar* getRootGrammar() = 0; |
---|
479 | |
---|
480 | /** |
---|
481 | * Returns the string corresponding to a URI id from the URI string pool. |
---|
482 | * |
---|
483 | * @param uriId id of the string in the URI string pool. |
---|
484 | * @return URI string corresponding to the URI id. |
---|
485 | */ |
---|
486 | virtual const XMLCh* getURIText(unsigned int uriId) const = 0; |
---|
487 | |
---|
488 | /** |
---|
489 | * Returns the current src offset within the input source. |
---|
490 | * To be used only while parsing is in progress. |
---|
491 | * |
---|
492 | * @return offset within the input source |
---|
493 | */ |
---|
494 | virtual unsigned int getSrcOffset() const = 0; |
---|
495 | |
---|
496 | //@} |
---|
497 | |
---|
498 | // ----------------------------------------------------------------------- |
---|
499 | // Setter Methods |
---|
500 | // ----------------------------------------------------------------------- |
---|
501 | /** @name Setter Methods (Xerces-C specific) */ |
---|
502 | //@{ |
---|
503 | /** |
---|
504 | * This method is used to set a validator. |
---|
505 | * |
---|
506 | * <b>SAX2XMLReader assumes responsibility for the validator. It will be |
---|
507 | * deleted when the XMLReader is destroyed.</b> |
---|
508 | * |
---|
509 | * @param valueToAdopt A pointer to the validator that the reader should use. |
---|
510 | * |
---|
511 | */ |
---|
512 | virtual void setValidator(XMLValidator* valueToAdopt) = 0; |
---|
513 | |
---|
514 | /** |
---|
515 | * This method allows users to set the parser's behaviour when it |
---|
516 | * encounters the first fatal error. If set to true, the parser |
---|
517 | * will exit at the first fatal error. If false, then it will |
---|
518 | * report the error and continue processing. |
---|
519 | * |
---|
520 | * <p>The default value is 'true' and the parser exits on the |
---|
521 | * first fatal error.</p> |
---|
522 | * |
---|
523 | * <p>Or you can set the feature "http://apache.org/xml/features/continue-after-fatal-error" |
---|
524 | * which has the opposite behaviour.</p> |
---|
525 | * |
---|
526 | * <p>If both the feature above and this function are used, the latter takes effect.</p> |
---|
527 | * |
---|
528 | * @param newState The value specifying whether the parser should |
---|
529 | * continue or exit when it encounters the first |
---|
530 | * fatal error. |
---|
531 | * |
---|
532 | * @see #getExitOnFirstFatalError |
---|
533 | * @see #setFeature |
---|
534 | */ |
---|
535 | virtual void setExitOnFirstFatalError(const bool newState) = 0; |
---|
536 | |
---|
537 | /** |
---|
538 | * This method allows users to set the parser's behaviour when it |
---|
539 | * encounters a validtion constraint error. If set to true, and the |
---|
540 | * the parser will treat validation error as fatal and will exit depends on the |
---|
541 | * state of "getExitOnFirstFatalError". If false, then it will |
---|
542 | * report the error and continue processing. |
---|
543 | * |
---|
544 | * Note: setting this true does not mean the validation error will be printed with |
---|
545 | * the word "Fatal Error". It is still printed as "Error", but the parser |
---|
546 | * will exit if "setExitOnFirstFatalError" is set to true. |
---|
547 | * |
---|
548 | * <p>The default value is 'false'.</p> |
---|
549 | * |
---|
550 | * <p>Or you can set the feature "http://apache.org/xml/features/validation-error-as-fatal" |
---|
551 | * which means the same thing.</p> |
---|
552 | * |
---|
553 | * <p>If both the feature above and this function are used, the latter takes effect.</p> |
---|
554 | * |
---|
555 | * @param newState If true, the parser will exit if "setExitOnFirstFatalError" |
---|
556 | * is set to true. |
---|
557 | * |
---|
558 | * @see #getValidationConstraintFatal |
---|
559 | * @see #setExitOnFirstFatalError |
---|
560 | * @see #setFeature |
---|
561 | */ |
---|
562 | virtual void setValidationConstraintFatal(const bool newState) = 0; |
---|
563 | //@} |
---|
564 | |
---|
565 | |
---|
566 | // ----------------------------------------------------------------------- |
---|
567 | // Progressive scan methods |
---|
568 | // ----------------------------------------------------------------------- |
---|
569 | |
---|
570 | /** @name Progressive scan methods */ |
---|
571 | //@{ |
---|
572 | |
---|
573 | /** Begin a progressive parse operation |
---|
574 | * |
---|
575 | * This method is used to start a progressive parse on a XML file. |
---|
576 | * To continue parsing, subsequent calls must be to the parseNext |
---|
577 | * method. |
---|
578 | * |
---|
579 | * It scans through the prolog and returns a token to be used on |
---|
580 | * subsequent scanNext() calls. If the return value is true, then the |
---|
581 | * token is legal and ready for further use. If it returns false, then |
---|
582 | * the scan of the prolog failed and the token is not going to work on |
---|
583 | * subsequent scanNext() calls. |
---|
584 | * |
---|
585 | * @param systemId A pointer to a Unicode string represting the path |
---|
586 | * to the XML file to be parsed. |
---|
587 | * @param toFill A token maintaing state information to maintain |
---|
588 | * internal consistency between invocation of 'parseNext' |
---|
589 | * calls. |
---|
590 | * |
---|
591 | * @return 'true', if successful in parsing the prolog. It indicates the |
---|
592 | * user can go ahead with parsing the rest of the file. It |
---|
593 | * returns 'false' to indicate that the parser could parse the |
---|
594 | * prolog (which means the token will not be valid.) |
---|
595 | * |
---|
596 | * @see #parseNext |
---|
597 | * @see #parseFirst(char*,...) |
---|
598 | * @see #parseFirst(InputSource&,...) |
---|
599 | */ |
---|
600 | virtual bool parseFirst |
---|
601 | ( |
---|
602 | const XMLCh* const systemId |
---|
603 | , XMLPScanToken& toFill |
---|
604 | ) = 0; |
---|
605 | |
---|
606 | /** Begin a progressive parse operation |
---|
607 | * |
---|
608 | * This method is used to start a progressive parse on a XML file. |
---|
609 | * To continue parsing, subsequent calls must be to the parseNext |
---|
610 | * method. |
---|
611 | * |
---|
612 | * It scans through the prolog and returns a token to be used on |
---|
613 | * subsequent scanNext() calls. If the return value is true, then the |
---|
614 | * token is legal and ready for further use. If it returns false, then |
---|
615 | * the scan of the prolog failed and the token is not going to work on |
---|
616 | * subsequent scanNext() calls. |
---|
617 | * |
---|
618 | * @param systemId A pointer to a regular native string represting |
---|
619 | * the path to the XML file to be parsed. |
---|
620 | * @param toFill A token maintaing state information to maintain |
---|
621 | * internal consIstency between invocation of 'parseNext' |
---|
622 | * calls. |
---|
623 | * |
---|
624 | * @return 'true', if successful in parsing the prolog. It indicates the |
---|
625 | * user can go ahead with parsing the rest of the file. It |
---|
626 | * returns 'false' to indicate that the parser could not parse |
---|
627 | * the prolog. |
---|
628 | * |
---|
629 | * @see #parseNext |
---|
630 | * @see #parseFirst(XMLCh*,...) |
---|
631 | * @see #parseFirst(InputSource&,...) |
---|
632 | */ |
---|
633 | virtual bool parseFirst |
---|
634 | ( |
---|
635 | const char* const systemId |
---|
636 | , XMLPScanToken& toFill |
---|
637 | ) = 0; |
---|
638 | |
---|
639 | /** Begin a progressive parse operation |
---|
640 | * |
---|
641 | * This method is used to start a progressive parse on a XML file. |
---|
642 | * To continue parsing, subsequent calls must be to the parseNext |
---|
643 | * method. |
---|
644 | * |
---|
645 | * It scans through the prolog and returns a token to be used on |
---|
646 | * subsequent scanNext() calls. If the return value is true, then the |
---|
647 | * token is legal and ready for further use. If it returns false, then |
---|
648 | * the scan of the prolog failed and the token is not going to work on |
---|
649 | * subsequent scanNext() calls. |
---|
650 | * |
---|
651 | * @param source A const reference to the InputSource object which |
---|
652 | * points to the XML file to be parsed. |
---|
653 | * @param toFill A token maintaing state information to maintain |
---|
654 | * internal consistency between invocation of 'parseNext' |
---|
655 | * calls. |
---|
656 | * |
---|
657 | * @return 'true', if successful in parsing the prolog. It indicates the |
---|
658 | * user can go ahead with parsing the rest of the file. It |
---|
659 | * returns 'false' to indicate that the parser could not parse |
---|
660 | * the prolog. |
---|
661 | * |
---|
662 | * @see #parseNext |
---|
663 | * @see #parseFirst(XMLCh*,...) |
---|
664 | * @see #parseFirst(char*,...) |
---|
665 | */ |
---|
666 | virtual bool parseFirst |
---|
667 | ( |
---|
668 | const InputSource& source |
---|
669 | , XMLPScanToken& toFill |
---|
670 | ) = 0; |
---|
671 | |
---|
672 | /** Continue a progressive parse operation |
---|
673 | * |
---|
674 | * This method is used to continue with progressive parsing of |
---|
675 | * XML files started by a call to 'parseFirst' method. |
---|
676 | * |
---|
677 | * It parses the XML file and stops as soon as it comes across |
---|
678 | * a XML token (as defined in the XML specification). Relevant |
---|
679 | * callback handlers are invoked as required by the SAX |
---|
680 | * specification. |
---|
681 | * |
---|
682 | * @param token A token maintaing state information to maintain |
---|
683 | * internal consistency between invocation of 'parseNext' |
---|
684 | * calls. |
---|
685 | * |
---|
686 | * @return 'true', if successful in parsing the next XML token. |
---|
687 | * It indicates the user can go ahead with parsing the rest |
---|
688 | * of the file. It returns 'false' to indicate that the parser |
---|
689 | * could not find next token as per the XML specification |
---|
690 | * production rule. |
---|
691 | * |
---|
692 | * @see #parseFirst(XMLCh*,...) |
---|
693 | * @see #parseFirst(char*,...) |
---|
694 | * @see #parseFirst(InputSource&,...) |
---|
695 | */ |
---|
696 | virtual bool parseNext(XMLPScanToken& token) = 0; |
---|
697 | |
---|
698 | /** Reset the parser after a progressive parse |
---|
699 | * |
---|
700 | * If a progressive parse loop exits before the end of the document |
---|
701 | * is reached, the parser has no way of knowing this. So it will leave |
---|
702 | * open any files or sockets or memory buffers that were in use at |
---|
703 | * the time that the parse loop exited. |
---|
704 | * |
---|
705 | * The next parse operation will cause these open files and such to |
---|
706 | * be closed, but the next parse operation might occur at some unknown |
---|
707 | * future point. To avoid this problem, you should reset the parser if |
---|
708 | * you exit the loop early. |
---|
709 | * |
---|
710 | * If you exited because of an error, then this cleanup will be done |
---|
711 | * for you. Its only when you exit the file prematurely of your own |
---|
712 | * accord, because you've found what you wanted in the file most |
---|
713 | * likely. |
---|
714 | * |
---|
715 | * @param token A token maintaing state information to maintain |
---|
716 | * internal consistency between invocation of 'parseNext' |
---|
717 | * calls. |
---|
718 | */ |
---|
719 | virtual void parseReset(XMLPScanToken& token) = 0; |
---|
720 | |
---|
721 | //@} |
---|
722 | |
---|
723 | // ----------------------------------------------------------------------- |
---|
724 | // Grammar preparsing interface |
---|
725 | // ----------------------------------------------------------------------- |
---|
726 | |
---|
727 | /** @name Grammar preparsing interface's. */ |
---|
728 | //@{ |
---|
729 | /** |
---|
730 | * Preparse schema grammar (XML Schema, DTD, etc.) via an input source |
---|
731 | * object. |
---|
732 | * |
---|
733 | * This method invokes the preparsing process on a schema grammar XML |
---|
734 | * file specified by the SAX InputSource parameter. If the 'toCache' flag |
---|
735 | * is enabled, the parser will cache the grammars for re-use. If a grammar |
---|
736 | * key is found in the pool, no caching of any grammar will take place. |
---|
737 | * |
---|
738 | * <p><b>"Experimental - subject to change"</b></p> |
---|
739 | * |
---|
740 | * @param source A const reference to the SAX InputSource object which |
---|
741 | * points to the schema grammar file to be preparsed. |
---|
742 | * @param grammarType The grammar type (Schema or DTD). |
---|
743 | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
---|
744 | * otherwise, no chaching. Default is <code>false</code>. |
---|
745 | * @return The preparsed schema grammar object (SchemaGrammar or |
---|
746 | * DTDGrammar). That grammar object is owned by the parser. |
---|
747 | * |
---|
748 | * @exception SAXException Any SAX exception, possibly |
---|
749 | * wrapping another exception. |
---|
750 | * @exception XMLException An exception from the parser or client |
---|
751 | * handler code. |
---|
752 | * @exception DOMException A DOM exception as per DOM spec. |
---|
753 | * |
---|
754 | * @see InputSource#InputSource |
---|
755 | */ |
---|
756 | virtual Grammar* loadGrammar(const InputSource& source, |
---|
757 | const short grammarType, |
---|
758 | const bool toCache = false) = 0; |
---|
759 | |
---|
760 | /** |
---|
761 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL |
---|
762 | * |
---|
763 | * This method invokes the preparsing process on a schema grammar XML |
---|
764 | * file specified by the file path parameter. If the 'toCache' flag |
---|
765 | * is enabled, the parser will cache the grammars for re-use. If a grammar |
---|
766 | * key is found in the pool, no caching of any grammar will take place. |
---|
767 | * |
---|
768 | * <p><b>"Experimental - subject to change"</b></p> |
---|
769 | * |
---|
770 | * @param systemId A const XMLCh pointer to the Unicode string which |
---|
771 | * contains the path to the XML grammar file to be |
---|
772 | * preparsed. |
---|
773 | * @param grammarType The grammar type (Schema or DTD). |
---|
774 | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
---|
775 | * otherwise, no chaching. Default is <code>false</code>. |
---|
776 | * @return The preparsed schema grammar object (SchemaGrammar or |
---|
777 | * DTDGrammar). That grammar object is owned by the parser. |
---|
778 | * |
---|
779 | * @exception SAXException Any SAX exception, possibly |
---|
780 | * wrapping another exception. |
---|
781 | * @exception XMLException An exception from the parser or client |
---|
782 | * handler code. |
---|
783 | * @exception DOMException A DOM exception as per DOM spec. |
---|
784 | */ |
---|
785 | virtual Grammar* loadGrammar(const XMLCh* const systemId, |
---|
786 | const short grammarType, |
---|
787 | const bool toCache = false) = 0; |
---|
788 | |
---|
789 | /** |
---|
790 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL |
---|
791 | * |
---|
792 | * This method invokes the preparsing process on a schema grammar XML |
---|
793 | * file specified by the file path parameter. If the 'toCache' flag |
---|
794 | * is enabled, the parser will cache the grammars for re-use. If a grammar |
---|
795 | * key is found in the pool, no caching of any grammar will take place. |
---|
796 | * |
---|
797 | * <p><b>"Experimental - subject to change"</b></p> |
---|
798 | * |
---|
799 | * @param systemId A const char pointer to a native string which contains |
---|
800 | * the path to the XML grammar file to be preparsed. |
---|
801 | * @param grammarType The grammar type (Schema or DTD). |
---|
802 | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
---|
803 | * otherwise, no chaching. Default is <code>false</code>. |
---|
804 | * @return The preparsed schema grammar object (SchemaGrammar or |
---|
805 | * DTDGrammar). That grammar object is owned by the parser. |
---|
806 | * |
---|
807 | * @exception SAXException Any SAX exception, possibly |
---|
808 | * wrapping another exception. |
---|
809 | * @exception XMLException An exception from the parser or client |
---|
810 | * handler code. |
---|
811 | * @exception DOMException A DOM exception as per DOM spec. |
---|
812 | */ |
---|
813 | virtual Grammar* loadGrammar(const char* const systemId, |
---|
814 | const short grammarType, |
---|
815 | const bool toCache = false) = 0; |
---|
816 | |
---|
817 | /** |
---|
818 | * Clear the cached grammar pool |
---|
819 | */ |
---|
820 | virtual void resetCachedGrammarPool() = 0; |
---|
821 | |
---|
822 | /** Set maximum input buffer size |
---|
823 | * |
---|
824 | * This method allows users to limit the size of buffers used in parsing |
---|
825 | * XML character data. The effect of setting this size is to limit the |
---|
826 | * size of a ContentHandler::characters() call. |
---|
827 | * |
---|
828 | * The parser's default input buffer size is 1 megabyte. |
---|
829 | * |
---|
830 | * @param bufferSize The maximum input buffer size |
---|
831 | */ |
---|
832 | virtual void setInputBufferSize(const size_t bufferSize); |
---|
833 | |
---|
834 | //@} |
---|
835 | |
---|
836 | |
---|
837 | // ----------------------------------------------------------------------- |
---|
838 | // Advanced document handler list maintenance methods |
---|
839 | // ----------------------------------------------------------------------- |
---|
840 | |
---|
841 | /** @name Advanced document handler list maintenance methods */ |
---|
842 | //@{ |
---|
843 | /** |
---|
844 | * This method installs the specified 'advanced' document callback |
---|
845 | * handler, thereby allowing the user to customize the processing, |
---|
846 | * if they choose to do so. Any number of advanced callback handlers |
---|
847 | * maybe installed. |
---|
848 | * |
---|
849 | * <p>The methods in the advanced callback interface represent |
---|
850 | * Xerces-C extensions. There is no specification for this interface.</p> |
---|
851 | * |
---|
852 | * @param toInstall A pointer to the users advanced callback handler. |
---|
853 | * |
---|
854 | * @see #removeAdvDocHandler |
---|
855 | */ |
---|
856 | virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) = 0; |
---|
857 | |
---|
858 | /** |
---|
859 | * This method removes the 'advanced' document handler callback from |
---|
860 | * the underlying parser scanner. If no handler is installed, advanced |
---|
861 | * callbacks are not invoked by the scanner. |
---|
862 | * @param toRemove A pointer to the advanced callback handler which |
---|
863 | * should be removed. |
---|
864 | * |
---|
865 | * @see #installAdvDocHandler |
---|
866 | */ |
---|
867 | virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) = 0; |
---|
868 | //@} |
---|
869 | |
---|
870 | private : |
---|
871 | /* The copy constructor, you cannot call this directly */ |
---|
872 | SAX2XMLReader(const SAX2XMLReader&); |
---|
873 | |
---|
874 | /* The assignment operator, you cannot call this directly */ |
---|
875 | SAX2XMLReader& operator=(const SAX2XMLReader&); |
---|
876 | |
---|
877 | }; |
---|
878 | |
---|
879 | inline void SAX2XMLReader::setInputBufferSize(const size_t /*bufferSize*/) |
---|
880 | { |
---|
881 | } |
---|
882 | |
---|
883 | XERCES_CPP_NAMESPACE_END |
---|
884 | |
---|
885 | #endif |
---|