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

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

Fixes for icXML 0.9

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