source: NonGTP/Xerces/xerces/include/xercesc/parsers/SAX2XMLReaderImpl.hpp @ 358

Revision 358, 76.4 KB checked in by bittner, 19 years ago (diff)

xerces added

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