source: icXML/icXML-devel/src/icxercesc/parsers/SAX2XMLReaderImpl.hpp @ 2720

Last change on this file since 2720 was 2720, checked in by cameron, 6 years ago

Initial check-in of icXML 0.8 source files

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