/src/xerces-c/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
Line | Count | Source (jump to first uncovered line) |
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: SAX2XMLReaderImpl.hpp 932889 2010-04-11 13:10:10Z borisk $ |
20 | | */ |
21 | | |
22 | | #if !defined(XERCESC_INCLUDE_GUARD_SAX2XMLREADERIMPL_HPP) |
23 | | #define XERCESC_INCLUDE_GUARD_SAX2XMLREADERIMPL_HPP |
24 | | |
25 | | #include <xercesc/parsers/SAXParser.hpp> |
26 | | #include <xercesc/sax/Parser.hpp> |
27 | | #include <xercesc/framework/XMLBuffer.hpp> |
28 | | #include <xercesc/internal/VecAttributesImpl.hpp> |
29 | | #include <xercesc/sax2/SAX2XMLReader.hpp> |
30 | | #include <xercesc/util/RefStackOf.hpp> |
31 | | #include <xercesc/util/SecurityManager.hpp> |
32 | | #include <xercesc/util/ValueStackOf.hpp> |
33 | | |
34 | | XERCES_CPP_NAMESPACE_BEGIN |
35 | | |
36 | | |
37 | | class ContentHandler; |
38 | | class LexicalHandler; |
39 | | class DeclHandler; |
40 | | class GrammarResolver; |
41 | | class XMLGrammarPool; |
42 | | class XMLResourceIdentifier; |
43 | | class PSVIHandler; |
44 | | |
45 | | /** |
46 | | * This class implements the SAX2 'XMLReader' interface and should be |
47 | | * used by applications wishing to parse the XML files using SAX2. |
48 | | * It allows the client program to install SAX2 handlers for event |
49 | | * callbacks. |
50 | | * |
51 | | * <p>It can be used to instantiate a validating or non-validating |
52 | | * parser, by setting a member flag.</p> |
53 | | * |
54 | | * we basically re-use the existing SAX1 parser code, but provide a |
55 | | * new implementation of XMLContentHandler that raises the new |
56 | | * SAX2 style events |
57 | | * |
58 | | */ |
59 | | |
60 | | class PARSERS_EXPORT SAX2XMLReaderImpl : |
61 | | public XMemory |
62 | | , public SAX2XMLReader |
63 | | , public XMLDocumentHandler |
64 | | , public XMLErrorReporter |
65 | | , public XMLEntityHandler |
66 | | , public DocTypeHandler |
67 | | { |
68 | | public : |
69 | | // ----------------------------------------------------------------------- |
70 | | // Constructors and Destructor |
71 | | // ----------------------------------------------------------------------- |
72 | | /** @name Constructors and Destructor */ |
73 | | //@{ |
74 | | /** The default constructor */ |
75 | | SAX2XMLReaderImpl( |
76 | | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
77 | | , XMLGrammarPool* const gramPool = 0 |
78 | | ); |
79 | | |
80 | | /** The destructor */ |
81 | | ~SAX2XMLReaderImpl() ; |
82 | | //@} |
83 | | |
84 | | //----------------------------------------------------------------------- |
85 | | // Implementation of SAX2XMLReader Interface |
86 | | //----------------------------------------------------------------------- |
87 | | //----------------------------------------------------------------------- |
88 | | // The XMLReader interface |
89 | | //----------------------------------------------------------------------- |
90 | | /** @name Implementation of SAX 2.0 XMLReader interface's. */ |
91 | | //@{ |
92 | | |
93 | | /** |
94 | | * This method returns the installed content handler. |
95 | | * |
96 | | * @return A pointer to the installed content handler object. |
97 | | */ |
98 | | virtual ContentHandler* getContentHandler() const ; |
99 | | |
100 | | /** |
101 | | * This method returns the installed DTD handler. |
102 | | * |
103 | | * @return A pointer to the installed DTD handler object. |
104 | | */ |
105 | | virtual DTDHandler* getDTDHandler() const ; |
106 | | |
107 | | /** |
108 | | * This method returns the installed entity resolver. |
109 | | * |
110 | | * @return A pointer to the installed entity resolver object. |
111 | | */ |
112 | | virtual EntityResolver* getEntityResolver() const ; |
113 | | |
114 | | /** |
115 | | * This method returns the installed entity resolver. |
116 | | * |
117 | | * @return A pointer to the installed entity resolver object. |
118 | | */ |
119 | | virtual XMLEntityResolver* getXMLEntityResolver() const ; |
120 | | |
121 | | /** |
122 | | * This method returns the installed error handler. |
123 | | * |
124 | | * @return A pointer to the installed error handler object. |
125 | | */ |
126 | | virtual ErrorHandler* getErrorHandler() const ; |
127 | | |
128 | | /** |
129 | | * This method returns the installed PSVI handler. |
130 | | * |
131 | | * @return A pointer to the installed PSVI handler object. |
132 | | */ |
133 | | virtual PSVIHandler* getPSVIHandler() const ; |
134 | | |
135 | | /** |
136 | | * Query the current state of any feature in a SAX2 XMLReader. |
137 | | * |
138 | | * @param name The unique identifier (URI) of the feature being set. |
139 | | * @return The current state of the feature. |
140 | | * @exception SAXNotRecognizedException If the requested feature is not known. |
141 | | */ |
142 | | virtual bool getFeature(const XMLCh* const name) const ; |
143 | | |
144 | | /** |
145 | | * Query the current value of a property in a SAX2 XMLReader. |
146 | | * |
147 | | * The parser owns the returned pointer. The memory allocated for |
148 | | * the returned pointer will be destroyed when the parser is deleted. |
149 | | * |
150 | | * To ensure accessibility of the returned information after the parser |
151 | | * is deleted, callers need to copy and store the returned information |
152 | | * somewhere else; otherwise you may get unexpected result. Since the returned |
153 | | * pointer is a generic void pointer, see the SAX2 Programming Guide to learn |
154 | | * exactly what type of property value each property returns for replication. |
155 | | * |
156 | | * @param name The unique identifier (URI) of the property being set. |
157 | | * @return The current value of the property. The pointer spans the same |
158 | | * life-time as the parser. A null pointer is returned if nothing |
159 | | * was specified externally. |
160 | | * @exception SAXNotRecognizedException If the requested property is not known. |
161 | | */ |
162 | | virtual void* getProperty(const XMLCh* const name) const ; |
163 | | |
164 | | /** |
165 | | * Allow an application to register a document event handler. |
166 | | * |
167 | | * If the application does not register a document handler, all |
168 | | * document events reported by the SAX parser will be silently |
169 | | * ignored (this is the default behaviour implemented by |
170 | | * HandlerBase). |
171 | | * |
172 | | * Applications may register a new or different handler in the |
173 | | * middle of a parse, and the SAX parser must begin using the new |
174 | | * handler immediately. |
175 | | * |
176 | | * @param handler The document handler. |
177 | | * @see DocumentHandler#DocumentHandler |
178 | | * @see HandlerBase#HandlerBase |
179 | | */ |
180 | | virtual void setContentHandler(ContentHandler* const handler) ; |
181 | | |
182 | | /** |
183 | | * Allow an application to register a DTD event handler. |
184 | | * |
185 | | * If the application does not register a DTD handler, all DTD |
186 | | * events reported by the SAX parser will be silently ignored (this |
187 | | * is the default behaviour implemented by HandlerBase). |
188 | | * |
189 | | * Applications may register a new or different handler in the middle |
190 | | * of a parse, and the SAX parser must begin using the new handler |
191 | | * immediately. |
192 | | * |
193 | | * @param handler The DTD handler. |
194 | | * @see DTDHandler#DTDHandler |
195 | | * @see HandlerBase#HandlerBase |
196 | | */ |
197 | | virtual void setDTDHandler(DTDHandler* const handler) ; |
198 | | |
199 | | /** |
200 | | * Allow an application to register a custom entity resolver. |
201 | | * |
202 | | * If the application does not register an entity resolver, the |
203 | | * SAX parser will resolve system identifiers and open connections |
204 | | * to entities itself (this is the default behaviour implemented in |
205 | | * DefaultHandler). |
206 | | * |
207 | | * Applications may register a new or different entity resolver |
208 | | * in the middle of a parse, and the SAX parser must begin using |
209 | | * the new resolver immediately. |
210 | | * |
211 | | * <i>Any previously set entity resolver is merely dropped, since the parser |
212 | | * does not own them. If both setEntityResolver and setXMLEntityResolver |
213 | | * are called, then the last one is used.</i> |
214 | | * |
215 | | * @param resolver The object for resolving entities. |
216 | | * @see EntityResolver#EntityResolver |
217 | | * @see DefaultHandler#DefaultHandler |
218 | | */ |
219 | | virtual void setEntityResolver(EntityResolver* const resolver) ; |
220 | | |
221 | | /** Set the entity resolver |
222 | | * |
223 | | * This method allows applications to install their own entity |
224 | | * resolver. By installing an entity resolver, the applications |
225 | | * can trap and potentially redirect references to external |
226 | | * entities. |
227 | | * |
228 | | * <i>Any previously set entity resolver is merely dropped, since the parser |
229 | | * does not own them. If both setEntityResolver and setXMLEntityResolver |
230 | | * are called, then the last one is used.</i> |
231 | | * |
232 | | * @param resolver A const pointer to the user supplied entity |
233 | | * resolver. |
234 | | * |
235 | | * @see #getXMLEntityResolver |
236 | | */ |
237 | | virtual void setXMLEntityResolver(XMLEntityResolver* const resolver) ; |
238 | | |
239 | | /** |
240 | | * Allow an application to register an error event handler. |
241 | | * |
242 | | * If the application does not register an error event handler, |
243 | | * all error events reported by the SAX parser will be silently |
244 | | * ignored, except for fatalError, which will throw a SAXException |
245 | | * (this is the default behaviour implemented by HandlerBase). |
246 | | * |
247 | | * Applications may register a new or different handler in the |
248 | | * middle of a parse, and the SAX parser must begin using the new |
249 | | * handler immediately. |
250 | | * |
251 | | * @param handler The error handler. |
252 | | * @see ErrorHandler#ErrorHandler |
253 | | * @see SAXException#SAXException |
254 | | * @see HandlerBase#HandlerBase |
255 | | */ |
256 | | virtual void setErrorHandler(ErrorHandler* const handler) ; |
257 | | |
258 | | /** |
259 | | * This method installs the user specified PSVI handler on |
260 | | * the parser. |
261 | | * |
262 | | * @param handler A pointer to the PSVI handler to be called |
263 | | * when the parser comes across 'PSVI' events |
264 | | * as per the schema specification. |
265 | | */ |
266 | | virtual void setPSVIHandler(PSVIHandler* const handler); |
267 | | |
268 | | /** |
269 | | * Set the state of any feature in a SAX2 XMLReader. |
270 | | * Supported features in SAX2 for xerces-c are: |
271 | | * <br>(See the SAX2 Programming Guide for detail description). |
272 | | * |
273 | | * <br>http://xml.org/sax/features/validation (default: false) |
274 | | * <br>http://xml.org/sax/features/namespaces (default: true) |
275 | | * <br>http://xml.org/sax/features/namespace-prefixes (default: false) |
276 | | * <br>http://apache.org/xml/features/validation/dynamic (default: false) |
277 | | * <br>http://apache.org/xml/features/validation/reuse-grammar (default: false) |
278 | | * <br>http://apache.org/xml/features/validation/schema (default: true) |
279 | | * <br>http://apache.org/xml/features/validation/schema-full-checking (default: false) |
280 | | * <br>http://apache.org/xml/features/validating/load-schema (default: true) |
281 | | * <br>http://apache.org/xml/features/nonvalidating/load-external-dtd (default: true) |
282 | | * <br>http://apache.org/xml/features/continue-after-fatal-error (default: false) |
283 | | * <br>http://apache.org/xml/features/validation-error-as-fatal (default: false) |
284 | | * |
285 | | * @param name The unique identifier (URI) of the feature. |
286 | | * @param value The requested state of the feature (true or false). |
287 | | * @exception SAXNotRecognizedException If the requested feature is not known. |
288 | | * @exception SAXNotSupportedException Feature modification is not supported during parse |
289 | | * |
290 | | */ |
291 | | virtual void setFeature(const XMLCh* const name, const bool value) ; |
292 | | |
293 | | /** |
294 | | * Set the value of any property in a SAX2 XMLReader. |
295 | | * Supported properties in SAX2 for xerces-c are: |
296 | | * <br>(See the SAX2 Programming Guide for detail description). |
297 | | * |
298 | | * <br>http://apache.org/xml/properties/schema/external-schemaLocation |
299 | | * <br>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation. |
300 | | * |
301 | | * It takes a void pointer as the property value. Application is required to initialize this void |
302 | | * pointer to a correct type. See the SAX2 Programming Guide |
303 | | * to learn exactly what type of property value each property expects for processing. |
304 | | * Passing a void pointer that was initialized with a wrong type will lead to unexpected result. |
305 | | * If the same property is set more than once, the last one takes effect. |
306 | | * |
307 | | * @param name The unique identifier (URI) of the property being set. |
308 | | * @param value The requested value for the property. See |
309 | | * the SAX2 Programming Guide to learn |
310 | | * exactly what type of property value each property expects for processing. |
311 | | * Passing a void pointer that was initialized with a wrong type will lead |
312 | | * to unexpected result. |
313 | | * @exception SAXNotRecognizedException If the requested property is not known. |
314 | | * @exception SAXNotSupportedException Property modification is not supported during parse |
315 | | */ |
316 | | virtual void setProperty(const XMLCh* const name, void* value) ; |
317 | | |
318 | | /** |
319 | | * Parse an XML document. |
320 | | * |
321 | | * The application can use this method to instruct the SAX parser |
322 | | * to begin parsing an XML document from any valid input |
323 | | * source (a character stream, a byte stream, or a URI). |
324 | | * |
325 | | * Applications may not invoke this method while a parse is in |
326 | | * progress (they should create a new Parser instead for each |
327 | | * additional XML document). Once a parse is complete, an |
328 | | * application may reuse the same Parser object, possibly with a |
329 | | * different input source. |
330 | | * |
331 | | * @param source The input source for the top-level of the |
332 | | * XML document. |
333 | | * @exception SAXException Any SAX exception, possibly |
334 | | * wrapping another exception. |
335 | | * @exception XMLException An exception from the parser or client |
336 | | * handler code. |
337 | | * @see InputSource#InputSource |
338 | | * @see #setEntityResolver |
339 | | * @see #setDTDHandler |
340 | | * @see #setDocumentHandler |
341 | | * @see #setErrorHandler |
342 | | */ |
343 | | virtual void parse |
344 | | ( |
345 | | const InputSource& source |
346 | | ) ; |
347 | | |
348 | | /** |
349 | | * Parse an XML document from a system identifier (URI). |
350 | | * |
351 | | * This method is a shortcut for the common case of reading a |
352 | | * document from a system identifier. It is the exact equivalent |
353 | | * of the following: |
354 | | * |
355 | | * parse(new URLInputSource(systemId)); |
356 | | * |
357 | | * If the system identifier is a URL, it must be fully resolved |
358 | | * by the application before it is passed to the parser. |
359 | | * |
360 | | * @param systemId The system identifier (URI). |
361 | | * @exception SAXException Any SAX exception, possibly |
362 | | * wrapping another exception. |
363 | | * @exception XMLException An exception from the parser or client |
364 | | * handler code. |
365 | | * @see #parse(InputSource) |
366 | | */ |
367 | | virtual void parse |
368 | | ( |
369 | | const XMLCh* const systemId |
370 | | ) ; |
371 | | |
372 | | /** |
373 | | * Parse an XML document from a system identifier (URI). |
374 | | * |
375 | | * This method is a shortcut for the common case of reading a |
376 | | * document from a system identifier. It is the exact equivalent |
377 | | * of the following: |
378 | | * |
379 | | * parse(new URLInputSource(systemId)); |
380 | | * |
381 | | * If the system identifier is a URL, it must be fully resolved |
382 | | * by the application before it is passed to the parser. |
383 | | * |
384 | | * @param systemId The system identifier (URI). |
385 | | * @exception SAXException Any SAX exception, possibly |
386 | | * wrapping another exception. |
387 | | * @exception XMLException An exception from the parser or client |
388 | | * handler code. |
389 | | * @see #parse(InputSource) |
390 | | */ |
391 | | virtual void parse |
392 | | ( |
393 | | const char* const systemId |
394 | | ) ; |
395 | | |
396 | | //@} |
397 | | |
398 | | // ----------------------------------------------------------------------- |
399 | | // SAX 2.0-ext |
400 | | // ----------------------------------------------------------------------- |
401 | | /** @name SAX 2.0-ext */ |
402 | | //@{ |
403 | | /** |
404 | | * This method returns the installed declaration handler. |
405 | | * |
406 | | * @return A pointer to the installed declaration handler object. |
407 | | */ |
408 | | virtual DeclHandler* getDeclarationHandler() const ; |
409 | | |
410 | | /** |
411 | | * This method returns the installed lexical handler. |
412 | | * |
413 | | * @return A pointer to the installed lexical handler object. |
414 | | */ |
415 | | virtual LexicalHandler* getLexicalHandler() const ; |
416 | | |
417 | | /** |
418 | | * Allow an application to register a declaration event handler. |
419 | | * |
420 | | * If the application does not register a declaration handler, |
421 | | * all events reported by the SAX parser will be silently |
422 | | * ignored. (this is the default behaviour implemented by DefaultHandler). |
423 | | * |
424 | | * Applications may register a new or different handler in the |
425 | | * middle of a parse, and the SAX parser must begin using the new |
426 | | * handler immediately. |
427 | | * |
428 | | * @param handler The DTD declaration handler. |
429 | | * @see DeclHandler#DeclHandler |
430 | | * @see SAXException#SAXException |
431 | | * @see DefaultHandler#DefaultHandler |
432 | | */ |
433 | | virtual void setDeclarationHandler(DeclHandler* const handler) ; |
434 | | |
435 | | /** |
436 | | * Allow an application to register a lexical event handler. |
437 | | * |
438 | | * If the application does not register a lexical handler, |
439 | | * all events reported by the SAX parser will be silently |
440 | | * ignored. (this is the default behaviour implemented by HandlerBase). |
441 | | * |
442 | | * Applications may register a new or different handler in the |
443 | | * middle of a parse, and the SAX parser must begin using the new |
444 | | * handler immediately. |
445 | | * |
446 | | * @param handler The error handler. |
447 | | * @see LexicalHandler#LexicalHandler |
448 | | * @see SAXException#SAXException |
449 | | * @see HandlerBase#HandlerBase |
450 | | */ |
451 | | virtual void setLexicalHandler(LexicalHandler* const handler) ; |
452 | | |
453 | | //@} |
454 | | |
455 | | // ----------------------------------------------------------------------- |
456 | | // Getter Methods |
457 | | // ----------------------------------------------------------------------- |
458 | | /** @name Getter Methods (Xerces-C specific) */ |
459 | | //@{ |
460 | | /** |
461 | | * This method is used to get the current validator. |
462 | | * |
463 | | * <b>SAX2XMLReader assumes responsibility for the validator. It will be |
464 | | * deleted when the XMLReader is destroyed.</b> |
465 | | * |
466 | | * @return A pointer to the validator. An application should not deleted |
467 | | * the object returned. |
468 | | * |
469 | | */ |
470 | | virtual XMLValidator* getValidator() const ; |
471 | | //@} |
472 | | |
473 | | /** Get error count from the last parse operation. |
474 | | * |
475 | | * This method returns the error count from the last parse |
476 | | * operation. Note that this count is actually stored in the |
477 | | * scanner, so this method simply returns what the |
478 | | * scanner reports. |
479 | | * |
480 | | * @return number of errors encountered during the latest |
481 | | * parse operation. |
482 | | */ |
483 | | virtual XMLSize_t getErrorCount() const ; |
484 | | |
485 | | /** |
486 | | * This method returns the state of the parser's |
487 | | * exit-on-First-Fatal-Error flag. |
488 | | * |
489 | | * <p>Or you can query the feature "http://apache.org/xml/features/continue-after-fatal-error" |
490 | | * which indicates the opposite state.</p> |
491 | | * |
492 | | * @return true, if the parser is currently configured to |
493 | | * exit on the first fatal error, false otherwise. |
494 | | * |
495 | | * @see #setExitOnFirstFatalError |
496 | | * @see #getFeature |
497 | | */ |
498 | | virtual bool getExitOnFirstFatalError() const ; |
499 | | |
500 | | /** |
501 | | * This method returns the state of the parser's |
502 | | * validation-constraint-fatal flag. |
503 | | * |
504 | | * <p>Or you can query the feature "http://apache.org/xml/features/validation-error-as-fatal" |
505 | | * which means the same thing. |
506 | | * |
507 | | * @return true, if the parser is currently configured to |
508 | | * set validation constraint errors as fatal, false |
509 | | * otherwise. |
510 | | * |
511 | | * @see #setValidationContraintFatal |
512 | | * @see #getFeature |
513 | | */ |
514 | | virtual bool getValidationConstraintFatal() const ; |
515 | | |
516 | | /** |
517 | | * Retrieve the grammar that is associated with the specified namespace key |
518 | | * |
519 | | * @param nameSpaceKey Namespace key |
520 | | * @return Grammar associated with the Namespace key. |
521 | | */ |
522 | | virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey); |
523 | | |
524 | | /** |
525 | | * Retrieve the grammar where the root element is declared. |
526 | | * |
527 | | * @return Grammar where root element declared |
528 | | */ |
529 | | virtual Grammar* getRootGrammar(); |
530 | | |
531 | | /** |
532 | | * Returns the string corresponding to a URI id from the URI string pool. |
533 | | * |
534 | | * @param uriId id of the string in the URI string pool. |
535 | | * @return URI string corresponding to the URI id. |
536 | | */ |
537 | | virtual const XMLCh* getURIText(unsigned int uriId) const; |
538 | | |
539 | | /** |
540 | | * Returns the current src offset within the input source. |
541 | | * To be used only while parsing is in progress. |
542 | | * |
543 | | * @return offset within the input source |
544 | | */ |
545 | | virtual XMLFilePos getSrcOffset() const; |
546 | | |
547 | | //@} |
548 | | |
549 | | // ----------------------------------------------------------------------- |
550 | | // Setter Methods |
551 | | // ----------------------------------------------------------------------- |
552 | | /** @name Setter Methods (Xerces-C specific) */ |
553 | | //@{ |
554 | | /** |
555 | | * This method is used to set a validator. |
556 | | * |
557 | | * <b>SAX2XMLReader assumes responsibility for the validator. It will be |
558 | | * deleted when the XMLReader is destroyed.</b> |
559 | | * |
560 | | * @param valueToAdopt A pointer to the validator that the reader should use. |
561 | | * |
562 | | */ |
563 | | virtual void setValidator(XMLValidator* valueToAdopt) ; |
564 | | |
565 | | /** |
566 | | * This method allows users to set the parser's behaviour when it |
567 | | * encounters the first fatal error. If set to true, the parser |
568 | | * will exit at the first fatal error. If false, then it will |
569 | | * report the error and continue processing. |
570 | | * |
571 | | * <p>The default value is 'true' and the parser exits on the |
572 | | * first fatal error.</p> |
573 | | * |
574 | | * <p>Or you can set the feature "http://apache.org/xml/features/continue-after-fatal-error" |
575 | | * which has the opposite behaviour.</p> |
576 | | * |
577 | | * <p>If both the feature above and this function are used, the latter takes effect.</p> |
578 | | * |
579 | | * @param newState The value specifying whether the parser should |
580 | | * continue or exit when it encounters the first |
581 | | * fatal error. |
582 | | * |
583 | | * @see #getExitOnFirstFatalError |
584 | | * @see #setFeature |
585 | | */ |
586 | | virtual void setExitOnFirstFatalError(const bool newState) ; |
587 | | |
588 | | /** |
589 | | * This method allows users to set the parser's behaviour when it |
590 | | * encounters a validation constraint error. If set to true, and the |
591 | | * the parser will treat validation error as fatal and will exit depends on the |
592 | | * state of "getExitOnFirstFatalError". If false, then it will |
593 | | * report the error and continue processing. |
594 | | * |
595 | | * Note: setting this true does not mean the validation error will be printed with |
596 | | * the word "Fatal Error". It is still printed as "Error", but the parser |
597 | | * will exit if "setExitOnFirstFatalError" is set to true. |
598 | | * |
599 | | * <p>The default value is 'false'.</p> |
600 | | * |
601 | | * <p>Or you can set the feature "http://apache.org/xml/features/validation-error-as-fatal" |
602 | | * which means the same thing.</p> |
603 | | * |
604 | | * <p>If both the feature above and this function are used, the latter takes effect.</p> |
605 | | * |
606 | | * @param newState If true, the parser will exit if "setExitOnFirstFatalError" |
607 | | * is set to true. |
608 | | * |
609 | | * @see #getValidationConstraintFatal |
610 | | * @see #setExitOnFirstFatalError |
611 | | * @see #setFeature |
612 | | */ |
613 | | virtual void setValidationConstraintFatal(const bool newState) ; |
614 | | //@} |
615 | | |
616 | | |
617 | | // ----------------------------------------------------------------------- |
618 | | // Progressive scan methods |
619 | | // ----------------------------------------------------------------------- |
620 | | |
621 | | /** @name Progressive scan methods */ |
622 | | //@{ |
623 | | |
624 | | /** Begin a progressive parse operation |
625 | | * |
626 | | * This method is used to start a progressive parse on a XML file. |
627 | | * To continue parsing, subsequent calls must be to the parseNext |
628 | | * method. |
629 | | * |
630 | | * It scans through the prolog and returns a token to be used on |
631 | | * subsequent scanNext() calls. If the return value is true, then the |
632 | | * token is legal and ready for further use. If it returns false, then |
633 | | * the scan of the prolog failed and the token is not going to work on |
634 | | * subsequent scanNext() calls. |
635 | | * |
636 | | * @param systemId A pointer to a Unicode string representing the path |
637 | | * to the XML file to be parsed. |
638 | | * @param toFill A token maintaing state information to maintain |
639 | | * internal consistency between invocation of 'parseNext' |
640 | | * calls. |
641 | | * |
642 | | * @return 'true', if successful in parsing the prolog. It indicates the |
643 | | * user can go ahead with parsing the rest of the file. It |
644 | | * returns 'false' to indicate that the parser could parse the |
645 | | * prolog (which means the token will not be valid.) |
646 | | * |
647 | | * @see #parseNext |
648 | | * @see #parseFirst(char*,...) |
649 | | * @see #parseFirst(InputSource&,...) |
650 | | */ |
651 | | virtual bool parseFirst |
652 | | ( |
653 | | const XMLCh* const systemId |
654 | | , XMLPScanToken& toFill |
655 | | ) ; |
656 | | |
657 | | /** Begin a progressive parse operation |
658 | | * |
659 | | * This method is used to start a progressive parse on a XML file. |
660 | | * To continue parsing, subsequent calls must be to the parseNext |
661 | | * method. |
662 | | * |
663 | | * It scans through the prolog and returns a token to be used on |
664 | | * subsequent scanNext() calls. If the return value is true, then the |
665 | | * token is legal and ready for further use. If it returns false, then |
666 | | * the scan of the prolog failed and the token is not going to work on |
667 | | * subsequent scanNext() calls. |
668 | | * |
669 | | * @param systemId A pointer to a regular native string representing |
670 | | * the path to the XML file to be parsed. |
671 | | * @param toFill A token maintaing state information to maintain |
672 | | * internal consistency between invocation of 'parseNext' |
673 | | * calls. |
674 | | * |
675 | | * @return 'true', if successful in parsing the prolog. It indicates the |
676 | | * user can go ahead with parsing the rest of the file. It |
677 | | * returns 'false' to indicate that the parser could not parse |
678 | | * the prolog. |
679 | | * |
680 | | * @see #parseNext |
681 | | * @see #parseFirst(XMLCh*,...) |
682 | | * @see #parseFirst(InputSource&,...) |
683 | | */ |
684 | | virtual bool parseFirst |
685 | | ( |
686 | | const char* const systemId |
687 | | , XMLPScanToken& toFill |
688 | | ) ; |
689 | | |
690 | | /** Begin a progressive parse operation |
691 | | * |
692 | | * This method is used to start a progressive parse on a XML file. |
693 | | * To continue parsing, subsequent calls must be to the parseNext |
694 | | * method. |
695 | | * |
696 | | * It scans through the prolog and returns a token to be used on |
697 | | * subsequent scanNext() calls. If the return value is true, then the |
698 | | * token is legal and ready for further use. If it returns false, then |
699 | | * the scan of the prolog failed and the token is not going to work on |
700 | | * subsequent scanNext() calls. |
701 | | * |
702 | | * @param source A const reference to the InputSource object which |
703 | | * points to the XML file to be parsed. |
704 | | * @param toFill A token maintaing state information to maintain |
705 | | * internal consistency between invocation of 'parseNext' |
706 | | * calls. |
707 | | * |
708 | | * @return 'true', if successful in parsing the prolog. It indicates the |
709 | | * user can go ahead with parsing the rest of the file. It |
710 | | * returns 'false' to indicate that the parser could not parse |
711 | | * the prolog. |
712 | | * |
713 | | * @see #parseNext |
714 | | * @see #parseFirst(XMLCh*,...) |
715 | | * @see #parseFirst(char*,...) |
716 | | */ |
717 | | virtual bool parseFirst |
718 | | ( |
719 | | const InputSource& source |
720 | | , XMLPScanToken& toFill |
721 | | ) ; |
722 | | |
723 | | /** Continue a progressive parse operation |
724 | | * |
725 | | * This method is used to continue with progressive parsing of |
726 | | * XML files started by a call to 'parseFirst' method. |
727 | | * |
728 | | * It parses the XML file and stops as soon as it comes across |
729 | | * a XML token (as defined in the XML specification). Relevant |
730 | | * callback handlers are invoked as required by the SAX |
731 | | * specification. |
732 | | * |
733 | | * @param token A token maintaing state information to maintain |
734 | | * internal consistency between invocation of 'parseNext' |
735 | | * calls. |
736 | | * |
737 | | * @return 'true', if successful in parsing the next XML token. |
738 | | * It indicates the user can go ahead with parsing the rest |
739 | | * of the file. It returns 'false' to indicate that the parser |
740 | | * could not find next token as per the XML specification |
741 | | * production rule. |
742 | | * |
743 | | * @see #parseFirst(XMLCh*,...) |
744 | | * @see #parseFirst(char*,...) |
745 | | * @see #parseFirst(InputSource&,...) |
746 | | */ |
747 | | virtual bool parseNext(XMLPScanToken& token) ; |
748 | | |
749 | | /** Reset the parser after a progressive parse |
750 | | * |
751 | | * If a progressive parse loop exits before the end of the document |
752 | | * is reached, the parser has no way of knowing this. So it will leave |
753 | | * open any files or sockets or memory buffers that were in use at |
754 | | * the time that the parse loop exited. |
755 | | * |
756 | | * The next parse operation will cause these open files and such to |
757 | | * be closed, but the next parse operation might occur at some unknown |
758 | | * future point. To avoid this problem, you should reset the parser if |
759 | | * you exit the loop early. |
760 | | * |
761 | | * If you exited because of an error, then this cleanup will be done |
762 | | * for you. Its only when you exit the file prematurely of your own |
763 | | * accord, because you've found what you wanted in the file most |
764 | | * likely. |
765 | | * |
766 | | * @param token A token maintaing state information to maintain |
767 | | * internal consistency between invocation of 'parseNext' |
768 | | * calls. |
769 | | */ |
770 | | virtual void parseReset(XMLPScanToken& token) ; |
771 | | |
772 | | //@} |
773 | | |
774 | | // ----------------------------------------------------------------------- |
775 | | // Implementation of the grammar preparsing interface |
776 | | // ----------------------------------------------------------------------- |
777 | | |
778 | | /** @name Implementation of Grammar preparsing interface's. */ |
779 | | //@{ |
780 | | /** |
781 | | * Preparse schema grammar (XML Schema, DTD, etc.) via an input source |
782 | | * object. |
783 | | * |
784 | | * This method invokes the preparsing process on a schema grammar XML |
785 | | * file specified by the SAX InputSource parameter. |
786 | | * |
787 | | * |
788 | | * @param source A const reference to the SAX InputSource object which |
789 | | * points to the schema grammar file to be preparsed. |
790 | | * @param grammarType The grammar type (Schema or DTD). |
791 | | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
792 | | * otherwise, no caching. Default is <code>false</code>. |
793 | | * @return The preparsed schema grammar object (SchemaGrammar or |
794 | | * DTDGrammar). That grammar object is owned by the parser. |
795 | | * |
796 | | * @exception SAXException Any SAX exception, possibly |
797 | | * wrapping another exception. |
798 | | * @exception XMLException An exception from the parser or client |
799 | | * handler code. |
800 | | * @exception DOMException A DOM exception as per DOM spec. |
801 | | * |
802 | | * @see InputSource#InputSource |
803 | | */ |
804 | | virtual Grammar* loadGrammar(const InputSource& source, |
805 | | const Grammar::GrammarType grammarType, |
806 | | const bool toCache = false); |
807 | | |
808 | | /** |
809 | | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL |
810 | | * |
811 | | * This method invokes the preparsing process on a schema grammar XML |
812 | | * file specified by the file path parameter. |
813 | | * |
814 | | * |
815 | | * @param systemId A const XMLCh pointer to the Unicode string which |
816 | | * contains the path to the XML grammar file to be |
817 | | * preparsed. |
818 | | * @param grammarType The grammar type (Schema or DTD). |
819 | | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
820 | | * otherwise, no caching. Default is <code>false</code>. |
821 | | * @return The preparsed schema grammar object (SchemaGrammar or |
822 | | * DTDGrammar). That grammar object is owned by the parser. |
823 | | * |
824 | | * @exception SAXException Any SAX exception, possibly |
825 | | * wrapping another exception. |
826 | | * @exception XMLException An exception from the parser or client |
827 | | * handler code. |
828 | | * @exception DOMException A DOM exception as per DOM spec. |
829 | | */ |
830 | | virtual Grammar* loadGrammar(const XMLCh* const systemId, |
831 | | const Grammar::GrammarType grammarType, |
832 | | const bool toCache = false); |
833 | | |
834 | | /** |
835 | | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL |
836 | | * |
837 | | * This method invokes the preparsing process on a schema grammar XML |
838 | | * file specified by the file path parameter. |
839 | | * |
840 | | * |
841 | | * @param systemId A const char pointer to a native string which contains |
842 | | * the path to the XML grammar file to be preparsed. |
843 | | * @param grammarType The grammar type (Schema or DTD). |
844 | | * @param toCache If <code>true</code>, we cache the preparsed grammar, |
845 | | * otherwise, no caching. Default is <code>false</code>. |
846 | | * @return The preparsed schema grammar object (SchemaGrammar or |
847 | | * DTDGrammar). That grammar object is owned by the parser. |
848 | | * |
849 | | * @exception SAXException Any SAX exception, possibly |
850 | | * wrapping another exception. |
851 | | * @exception XMLException An exception from the parser or client |
852 | | * handler code. |
853 | | * @exception DOMException A DOM exception as per DOM spec. |
854 | | */ |
855 | | virtual Grammar* loadGrammar(const char* const systemId, |
856 | | const Grammar::GrammarType grammarType, |
857 | | const bool toCache = false); |
858 | | |
859 | | /** |
860 | | * Clear the cached grammar pool |
861 | | */ |
862 | | virtual void resetCachedGrammarPool(); |
863 | | |
864 | | /** Set maximum input buffer size |
865 | | * |
866 | | * This method allows users to limit the size of buffers used in parsing |
867 | | * XML character data. The effect of setting this size is to limit the |
868 | | * size of a ContentHandler::characters() call. |
869 | | * |
870 | | * The parser's default input buffer size is 1 megabyte. |
871 | | * |
872 | | * @param bufferSize The maximum input buffer size |
873 | | */ |
874 | | virtual void setInputBufferSize(const XMLSize_t bufferSize); |
875 | | |
876 | | //@} |
877 | | |
878 | | |
879 | | // ----------------------------------------------------------------------- |
880 | | // Advanced document handler list maintenance methods |
881 | | // ----------------------------------------------------------------------- |
882 | | |
883 | | /** @name Advanced document handler list maintenance methods */ |
884 | | //@{ |
885 | | /** |
886 | | * This method installs the specified 'advanced' document callback |
887 | | * handler, thereby allowing the user to customize the processing, |
888 | | * if they choose to do so. Any number of advanced callback handlers |
889 | | * maybe installed. |
890 | | * |
891 | | * <p>The methods in the advanced callback interface represent |
892 | | * Xerces-C extensions. There is no specification for this interface.</p> |
893 | | * |
894 | | * @param toInstall A pointer to the users advanced callback handler. |
895 | | * |
896 | | * @see #removeAdvDocHandler |
897 | | */ |
898 | | virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) ; |
899 | | |
900 | | /** |
901 | | * This method removes the 'advanced' document handler callback from |
902 | | * the underlying parser scanner. If no handler is installed, advanced |
903 | | * callbacks are not invoked by the scanner. |
904 | | * @param toRemove A pointer to the advanced callback handler which |
905 | | * should be removed. |
906 | | * |
907 | | * @see #installAdvDocHandler |
908 | | */ |
909 | | virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) ; |
910 | | //@} |
911 | | |
912 | | // ----------------------------------------------------------------------- |
913 | | // Implementation of the XMLDocumentHandler interface |
914 | | // ----------------------------------------------------------------------- |
915 | | /** @name Implementation of the XMLDocumentHandler Interface. */ |
916 | | //@{ |
917 | | /** |
918 | | * This method is used to report all the characters scanned |
919 | | * by the parser. The driver will invoke the 'characters' |
920 | | * method of the user installed SAX Document Handler. |
921 | | * |
922 | | * <p>If any advanced callback handlers are installed, the |
923 | | * corresponding 'docCharacters' method will also be invoked.</p> |
924 | | * |
925 | | * @param chars A const pointer to a Unicode string representing the |
926 | | * character data. |
927 | | * @param length The length of the Unicode string returned in 'chars'. |
928 | | * @param cdataSection A flag indicating if the characters represent |
929 | | * content from the CDATA section. |
930 | | * @see DocumentHandler#characters |
931 | | */ |
932 | | virtual void docCharacters |
933 | | ( |
934 | | const XMLCh* const chars |
935 | | , const XMLSize_t length |
936 | | , const bool cdataSection |
937 | | ); |
938 | | |
939 | | /** |
940 | | * This method is used to report any comments scanned by the parser. |
941 | | * This method is a no-op unless, unless an advanced callback handler |
942 | | * is installed, in which case the corresponding 'docComment' method |
943 | | * is invoked. |
944 | | * |
945 | | * @param comment A const pointer to a null terminated Unicode |
946 | | * string representing the comment text. |
947 | | */ |
948 | | virtual void docComment |
949 | | ( |
950 | | const XMLCh* const comment |
951 | | ); |
952 | | |
953 | | /** |
954 | | * This method is used to report any PI scanned by the parser. |
955 | | * |
956 | | * <p>Any PI's occurring before any 'content' are not reported |
957 | | * to any SAX handler as per the specification. However, all |
958 | | * PI's within content are reported via the SAX Document Handler's |
959 | | * 'processingInstruction' method. |
960 | | * |
961 | | * <p>If any advanced callback handlers are installed, the |
962 | | * corresponding 'docPI' method will be invoked.</p> |
963 | | * |
964 | | * @param target A const pointer to a Unicode string representing the |
965 | | * target of the PI declaration. |
966 | | * @param data A const pointer to a Unicode string representing the |
967 | | * data of the PI declaration. See the PI production rule |
968 | | * in the XML specification for details. |
969 | | * |
970 | | * @see DocumentHandler#processingInstruction |
971 | | */ |
972 | | virtual void docPI |
973 | | ( |
974 | | const XMLCh* const target |
975 | | , const XMLCh* const data |
976 | | ); |
977 | | |
978 | | /** |
979 | | * This method is used to indicate the end of root element |
980 | | * was just scanned by the parser. Corresponding 'endDocument' |
981 | | * method of the user installed SAX Document Handler will also |
982 | | * be invoked. |
983 | | * |
984 | | * <p>In addition, if any advanced callback handlers are installed, |
985 | | * the corresponding 'endDocument' method is invoked.</p> |
986 | | * |
987 | | * @see DocumentHandler#endDocument |
988 | | */ |
989 | | virtual void endDocument(); |
990 | | |
991 | | /** |
992 | | * This method is used to indicate the end tag of an element. |
993 | | * The driver will invoke the corresponding 'endElement' method of |
994 | | * the SAX Document Handler interface. |
995 | | * |
996 | | * <p>If any advanced callback handlers are installed, the |
997 | | * corresponding 'endElement' method is also invoked.</p> |
998 | | * |
999 | | * @param elemDecl A const reference to the object containing element |
1000 | | * declaration information. |
1001 | | * @param urlId An id referring to the namespace prefix, if |
1002 | | * namespaces setting is switched on. |
1003 | | * @param isRoot A flag indicating whether this element was the |
1004 | | * root element. |
1005 | | * @param elemPrefix A const pointer to a Unicode string containing |
1006 | | * the namespace prefix for this element. Applicable |
1007 | | * only when namespace processing is enabled. |
1008 | | * @see DocumentHandler#endElement |
1009 | | */ |
1010 | | virtual void endElement |
1011 | | ( |
1012 | | const XMLElementDecl& elemDecl |
1013 | | , const unsigned int urlId |
1014 | | , const bool isRoot |
1015 | | , const XMLCh* const elemPrefix=0 |
1016 | | ); |
1017 | | |
1018 | | /** |
1019 | | * This method is used to indicate that an end of an entity reference |
1020 | | * was just scanned. |
1021 | | * |
1022 | | * <p>If any advanced callback handlers are installed, the |
1023 | | * corresponding 'endEntityReference' method is invoked.</p> |
1024 | | * |
1025 | | * @param entDecl A const reference to the object containing the |
1026 | | * entity declaration information. |
1027 | | */ |
1028 | | virtual void endEntityReference |
1029 | | ( |
1030 | | const XMLEntityDecl& entDecl |
1031 | | ); |
1032 | | |
1033 | | /** |
1034 | | * This method is used to report all the whitespace characters, |
1035 | | * which are determined to be 'ignorable'. This distinction |
1036 | | * between characters is only made, if validation is enabled. |
1037 | | * Corresponding 'ignorableWhitespace' method of the user installed |
1038 | | * SAX Document Handler interface is called. |
1039 | | * |
1040 | | * <p>Any whitespace before content is not reported to the SAX |
1041 | | * Document Handler method, as per the SAX specification. |
1042 | | * However, if any advanced callback handlers are installed, the |
1043 | | * corresponding 'ignorableWhitespace' method is invoked.</p> |
1044 | | * |
1045 | | * @param chars A const pointer to a Unicode string representing the |
1046 | | * ignorable whitespace character data. |
1047 | | * @param length The length of the Unicode string 'chars'. |
1048 | | * @param cdataSection A flag indicating if the characters represent |
1049 | | * content from the CDATA section. |
1050 | | * @see DocumentHandler#ignorableWhitespace |
1051 | | */ |
1052 | | virtual void ignorableWhitespace |
1053 | | ( |
1054 | | const XMLCh* const chars |
1055 | | , const XMLSize_t length |
1056 | | , const bool cdataSection |
1057 | | ); |
1058 | | |
1059 | | /** |
1060 | | * This method allows the user installed Document Handler and |
1061 | | * any advanced callback handlers to 'reset' themselves. |
1062 | | */ |
1063 | | virtual void resetDocument(); |
1064 | | |
1065 | | /** |
1066 | | * This method is used to report the start of the parsing process. |
1067 | | * The corresponding user installed SAX Document Handler's method |
1068 | | * 'startDocument' is invoked. |
1069 | | * |
1070 | | * <p>If any advanced callback handlers are installed, then the |
1071 | | * corresponding 'startDocument' method is also called.</p> |
1072 | | * |
1073 | | * @see DocumentHandler#startDocument |
1074 | | */ |
1075 | | virtual void startDocument(); |
1076 | | |
1077 | | /** |
1078 | | * This method is used to report the start of an element. It is |
1079 | | * called at the end of the element, by which time all attributes |
1080 | | * specified are also parsed. The corresponding user installed |
1081 | | * SAX Document Handler's method 'startElement' is invoked. |
1082 | | * |
1083 | | * <p>If any advanced callback handlers are installed, then the |
1084 | | * corresponding 'startElement' method is also called.</p> |
1085 | | * |
1086 | | * @param elemDecl A const reference to the object containing element |
1087 | | * declaration information. |
1088 | | * @param urlId An id referring to the namespace prefix, if |
1089 | | * namespaces setting is switched on. |
1090 | | * @param elemPrefix A const pointer to a Unicode string containing |
1091 | | * the namespace prefix for this element. Applicable |
1092 | | * only when namespace processing is enabled. |
1093 | | * @param attrList A const reference to the object containing the |
1094 | | * list of attributes just scanned for this element. |
1095 | | * @param attrCount A count of number of attributes in the list |
1096 | | * specified by the parameter 'attrList'. |
1097 | | * @param isEmpty A flag indicating whether this is an empty element |
1098 | | * or not. |
1099 | | * @param isRoot A flag indicating whether this element was the |
1100 | | * root element. |
1101 | | * @see DocumentHandler#startElement |
1102 | | */ |
1103 | | virtual void startElement |
1104 | | ( |
1105 | | const XMLElementDecl& elemDecl |
1106 | | , const unsigned int urlId |
1107 | | , const XMLCh* const elemPrefix |
1108 | | , const RefVectorOf<XMLAttr>& attrList |
1109 | | , const XMLSize_t attrCount |
1110 | | , const bool isEmpty |
1111 | | , const bool isRoot |
1112 | | ); |
1113 | | |
1114 | | /** |
1115 | | * This method is used to indicate the start of an entity reference. |
1116 | | * |
1117 | | * <p>If any advanced callback handlers are installed, the |
1118 | | * corresponding 'endEntityReference' method is invoked.</p> |
1119 | | * |
1120 | | * @param entDecl A const reference to the object containing the |
1121 | | * entity declaration information. |
1122 | | */ |
1123 | | virtual void startEntityReference |
1124 | | ( |
1125 | | const XMLEntityDecl& entDecl |
1126 | | ); |
1127 | | |
1128 | | /** |
1129 | | * This method is used to report the XML decl scanned by the parser. |
1130 | | * Refer to the XML specification to see the meaning of parameters. |
1131 | | * |
1132 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1133 | | * implementation.</font></b> |
1134 | | * |
1135 | | * @param versionStr A const pointer to a Unicode string representing |
1136 | | * version string value. |
1137 | | * @param encodingStr A const pointer to a Unicode string representing |
1138 | | * the encoding string value. |
1139 | | * @param standaloneStr A const pointer to a Unicode string |
1140 | | * representing the standalone string value. |
1141 | | * @param actualEncodingStr A const pointer to a Unicode string |
1142 | | * representing the actual encoding string |
1143 | | * value. |
1144 | | */ |
1145 | | virtual void XMLDecl |
1146 | | ( |
1147 | | const XMLCh* const versionStr |
1148 | | , const XMLCh* const encodingStr |
1149 | | , const XMLCh* const standaloneStr |
1150 | | , const XMLCh* const actualEncodingStr |
1151 | | ); |
1152 | | //@} |
1153 | | |
1154 | | |
1155 | | // ----------------------------------------------------------------------- |
1156 | | // Implementation of the XMLErrorReporter interface |
1157 | | // ----------------------------------------------------------------------- |
1158 | | |
1159 | | /** @name Implementation of the XMLErrorReporter Interface. */ |
1160 | | //@{ |
1161 | | /** |
1162 | | * This method is used to report back errors found while parsing the |
1163 | | * XML file. The driver will call the corresponding user installed |
1164 | | * SAX Error Handler methods: 'fatal', 'error', 'warning' depending |
1165 | | * on the severity of the error. This classification is defined by |
1166 | | * the XML specification. |
1167 | | * |
1168 | | * @param errCode An integer code for the error. |
1169 | | * @param msgDomain A const pointer to an Unicode string representing |
1170 | | * the message domain to use. |
1171 | | * @param errType An enumeration classifying the severity of the error. |
1172 | | * @param errorText A const pointer to an Unicode string representing |
1173 | | * the text of the error message. |
1174 | | * @param systemId A const pointer to an Unicode string representing |
1175 | | * the system id of the XML file where this error |
1176 | | * was discovered. |
1177 | | * @param publicId A const pointer to an Unicode string representing |
1178 | | * the public id of the XML file where this error |
1179 | | * was discovered. |
1180 | | * @param lineNum The line number where the error occurred. |
1181 | | * @param colNum The column number where the error occurred. |
1182 | | * @see ErrorHandler |
1183 | | */ |
1184 | | virtual void error |
1185 | | ( |
1186 | | const unsigned int errCode |
1187 | | , const XMLCh* const msgDomain |
1188 | | , const XMLErrorReporter::ErrTypes errType |
1189 | | , const XMLCh* const errorText |
1190 | | , const XMLCh* const systemId |
1191 | | , const XMLCh* const publicId |
1192 | | , const XMLFileLoc lineNum |
1193 | | , const XMLFileLoc colNum |
1194 | | ); |
1195 | | |
1196 | | /** |
1197 | | * This method allows the user installed Error Handler |
1198 | | * callback to 'reset' itself. |
1199 | | * |
1200 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1201 | | * implementation.</font></b> |
1202 | | * |
1203 | | */ |
1204 | | virtual void resetErrors(); |
1205 | | //@} |
1206 | | |
1207 | | |
1208 | | // ----------------------------------------------------------------------- |
1209 | | // Implementation of the XMLEntityHandler interface |
1210 | | // ----------------------------------------------------------------------- |
1211 | | |
1212 | | /** @name Implementation of the XMLEntityHandler Interface. */ |
1213 | | //@{ |
1214 | | /** |
1215 | | * This method is used to indicate the end of parsing of an external |
1216 | | * entity file. |
1217 | | * |
1218 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1219 | | * implementation.</font></b> |
1220 | | * |
1221 | | * @param inputSource A const reference to the InputSource object |
1222 | | * which points to the XML file being parsed. |
1223 | | * @see InputSource |
1224 | | */ |
1225 | | virtual void endInputSource(const InputSource& inputSource); |
1226 | | |
1227 | | /** |
1228 | | * This method allows an installed XMLEntityHandler to further |
1229 | | * process any system id's of external entities encountered in |
1230 | | * the XML file being parsed, such as redirection etc. |
1231 | | * |
1232 | | * <b><font color="#FF0000">This method always returns 'false' |
1233 | | * for this SAX driver implementation.</font></b> |
1234 | | * |
1235 | | * @param systemId A const pointer to an Unicode string representing |
1236 | | * the system id scanned by the parser. |
1237 | | * @param toFill A pointer to a buffer in which the application |
1238 | | * processed system id is stored. |
1239 | | * @return 'true', if any processing is done, 'false' otherwise. |
1240 | | */ |
1241 | | virtual bool expandSystemId |
1242 | | ( |
1243 | | const XMLCh* const systemId |
1244 | | , XMLBuffer& toFill |
1245 | | ); |
1246 | | |
1247 | | /** |
1248 | | * This method allows the installed XMLEntityHandler to reset |
1249 | | * itself. |
1250 | | * |
1251 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1252 | | * implementation.</font></b> |
1253 | | */ |
1254 | | virtual void resetEntities(); |
1255 | | |
1256 | | /** Resolve a public/system id |
1257 | | * |
1258 | | * This method allows a user installed entity handler to further |
1259 | | * process any pointers to external entities. The applications can |
1260 | | * implement 'redirection' via this callback. |
1261 | | * |
1262 | | * @param resourceIdentifier An object containing the type of |
1263 | | * resource to be resolved and the associated data members |
1264 | | * corresponding to this type. |
1265 | | * @return The value returned by the user installed resolveEntity |
1266 | | * method or NULL otherwise to indicate no processing was done. |
1267 | | * The returned InputSource is owned by the parser which is |
1268 | | * responsible to clean up the memory. |
1269 | | * @see XMLEntityHandler |
1270 | | * @see XMLEntityResolver |
1271 | | */ |
1272 | | virtual InputSource* resolveEntity |
1273 | | ( |
1274 | | XMLResourceIdentifier* resourceIdentifier |
1275 | | ); |
1276 | | |
1277 | | /** |
1278 | | * This method is used to indicate the start of parsing an |
1279 | | * external entity file. |
1280 | | * |
1281 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1282 | | * implementation.</font></b> |
1283 | | * |
1284 | | * @param inputSource A const reference to the InputSource object |
1285 | | * which points to the external entity |
1286 | | * being parsed. |
1287 | | */ |
1288 | | virtual void startInputSource(const InputSource& inputSource); |
1289 | | //@} |
1290 | | |
1291 | | // ----------------------------------------------------------------------- |
1292 | | // Implementation of the Deprecated DocTypeHandler Interface |
1293 | | // ----------------------------------------------------------------------- |
1294 | | |
1295 | | /** @name Implementation of the deprecated DocTypeHandler Interface */ |
1296 | | //@{ |
1297 | | /** |
1298 | | * This method is used to report an attribute definition. |
1299 | | * |
1300 | | * <b><font color="#FF0000">This method is a no-op for this SAX |
1301 | | * driver implementation.</font></b> |
1302 | | * |
1303 | | * @param elemDecl A const reference to the object containing information |
1304 | | * about the element whose attribute definition was just |
1305 | | * parsed. |
1306 | | * @param attDef A const reference to the object containing information |
1307 | | * attribute definition. |
1308 | | * @param ignore The flag indicating whether this attribute definition |
1309 | | * was ignored by the parser or not. |
1310 | | */ |
1311 | | virtual void attDef |
1312 | | ( |
1313 | | const DTDElementDecl& elemDecl |
1314 | | , const DTDAttDef& attDef |
1315 | | , const bool ignoring |
1316 | | ); |
1317 | | |
1318 | | /** |
1319 | | * This method is used to report a comment occurring within the DTD. |
1320 | | * |
1321 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1322 | | * implementation.</font></b> |
1323 | | * |
1324 | | * @param comment A const pointer to a Unicode string representing the |
1325 | | * text of the comment just parsed. |
1326 | | */ |
1327 | | virtual void doctypeComment |
1328 | | ( |
1329 | | const XMLCh* const comment |
1330 | | ); |
1331 | | |
1332 | | /** |
1333 | | * This method is used to report the DOCTYPE declaration. |
1334 | | * |
1335 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1336 | | * implementation.</font></b> |
1337 | | * |
1338 | | * @param elemDecl A const reference to the object containing information |
1339 | | * about the root element definition declaration of the |
1340 | | * XML document being parsed. |
1341 | | * @param publicId A const pointer to a Unicode string representing the |
1342 | | * public id of the DTD file. |
1343 | | * @param systemId A const pointer to a Unicode string representing the |
1344 | | * system id of the DTD file. |
1345 | | * @param hasIntSubset A flag indicating if this XML file contains any |
1346 | | * internal subset. |
1347 | | * @param hasExtSubset A flag indicating if this XML file contains any |
1348 | | * external subset. Default is false. |
1349 | | */ |
1350 | | virtual void doctypeDecl |
1351 | | ( |
1352 | | const DTDElementDecl& elemDecl |
1353 | | , const XMLCh* const publicId |
1354 | | , const XMLCh* const systemId |
1355 | | , const bool hasIntSubset |
1356 | | , const bool hasExtSubset = false |
1357 | | ); |
1358 | | |
1359 | | /** |
1360 | | * This method is used to report any PI declarations |
1361 | | * occurring inside the DTD definition block. |
1362 | | * |
1363 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1364 | | * implementation.</font></b> |
1365 | | * |
1366 | | * @param target A const pointer to a Unicode string representing the |
1367 | | * target of the PI declaration. |
1368 | | * @param data A const pointer to a Unicode string representing the |
1369 | | * data of the PI declaration. See the PI production rule |
1370 | | * in the XML specification for details. |
1371 | | */ |
1372 | | virtual void doctypePI |
1373 | | ( |
1374 | | const XMLCh* const target |
1375 | | , const XMLCh* const data |
1376 | | ); |
1377 | | |
1378 | | /** |
1379 | | * This method is used to report any whitespaces |
1380 | | * occurring inside the DTD definition block. |
1381 | | * |
1382 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1383 | | * implementation.</font></b> |
1384 | | * |
1385 | | * @param chars A const pointer to a Unicode string representing the |
1386 | | * whitespace characters. |
1387 | | * @param length The length of the whitespace Unicode string. |
1388 | | */ |
1389 | | virtual void doctypeWhitespace |
1390 | | ( |
1391 | | const XMLCh* const chars |
1392 | | , const XMLSize_t length |
1393 | | ); |
1394 | | |
1395 | | /** |
1396 | | * This method is used to report an element declarations |
1397 | | * successfully scanned by the parser. |
1398 | | * |
1399 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1400 | | * implementation.</font></b> |
1401 | | * |
1402 | | * @param decl A const reference to the object containing element |
1403 | | * declaration information. |
1404 | | * @param isIgnored The flag indicating whether this definition was |
1405 | | * ignored by the parser or not. |
1406 | | */ |
1407 | | virtual void elementDecl |
1408 | | ( |
1409 | | const DTDElementDecl& decl |
1410 | | , const bool isIgnored |
1411 | | ); |
1412 | | |
1413 | | /** |
1414 | | * This method is used to report the end of an attribute |
1415 | | * list declaration for an element. |
1416 | | * |
1417 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1418 | | * implementation.</font></b> |
1419 | | * |
1420 | | * @param elemDecl A const reference to the object containing element |
1421 | | * declaration information. |
1422 | | */ |
1423 | | virtual void endAttList |
1424 | | ( |
1425 | | const DTDElementDecl& elemDecl |
1426 | | ); |
1427 | | |
1428 | | /** |
1429 | | * This method is used to report the end of the internal subset. |
1430 | | * |
1431 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1432 | | * implementation.</font></b> |
1433 | | */ |
1434 | | virtual void endIntSubset(); |
1435 | | |
1436 | | /** |
1437 | | * This method is used to report the end of the external subset. |
1438 | | * |
1439 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1440 | | * implementation.</font></b> |
1441 | | */ |
1442 | | virtual void endExtSubset(); |
1443 | | |
1444 | | /** |
1445 | | * This method is used to report any entity declarations. |
1446 | | * For unparsed entities, this driver will invoke the |
1447 | | * SAX DTDHandler::unparsedEntityDecl callback. |
1448 | | * |
1449 | | * @param entityDecl A const reference to the object containing |
1450 | | * the entity declaration information. |
1451 | | * @param isPEDecl The flag indicating whether this was a |
1452 | | * parameter entity declaration or not. |
1453 | | * @param isIgnored The flag indicating whether this definition |
1454 | | * was ignored by the parser or not. |
1455 | | * |
1456 | | * @see DTDHandler#unparsedEntityDecl |
1457 | | */ |
1458 | | virtual void entityDecl |
1459 | | ( |
1460 | | const DTDEntityDecl& entityDecl |
1461 | | , const bool isPEDecl |
1462 | | , const bool isIgnored |
1463 | | ); |
1464 | | |
1465 | | /** |
1466 | | * This method allows the user installed DTD handler to |
1467 | | * reset itself. |
1468 | | */ |
1469 | | virtual void resetDocType(); |
1470 | | |
1471 | | /** |
1472 | | * This method is used to report any notation declarations. |
1473 | | * If there is a user installed DTDHandler, then the driver will |
1474 | | * invoke the SAX DTDHandler::notationDecl callback. |
1475 | | * |
1476 | | * @param notDecl A const reference to the object containing the notation |
1477 | | * declaration information. |
1478 | | * @param isIgnored The flag indicating whether this definition was ignored |
1479 | | * by the parser or not. |
1480 | | * |
1481 | | * @see DTDHandler#notationDecl |
1482 | | */ |
1483 | | virtual void notationDecl |
1484 | | ( |
1485 | | const XMLNotationDecl& notDecl |
1486 | | , const bool isIgnored |
1487 | | ); |
1488 | | |
1489 | | /** |
1490 | | * This method is used to indicate the start of an element's attribute |
1491 | | * list declaration. |
1492 | | * |
1493 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1494 | | * implementation.</font></b> |
1495 | | * |
1496 | | * @param elemDecl A const reference to the object containing element |
1497 | | * declaration information. |
1498 | | */ |
1499 | | virtual void startAttList |
1500 | | ( |
1501 | | const DTDElementDecl& elemDecl |
1502 | | ); |
1503 | | |
1504 | | /** |
1505 | | * This method is used indicate the start of the internal subset. |
1506 | | * |
1507 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1508 | | * implementation.</font></b> |
1509 | | */ |
1510 | | virtual void startIntSubset(); |
1511 | | |
1512 | | /** |
1513 | | * This method is used indicate the start of the external subset. |
1514 | | * |
1515 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1516 | | * implementation.</font></b> |
1517 | | */ |
1518 | | virtual void startExtSubset(); |
1519 | | |
1520 | | /** |
1521 | | * This method is used to report the TextDecl. Refer to the XML |
1522 | | * specification for the syntax of a TextDecl. |
1523 | | * |
1524 | | * <b><font color="#FF0000">This method is a no-op for this SAX driver |
1525 | | * implementation.</font></b> |
1526 | | * |
1527 | | * @param versionStr A const pointer to a Unicode string representing |
1528 | | * the version number of the 'version' clause. |
1529 | | * @param encodingStr A const pointer to a Unicode string representing |
1530 | | * the encoding name of the 'encoding' clause. |
1531 | | */ |
1532 | | virtual void TextDecl |
1533 | | ( |
1534 | | const XMLCh* const versionStr |
1535 | | , const XMLCh* const encodingStr |
1536 | | ); |
1537 | | //@} |
1538 | | |
1539 | | |
1540 | | private : |
1541 | | // ----------------------------------------------------------------------- |
1542 | | // Unimplemented constructors and operators |
1543 | | // ----------------------------------------------------------------------- |
1544 | | SAX2XMLReaderImpl(const SAX2XMLReaderImpl&); |
1545 | | SAX2XMLReaderImpl& operator=(const SAX2XMLReaderImpl&); |
1546 | | |
1547 | | // ----------------------------------------------------------------------- |
1548 | | // Initialize/Cleanup methods |
1549 | | // ----------------------------------------------------------------------- |
1550 | | void initialize(); |
1551 | | void cleanUp(); |
1552 | | void resetInProgress(); |
1553 | | |
1554 | | // ----------------------------------------------------------------------- |
1555 | | // Private data members |
1556 | | // |
1557 | | // fAttrList |
1558 | | // A temporary implementation of the basic SAX2 Attributes |
1559 | | // interface. We use this one over and over on each startElement |
1560 | | // event to allow SAX-like access to the element attributes. |
1561 | | // |
1562 | | // fDocHandler |
1563 | | // The installed SAX content handler, if any. Null if none. |
1564 | | // |
1565 | | // fnamespacePrefix |
1566 | | // Indicates whether the namespace-prefix feature is on or off. |
1567 | | // |
1568 | | // fautoValidation |
1569 | | // Indicates whether automatic validation is on or off |
1570 | | // |
1571 | | // fValidation |
1572 | | // Indicates whether the 'validation' core features is on or off |
1573 | | // |
1574 | | // fReuseGrammar |
1575 | | // Tells the parser whether it should reuse the grammar or not. |
1576 | | // If true, there cannot be any internal subset. |
1577 | | // |
1578 | | // fPrefixesStorage |
1579 | | // the namespace prefixes will be allocated from this pool |
1580 | | // |
1581 | | // fPrefixes |
1582 | | // A Stack of the current namespace prefixes that need calls to |
1583 | | // endPrefixMapping |
1584 | | // |
1585 | | // fPrefixCounts |
1586 | | // A Stack of the number of prefixes that need endPrefixMapping |
1587 | | // calls for that element |
1588 | | // |
1589 | | // fDTDHandler |
1590 | | // The installed SAX DTD handler, if any. Null if none. |
1591 | | // |
1592 | | // fElemDepth |
1593 | | // This is used to track the element nesting depth, so that we can |
1594 | | // know when we are inside content. This is so we can ignore char |
1595 | | // data outside of content. |
1596 | | // |
1597 | | // fEntityResolver |
1598 | | // The installed SAX entity handler, if any. Null if none. |
1599 | | // |
1600 | | // fErrorHandler |
1601 | | // The installed SAX error handler, if any. Null if none. |
1602 | | // |
1603 | | // fLexicalHandler |
1604 | | // The installed SAX lexical handler, if any. Null if none. |
1605 | | // |
1606 | | // fDecllHandler |
1607 | | // The installed SAX declaration handler, if any. Null if none. |
1608 | | // |
1609 | | // fAdvDHCount |
1610 | | // fAdvDHList |
1611 | | // fAdvDHListSize |
1612 | | // This is an array of pointers to XMLDocumentHandlers, which is |
1613 | | // how we see installed advanced document handlers. There will |
1614 | | // usually not be very many at all, so a simple array is used |
1615 | | // instead of a collection, for performance. It will grow if needed, |
1616 | | // but that is unlikely. |
1617 | | // |
1618 | | // The count is how many handlers are currently installed. The size |
1619 | | // is how big the array itself is (for expansion purposes.) When |
1620 | | // count == size, is time to expand. |
1621 | | // |
1622 | | // fParseInProgress |
1623 | | // This flag is set once a parse starts. It is used to prevent |
1624 | | // multiple entrance or reentrance of the parser. |
1625 | | // |
1626 | | // fScanner |
1627 | | // The scanner being used by this parser. It is created internally |
1628 | | // during construction. |
1629 | | // |
1630 | | // fHasExternalSubset |
1631 | | // Indicate if the document has external DTD subset. |
1632 | | // |
1633 | | // fGrammarPool |
1634 | | // The grammar pool passed from external application (through derivatives). |
1635 | | // which could be 0, not owned. |
1636 | | // |
1637 | | // ----------------------------------------------------------------------- |
1638 | | bool fNamespacePrefix; |
1639 | | bool fAutoValidation; |
1640 | | bool fValidation; |
1641 | | bool fParseInProgress; |
1642 | | bool fHasExternalSubset; |
1643 | | XMLSize_t fElemDepth; |
1644 | | XMLSize_t fAdvDHCount; |
1645 | | XMLSize_t fAdvDHListSize; |
1646 | | VecAttributesImpl fAttrList ; |
1647 | | ContentHandler* fDocHandler ; |
1648 | | RefVectorOf<XMLAttr>* fTempAttrVec ; |
1649 | | XMLStringPool* fPrefixesStorage ; |
1650 | | ValueStackOf<unsigned int>* fPrefixes ; |
1651 | | ValueStackOf<XMLSize_t>* fPrefixCounts ; |
1652 | | XMLBuffer* fTempQName; |
1653 | | DTDHandler* fDTDHandler; |
1654 | | EntityResolver* fEntityResolver; |
1655 | | XMLEntityResolver* fXMLEntityResolver; |
1656 | | ErrorHandler* fErrorHandler; |
1657 | | PSVIHandler* fPSVIHandler; |
1658 | | LexicalHandler* fLexicalHandler; |
1659 | | DeclHandler* fDeclHandler; |
1660 | | XMLDocumentHandler** fAdvDHList; |
1661 | | XMLScanner* fScanner; |
1662 | | GrammarResolver* fGrammarResolver; |
1663 | | XMLStringPool* fURIStringPool; |
1664 | | XMLValidator* fValidator; |
1665 | | MemoryManager* fMemoryManager; |
1666 | | XMLGrammarPool* fGrammarPool; |
1667 | | |
1668 | | // ----------------------------------------------------------------------- |
1669 | | // internal function used to set the state of the parser |
1670 | | // ----------------------------------------------------------------------- |
1671 | | void setValidationScheme(const ValSchemes newScheme); |
1672 | | void setDoNamespaces(const bool newState); |
1673 | | bool getDoNamespaces() const; |
1674 | | void setDoSchema(const bool newState); |
1675 | | bool getDoSchema() const; |
1676 | | }; |
1677 | | |
1678 | | |
1679 | | // --------------------------------------------------------------------------- |
1680 | | // SAX2XMLReader: Getter methods |
1681 | | // --------------------------------------------------------------------------- |
1682 | | inline ContentHandler* SAX2XMLReaderImpl::getContentHandler() const |
1683 | 0 | { |
1684 | 0 | return fDocHandler; |
1685 | 0 | } |
1686 | | |
1687 | | inline DTDHandler* SAX2XMLReaderImpl::getDTDHandler() const |
1688 | 0 | { |
1689 | 0 | return fDTDHandler ; |
1690 | 0 | } |
1691 | | |
1692 | | inline EntityResolver* SAX2XMLReaderImpl::getEntityResolver() const |
1693 | 0 | { |
1694 | 0 | return fEntityResolver; |
1695 | 0 | } |
1696 | | |
1697 | | inline XMLEntityResolver* SAX2XMLReaderImpl::getXMLEntityResolver() const |
1698 | 0 | { |
1699 | 0 | return fXMLEntityResolver; |
1700 | 0 | } |
1701 | | |
1702 | | inline ErrorHandler* SAX2XMLReaderImpl::getErrorHandler() const |
1703 | 0 | { |
1704 | 0 | return fErrorHandler; |
1705 | 0 | } |
1706 | | |
1707 | | inline PSVIHandler* SAX2XMLReaderImpl::getPSVIHandler() const |
1708 | 0 | { |
1709 | 0 | return fPSVIHandler; |
1710 | 0 | } |
1711 | | |
1712 | | inline LexicalHandler* SAX2XMLReaderImpl::getLexicalHandler() const |
1713 | 0 | { |
1714 | 0 | return fLexicalHandler; |
1715 | 0 | } |
1716 | | |
1717 | | inline DeclHandler* SAX2XMLReaderImpl::getDeclarationHandler() const |
1718 | 0 | { |
1719 | 0 | return fDeclHandler; |
1720 | 0 | } |
1721 | | |
1722 | | inline bool SAX2XMLReaderImpl::getExitOnFirstFatalError() const |
1723 | 0 | { |
1724 | 0 | return fScanner->getExitOnFirstFatal(); |
1725 | 0 | } |
1726 | | |
1727 | | inline bool SAX2XMLReaderImpl::getValidationConstraintFatal() const |
1728 | 0 | { |
1729 | 0 | return fScanner->getValidationConstraintFatal(); |
1730 | 0 | } |
1731 | | |
1732 | | inline Grammar* SAX2XMLReaderImpl::getRootGrammar() |
1733 | 0 | { |
1734 | 0 | return fScanner->getRootGrammar(); |
1735 | 0 | } |
1736 | | |
1737 | | inline const XMLCh* SAX2XMLReaderImpl::getURIText(unsigned int uriId) const |
1738 | 0 | { |
1739 | 0 | return fScanner->getURIText(uriId); |
1740 | 0 | } |
1741 | | |
1742 | | inline XMLFilePos SAX2XMLReaderImpl::getSrcOffset() const |
1743 | 0 | { |
1744 | 0 | return fScanner->getSrcOffset(); |
1745 | 0 | } |
1746 | | |
1747 | | XERCES_CPP_NAMESPACE_END |
1748 | | |
1749 | | #endif |