source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/parsers/SAXParser.hpp @ 2674

Revision 2674, 78.7 KB checked in by mattausch, 16 years ago (diff)
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: SAXParser.hpp 568078 2007-08-21 11:43:25Z amassari $
20 */
21
22#if !defined(SAXPARSER_HPP)
23#define SAXPARSER_HPP
24
25#include <xercesc/sax/Parser.hpp>
26#include <xercesc/internal/VecAttrListImpl.hpp>
27#include <xercesc/framework/XMLDocumentHandler.hpp>
28#include <xercesc/framework/XMLElementDecl.hpp>
29#include <xercesc/framework/XMLEntityHandler.hpp>
30#include <xercesc/framework/XMLErrorReporter.hpp>
31#include <xercesc/framework/XMLBuffer.hpp>
32#include <xercesc/util/SecurityManager.hpp>
33#include <xercesc/validators/DTD/DocTypeHandler.hpp>
34
35XERCES_CPP_NAMESPACE_BEGIN
36
37
38class DocumentHandler;
39class EntityResolver;
40class XMLPScanToken;
41class XMLScanner;
42class XMLValidator;
43class Grammar;
44class GrammarResolver;
45class XMLGrammarPool;
46class XMLEntityResolver;
47class XMLResourceIdentifier;
48class PSVIHandler;
49
50/**
51  * This class implements the SAX 'Parser' interface and should be
52  * used by applications wishing to parse the XML files using SAX.
53  * It allows the client program to install SAX handlers for event
54  * callbacks.
55  *
56  * <p>It can be used to instantiate a validating or non-validating
57  * parser, by setting a member flag.</p>
58  *
59  * @deprecated This interface has been replaced by the SAX2
60  *             interface, which includes Namespace support.
61  *             See SAX2XMLReader for more information.
62  */
63
64class PARSERS_EXPORT SAXParser :
65
66    public XMemory
67    , public Parser
68    , public XMLDocumentHandler
69    , public XMLErrorReporter
70    , public XMLEntityHandler
71    , public DocTypeHandler   
72{
73public :
74    // -----------------------------------------------------------------------
75    //  Class types
76    // -----------------------------------------------------------------------
77    /** ValScheme enum used in setValidationScheme
78      *    Val_Never:  Do not report validation errors.
79      *    Val_Always: The parser will always report validation errors.
80      *    Val_Auto:   The parser will report validation errors only if a grammar is specified.
81      *
82      * @see #setValidationScheme
83      */
84
85    enum ValSchemes
86    {
87        Val_Never
88        , Val_Always
89        , Val_Auto
90    };
91
92
93    // -----------------------------------------------------------------------
94    //  Constructors and Destructor
95    // -----------------------------------------------------------------------
96    /** @name Constructors and Destructor */
97    //@{
98    /** Constructor with an instance of validator class to use for
99      * validation.
100      * @param valToAdopt Pointer to the validator instance to use. The
101      *                   parser is responsible for freeing the memory.
102      * @param manager    Pointer to the memory manager to be used to
103      *                   allocate objects.
104      * @param gramPool   The collection of cached grammers.
105      */
106    SAXParser
107    (
108          XMLValidator*   const valToAdopt = 0
109        , MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
110        , XMLGrammarPool* const gramPool = 0
111    );
112
113    /**
114      * Destructor
115      */
116    ~SAXParser();
117    //@}
118
119
120    // -----------------------------------------------------------------------
121    //  Getter Methods
122    // -----------------------------------------------------------------------
123    /** @name Getter methods */
124    //@{
125    /**
126      * This method returns the installed document handler. Suitable
127      * for 'lvalue' usages.
128      *
129      * @return The pointer to the installed document handler object.
130      */
131    DocumentHandler* getDocumentHandler();
132
133    /**
134      * This method returns the installed document handler. Suitable
135      * only for 'rvalue' usages.
136      *
137      * @return A const pointer to the installed document handler object.
138      */
139    const DocumentHandler* getDocumentHandler() const;
140
141    /**
142      * This method returns the installed entity resolver. Suitable
143      * for 'lvalue' usages.
144      *
145      * @return The pointer to the installed entity resolver object.
146      */
147    EntityResolver* getEntityResolver();
148
149    /**
150      * This method returns the installed entity resolver. Suitable
151      * for 'rvalue' usages.
152      *
153      * @return A const pointer to the installed entity resolver object.
154      */
155    const EntityResolver* getEntityResolver() const;
156
157    /**
158      * This method returns the installed entity resolver. Suitable
159      * for 'lvalue' usages.
160      *
161      * @return The pointer to the installed entity resolver object.
162      */
163    XMLEntityResolver* getXMLEntityResolver();
164
165    /**
166      * This method returns the installed entity resolver. Suitable
167      * for 'rvalue' usages.
168      *
169      * @return A const pointer to the installed entity resolver object.
170      */
171    const XMLEntityResolver* getXMLEntityResolver() const;
172
173    /**
174      * This method returns the installed error handler. Suitable
175      * for 'lvalue' usages.
176      *
177      * @return The pointer to the installed error handler object.
178      */
179    ErrorHandler* getErrorHandler();
180
181    /**
182      * This method returns the installed error handler. Suitable
183      * for 'rvalue' usages.
184      *
185      * @return A const pointer to the installed error handler object.
186      */
187    const ErrorHandler* getErrorHandler() const;
188
189    /**
190      * This method returns the installed PSVI handler. Suitable
191      * for 'lvalue' usages.
192      *
193      * @return The pointer to the installed PSVI handler object.
194      */
195    PSVIHandler* getPSVIHandler();
196
197    /**
198      * This method returns the installed PSVI handler. Suitable
199      * for 'rvalue' usages.
200      *
201      * @return A const pointer to the installed PSVI handler object.
202      */
203    const PSVIHandler* getPSVIHandler() const;
204
205    /**
206      * This method returns a reference to the parser's installed
207      * validator.
208      *
209      * @return A const reference to the installed validator object.
210      */
211    const XMLValidator& getValidator() const;
212
213    /**
214      * This method returns an enumerated value that indicates the current
215      * validation scheme set on this parser.
216      *
217      * @return The ValSchemes value current set on this parser.
218      * @see #setValidationScheme
219      */
220    ValSchemes getValidationScheme() const;
221
222    /** Get the 'do schema' flag
223      *
224      * This method returns the state of the parser's schema processing
225      * flag.
226      *
227      * @return true, if the parser is currently configured to
228      *         understand schema, false otherwise.
229      *
230      * @see #setDoSchema
231      */
232    bool getDoSchema() const;
233
234    /** Get the 'full schema constraint checking' flag
235      *
236      * This method returns the state of the parser's full schema constraint
237      * checking flag.
238      *
239      * @return true, if the parser is currently configured to
240      *         have full schema constraint checking, false otherwise.
241      *
242      * @see #setValidationSchemaFullChecking
243      */
244    bool getValidationSchemaFullChecking() const;
245
246    /** Get the 'identity constraint checking' flag
247      *
248      * This method returns the state of the parser's identity constraint
249      * checking flag.
250      *
251      * @return true, if the parser is currently configured to
252      *         have identity constraint checking, false otherwise.
253      *
254      * @see #setIdentityConstraintChecking
255      */
256    bool getIdentityConstraintChecking() const;
257
258    /** Get error count from the last parse operation.
259      *
260      * This method returns the error count from the last parse
261      * operation. Note that this count is actually stored in the
262      * scanner, so this method simply returns what the
263      * scanner reports.
264      *
265      * @return number of errors encountered during the latest
266      *                 parse operation.
267      */
268    int getErrorCount() const;
269
270    /**
271      * This method returns the state of the parser's namespace
272      * handling capability.
273      *
274      * @return true, if the parser is currently configured to
275      *         understand namespaces, false otherwise.
276      *
277      * @see #setDoNamespaces
278      */
279    bool getDoNamespaces() const;
280
281    /**
282      * This method returns the state of the parser's
283      * exit-on-First-Fatal-Error flag.
284      *
285      * @return true, if the parser is currently configured to
286      *         exit on the first fatal error, false otherwise.
287      *
288      * @see #setExitOnFirstFatalError
289      */
290    bool getExitOnFirstFatalError() const;
291
292    /**
293      * This method returns the state of the parser's
294      * validation-constraint-fatal flag.
295      *
296      * @return true, if the parser is currently configured to
297      *         set validation constraint errors as fatal, false
298      *         otherwise.
299      *
300      * @see #setValidationContraintFatal
301      */
302    bool getValidationConstraintFatal() const;
303
304   /** Get the set of Namespace/SchemaLocation that is specified externaly.
305      *
306      * This method returns the list of Namespace/SchemaLocation that was
307      * specified using setExternalSchemaLocation.
308      *
309      * The parser owns the returned string, and the memory allocated for
310      * the returned string will be destroyed when the parser is deleted.
311      *
312      * To ensure assessiblity of the returned information after the parser
313      * is deleted, callers need to copy and store the returned information
314      * somewhere else.
315      *
316      * @return a pointer to the list of Namespace/SchemaLocation that was
317      *         specified externally.  The pointer spans the same life-time as
318      *         the parser.  A null pointer is returned if nothing
319      *         was specified externally.
320      *
321      * @see #setExternalSchemaLocation(const XMLCh* const)
322      */
323    XMLCh* getExternalSchemaLocation() const;
324
325   /** Get the noNamespace SchemaLocation that is specified externaly.
326      *
327      * This method returns the no target namespace XML Schema Location
328      * that was specified using setExternalNoNamespaceSchemaLocation.
329      *
330      * The parser owns the returned string, and the memory allocated for
331      * the returned string will be destroyed when the parser is deleted.
332      *
333      * To ensure assessiblity of the returned information after the parser
334      * is deleted, callers need to copy and store the returned information
335      * somewhere else.
336      *
337      * @return a pointer to the no target namespace Schema Location that was
338      *         specified externally.  The pointer spans the same life-time as
339      *         the parser.  A null pointer is returned if nothing
340      *         was specified externally.
341      *
342      * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const)
343      */
344    XMLCh* getExternalNoNamespaceSchemaLocation() const;
345
346   /** Get the SecurityManager instance attached to this parser.
347      *
348      * This method returns the security manager
349      * that was specified using setSecurityManager.
350      *
351      * The SecurityManager instance must have been specified by the application;
352      * this should not be deleted until after the parser has been deleted (or
353      * a new SecurityManager instance has been supplied to the parser).
354      *
355      * @return a pointer to the SecurityManager instance
356      *         specified externally.  A null pointer is returned if nothing
357      *         was specified externally.
358      *
359      * @see #setSecurityManager(const SecurityManager* const)
360      */
361    SecurityManager* getSecurityManager() const;
362
363    /** Get the 'Loading External DTD' flag
364      *
365      * This method returns the state of the parser's loading external DTD
366      * flag.
367      *
368      * @return false, if the parser is currently configured to
369      *         ignore external DTD completely, true otherwise.
370      *
371      * @see #setLoadExternalDTD
372      * @see #getValidationScheme
373      */
374    bool getLoadExternalDTD() const;
375
376    /** Get the 'Grammar caching' flag
377      *
378      * This method returns the state of the parser's grammar caching when
379      * parsing an XML document.
380      *
381      * @return true, if the parser is currently configured to
382      *         cache grammars, false otherwise.
383      *
384      * @see #cacheGrammarFromParse
385      */
386    bool isCachingGrammarFromParse() const;
387
388    /** Get the 'Use cached grammar' flag
389      *
390      * This method returns the state of the parser's use of cached grammar
391      * when parsing an XML document.
392      *
393      * @return true, if the parser is currently configured to
394      *         use cached grammars, false otherwise.
395      *
396      * @see #useCachedGrammarInParse
397      */
398    bool isUsingCachedGrammarInParse() const;
399
400    /**
401      * Get the 'calculate src offset flag'
402      *
403      * This method returns the state of the parser's src offset calculation
404      * when parsing an XML document.
405      *
406      * @return true, if the parser is currently configured to
407      *         calculate src offsets, false otherwise.
408      *
409      * @see #setCalculateSrcOfs
410      */
411    bool getCalculateSrcOfs() const;
412
413    /**
414      * Get the 'force standard uri flag'
415      *
416      * This method returns the state if the parser forces standard uri
417      *
418      * @return true, if the parser is currently configured to
419      *         force standard uri, i.e. malformed uri will be rejected.
420      *
421      * @see #setStandardUriConformant
422      */
423    bool getStandardUriConformant() const;
424
425    /**
426     * Retrieve the grammar that is associated with the specified namespace key
427     *
428     * @param  nameSpaceKey Namespace key
429     * @return Grammar associated with the Namespace key.
430     */
431    Grammar* getGrammar(const XMLCh* const nameSpaceKey);
432
433    /**
434     * Retrieve the grammar where the root element is declared.
435     *
436     * @return Grammar where root element declared
437     */
438    Grammar* getRootGrammar();
439
440    /**
441     * Returns the string corresponding to a URI id from the URI string pool.
442     *
443     * @param uriId id of the string in the URI string pool.
444     * @return URI string corresponding to the URI id.
445     */
446    const XMLCh* getURIText(unsigned int uriId) const;
447
448    /**
449     * Returns the current src offset within the input source.
450     * To be used only while parsing is in progress.
451     *
452     * @return offset within the input source
453     */
454    unsigned int getSrcOffset() const;
455
456    /** Get the 'generate synthetic annotations' flag
457      *   
458      * @return true, if the parser is currently configured to
459      *         generate synthetic annotations, false otherwise.
460      *         A synthetic XSAnnotation is created when a schema
461      *         component has non-schema attributes but has no
462      *         child annotations so that the non-schema attributes
463      *         can be recovered under PSVI.
464      *
465      * @see #setGenerateSyntheticAnnotations
466      */
467    bool getGenerateSyntheticAnnotations() const;
468
469    /** Get the 'validate annotations' flag
470      *   
471      * @return true, if the parser is currently configured to
472      *         validate annotations, false otherwise.
473      *
474      * @see #setValidateAnnotations
475      */
476    bool getValidateAnnotations() const;
477
478    /** Get the 'ignore cached DTD grammar' flag
479      *   
480      * @return true, if the parser is currently configured to
481      *         ignore cached DTD, false otherwise.
482      *
483      * @see #setIgnoreCachedDTD
484      */
485    bool getIgnoreCachedDTD() const;
486
487    /** Get the 'ignore annotations' flag
488      *   
489      * @return true, if the parser is currently configured to
490      *         ignore annotations, false otherwise.
491      *
492      * @see #setIgnoreAnnotations
493      */
494    bool getIgnoreAnnotations() const;
495
496    /** Get the 'disable default entity resolution' flag
497      *   
498      * @return true, if the parser is currently configured to
499      *         not perform default entity resolution, false otherwise.
500      *
501      * @see #setDisableDefaultEntityResolution
502      */
503    bool getDisableDefaultEntityResolution() const;
504
505    /** Get the 'skip DTD validation' flag
506      *   
507      * @return true, if the parser is currently configured to
508      *         skip DTD validation, false otherwise.
509      *
510      * @see #setSkipDTDValidation
511      */
512    bool getSkipDTDValidation() const;
513
514    //@}
515
516
517    // -----------------------------------------------------------------------
518    //  Setter methods
519    // -----------------------------------------------------------------------
520
521    /** @name Setter methods */
522    //@{
523    /** set the 'generate synthetic annotations' flag
524      *   
525      * @param newValue The value for specifying whether Synthetic Annotations
526      *        should be generated or not.
527      *        A synthetic XSAnnotation is created when a schema
528      *        component has non-schema attributes but has no
529      *        child annotations.
530      *
531      * @see #getGenerateSyntheticAnnotations
532      */
533    void setGenerateSyntheticAnnotations(const bool newValue);
534
535    /** set the 'validate annotations' flag
536      *   
537      * @param newValue The value for specifying whether annotations
538      *        should be validate or not.
539      *
540      * @see #getValidateAnnotations
541      */
542    void setValidateAnnotations(const bool newValue);
543
544    /**
545      * This method allows users to enable or disable the parser's
546      * namespace processing. When set to true, parser starts enforcing
547      * all the constraints / rules specified by the NameSpace
548      * specification.
549      *
550      * <p>The parser's default state is: false.</p>
551      *
552      * @param newState The value specifying whether NameSpace rules should
553      *                 be enforced or not.
554      *
555      * @see #getDoNamespaces
556      */
557    void setDoNamespaces(const bool newState);
558
559    /**
560      * This method allows users to set the validation scheme to be used
561      * by this parser. The value is one of the ValSchemes enumerated values
562      * defined by this class:
563      *
564      * <br>  Val_Never  - turn off validation
565      * <br>  Val_Always - turn on validation
566      * <br>  Val_Auto   - turn on validation if any internal/external
567      *                  DTD subset have been seen
568      *
569      * <p>The parser's default state is: Val_Never.</p>
570      *
571      * @param newScheme The new validation scheme to use.
572      *
573      * @see #getValidationScheme
574      */
575    void setValidationScheme(const ValSchemes newScheme);
576
577    /** Set the 'schema support' flag
578      *
579      * This method allows users to enable or disable the parser's
580      * schema processing. When set to false, parser will not process
581      * any schema found.
582      *
583      * The parser's default state is: false.
584      *
585      * Note: If set to true, namespace processing must also be turned on.
586      *
587      * @param newState The value specifying whether schema support should
588      *                 be enforced or not.
589      *
590      * @see #getDoSchema
591      */
592    void setDoSchema(const bool newState);
593
594    /**
595      * This method allows the user to turn full Schema constraint checking on/off.
596      * Only takes effect if Schema validation is enabled.
597      * If turned off, partial constraint checking is done.
598      *
599      * Full schema constraint checking includes those checking that may
600      * be time-consuming or memory intensive. Currently, particle unique
601      * attribution constraint checking and particle derivation resriction checking
602      * are controlled by this option.
603      *
604      * The parser's default state is: false.
605      *
606      * @param schemaFullChecking True to turn on full schema constraint checking.
607      *
608      * @see #getValidationSchemaFullChecking
609      */
610    void setValidationSchemaFullChecking(const bool schemaFullChecking);
611
612    /**
613      * This method allows the user to turn identity constraint checking on/off.
614      * Only takes effect if Schema validation is enabled.
615      * If turned off, identity constraint checking is not done.
616      *
617      * The parser's default state is: true.
618      *
619      * @param identityConstraintChecking True to turn on identity constraint checking.
620      *
621      * @see #getIdentityConstraintChecking
622      */
623    void setIdentityConstraintChecking(const bool identityConstraintChecking);
624
625    /**
626      * This method allows users to set the parser's behaviour when it
627      * encounters the first fatal error. If set to true, the parser
628      * will exit at the first fatal error. If false, then it will
629      * report the error and continue processing.
630      *
631      * <p>The default value is 'true' and the parser exits on the
632      * first fatal error.</p>
633      *
634      * @param newState The value specifying whether the parser should
635      *                 continue or exit when it encounters the first
636      *                 fatal error.
637      *
638      * @see #getExitOnFirstFatalError
639      */
640    void setExitOnFirstFatalError(const bool newState);
641
642    /**
643      * This method allows users to set the parser's behaviour when it
644      * encounters a validtion constraint error. If set to true, and the
645      * the parser will treat validation error as fatal and will exit depends on the
646      * state of "getExitOnFirstFatalError". If false, then it will
647      * report the error and continue processing.
648      *
649      * Note: setting this true does not mean the validation error will be printed with
650      * the word "Fatal Error".   It is still printed as "Error", but the parser
651      * will exit if "setExitOnFirstFatalError" is set to true.
652      *
653      * <p>The default value is 'false'.</p>
654      *
655      * @param newState If true, the parser will exit if "setExitOnFirstFatalError"
656      *                 is set to true.
657      *
658      * @see #getValidationConstraintFatal
659      * @see #setExitOnFirstFatalError
660      */
661    void setValidationConstraintFatal(const bool newState);
662
663    /**
664      * This method allows the user to specify a list of schemas to use.
665      * If the targetNamespace of a schema specified using this method matches
666      * the targetNamespace of a schema occuring in the instance document in
667      * the schemaLocation attribute, or if the targetNamespace matches the
668      * namespace attribute of the "import" element, the schema specified by the
669      * user using this method will be used (i.e., the schemaLocation attribute
670      * in the instance document or on the "import" element will be effectively ignored).
671      *
672      * If this method is called more than once, only the last one takes effect.
673      *
674      * The syntax is the same as for schemaLocation attributes in instance
675      * documents: e.g, "http://www.example.com file_name.xsd". The user can
676      * specify more than one XML Schema in the list.
677      *
678      * @param schemaLocation the list of schemas to use
679      *
680      * @see #getExternalSchemaLocation
681      */
682
683    void setExternalSchemaLocation(const XMLCh* const schemaLocation);
684
685    /**
686      * This method is same as setExternalSchemaLocation(const XMLCh* const).
687      * It takes native char string as parameter
688      *
689      * @param schemaLocation the list of schemas to use
690      *
691      * @see #setExternalSchemaLocation(const XMLCh* const)
692      */
693    void setExternalSchemaLocation(const char* const schemaLocation);
694
695    /**
696      * This method allows the user to specify the no target namespace XML
697      * Schema Location externally.  If specified, the instance document's
698      * noNamespaceSchemaLocation attribute will be effectively ignored.
699      *
700      * If this method is called more than once, only the last one takes effect.
701      *
702      * The syntax is the same as for the noNamespaceSchemaLocation attribute
703      * that may occur in an instance document: e.g."file_name.xsd".
704      *
705      * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace
706      *
707      * @see #getExternalNoNamespaceSchemaLocation
708      */
709    void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
710
711    /**
712      * This method is same as setExternalNoNamespaceSchemaLocation(const XMLCh* const).
713      * It takes native char string as parameter
714      *
715      * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace
716      *
717      * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const)
718      */
719    void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
720
721    /**
722      * This allows an application to set a SecurityManager on
723      * the parser; this object stores information that various
724      * components use to limit their consumption of system
725      * resources while processing documents.
726      *
727      * If this method is called more than once, only the last one takes effect.
728      * It may not be reset during a parse.
729      *
730      *
731      * @param securityManager  the SecurityManager instance to
732      * be used by this parser
733      *
734      * @see #getSecurityManager
735      */
736    void setSecurityManager(SecurityManager* const securityManager);
737
738    /** Set the 'Loading External DTD' flag
739      *
740      * This method allows users to enable or disable the loading of external DTD.
741      * When set to false, the parser will ignore any external DTD completely
742      * if the validationScheme is set to Val_Never.
743      *
744      * The parser's default state is: true.
745      *
746      * This flag is ignored if the validationScheme is set to Val_Always or Val_Auto.
747      *
748      * @param newState The value specifying whether external DTD should
749      *                 be loaded or not.
750      *
751      * @see #getLoadExternalDTD
752      * @see #setValidationScheme
753      */
754    void setLoadExternalDTD(const bool newState);
755
756    /** Set the 'Grammar caching' flag
757      *
758      * This method allows users to enable or disable caching of grammar when
759      * parsing XML documents. When set to true, the parser will cache the
760      * resulting grammar for use in subsequent parses.
761      *
762      * If the flag is set to true, the 'Use cached grammar' flag will also be
763      * set to true.
764      *
765      * The parser's default state is: false.
766      *
767      * @param newState The value specifying whether we should cache grammars
768      *                 or not.
769      *
770      * @see #isCachingGrammarFromParse
771      * @see #useCachedGrammarInParse
772      */
773    void cacheGrammarFromParse(const bool newState);
774
775    /** Set the 'Use cached grammar' flag
776      *
777      * This method allows users to enable or disable the use of cached
778      * grammars.  When set to true, the parser will use the cached grammar,
779      * instead of building the grammar from scratch, to validate XML
780      * documents.
781      *
782      * If the 'Grammar caching' flag is set to true, this method ignores the
783      * value passed in.
784      *
785      * The parser's default state is: false.
786      *
787      * @param newState The value specifying whether we should use the cached
788      *                 grammar or not.
789      *
790      * @see #isUsingCachedGrammarInParse
791      * @see #cacheGrammarFromParse
792      */
793    void useCachedGrammarInParse(const bool newState);
794
795    /** Enable/disable src offset calculation
796      *
797      * This method allows users to enable/disable src offset calculation.
798      * Disabling the calculation will improve performance.
799      *
800      * The parser's default state is: false.
801      *
802      * @param newState The value specifying whether we should enable or
803      *                 disable src offset calculation
804      *
805      * @see #getCalculateSrcOfs
806      */
807    void setCalculateSrcOfs(const bool newState);
808
809    /** Force standard uri
810      *
811      * This method allows users to tell the parser to force standard uri conformance.
812      *
813      * The parser's default state is: false.
814      *
815      * @param newState The value specifying whether the parser should reject malformed URI.
816      *
817      * @see #getStandardUriConformant
818      */
819    void setStandardUriConformant(const bool newState);
820
821    /** Set the scanner to use when scanning the XML document
822      *
823      * This method allows users to set the scanner to use
824      * when scanning a given XML document.
825      *
826      * @param scannerName The name of the desired scanner
827      */
828    void useScanner(const XMLCh* const scannerName);
829
830    /** Set maximum input buffer size
831      *
832      * This method allows users to limit the size of buffers used in parsing
833      * XML character data. The effect of setting this size is to limit the
834      * size of a ContentHandler::characters() call.
835      *
836      * The parser's default input buffer size is 1 megabyte.
837      *
838      * @param bufferSize The maximum input buffer size
839      */
840    void setInputBufferSize(const size_t bufferSize);
841
842    /** Set the 'ignore cached DTD grammar' flag
843      *
844      * This method gives users the option to ignore a cached DTD grammar, when
845      * an XML document contains both an internal and external DTD, and the use
846      * cached grammar from parse option is enabled. Currently, we do not allow
847      * using cached DTD grammar when an internal subset is present in the
848      * document. This option will only affect the behavior of the parser when
849      * an internal and external DTD both exist in a document (i.e. no effect
850      * if document has no internal subset).
851      *
852      * The parser's default state is false
853      *
854      * @param newValue The state to set
855      */
856    void setIgnoreCachedDTD(const bool newValue);
857
858    /** Set the 'ignore annotation' flag
859      *
860      * This method gives users the option to not generate XSAnnotations
861      * when "traversing" a schema.
862      *
863      * The parser's default state is false
864      *
865      * @param newValue The state to set
866      */
867    void setIgnoreAnnotations(const bool newValue);
868
869    /** Set the 'disable default entity resolution' flag
870      *
871      * This method gives users the option to not perform default entity
872      * resolution.  If the user's resolveEntity method returns NULL the
873      * parser will try to resolve the entity on its own.  When this option
874      * is set to true, the parser will not attempt to resolve the entity
875      * when the resolveEntity method returns NULL.
876      *   
877      * The parser's default state is false
878      *
879      * @param newValue The state to set
880      *
881      * @see #entityResolver
882      */
883    void setDisableDefaultEntityResolution(const bool newValue);
884
885    /** Set the 'skip DTD validation' flag
886      *
887      * This method gives users the option to skip DTD validation only when
888      * schema validation is on (i.e. when performing validation,  we will
889      * ignore the DTD, except for entities, when schema validation is enabled).
890      *
891      * NOTE: This option is ignored if schema validation is disabled.
892      *
893      * The parser's default state is false
894      *
895      * @param newValue The state to set
896      */
897    void setSkipDTDValidation(const bool newValue);
898    //@}
899
900
901    // -----------------------------------------------------------------------
902    //  Advanced document handler list maintenance methods
903    // -----------------------------------------------------------------------
904
905    /** @name Advanced document handler list maintenance methods */
906    //@{
907    /**
908      * This method installs the specified 'advanced' document callback
909      * handler, thereby allowing the user to customize the processing,
910      * if they choose to do so. Any number of advanced callback handlers
911      * maybe installed.
912      *
913      * <p>The methods in the advanced callback interface represent
914      * Xerces-C extensions. There is no specification for this interface.</p>
915      *
916      * @param toInstall A pointer to the users advanced callback handler.
917      *
918      * @see #removeAdvDocHandler
919      */
920    void installAdvDocHandler(XMLDocumentHandler* const toInstall);
921
922    /**
923      * This method removes the 'advanced' document handler callback from
924      * the underlying parser scanner. If no handler is installed, advanced
925      * callbacks are not invoked by the scanner.
926      * @param toRemove A pointer to the advanced callback handler which
927      *                 should be removed.
928      *
929      * @see #installAdvDocHandler
930      */
931    bool removeAdvDocHandler(XMLDocumentHandler* const toRemove);
932    //@}
933
934
935    // -----------------------------------------------------------------------
936    //  Progressive scan methods
937    // -----------------------------------------------------------------------
938
939    /** @name Progressive scan methods */
940    //@{
941
942    /** Begin a progressive parse operation
943      *
944      * This method is used to start a progressive parse on a XML file.
945      * To continue parsing, subsequent calls must be to the parseNext
946      * method.
947      *
948      * It scans through the prolog and returns a token to be used on
949      * subsequent scanNext() calls. If the return value is true, then the
950      * token is legal and ready for further use. If it returns false, then
951      * the scan of the prolog failed and the token is not going to work on
952      * subsequent scanNext() calls.
953      *
954      * @param systemId A pointer to a Unicode string represting the path
955      *                 to the XML file to be parsed.
956      * @param toFill   A token maintaing state information to maintain
957      *                 internal consistency between invocation of 'parseNext'
958      *                 calls.
959      *
960      * @return 'true', if successful in parsing the prolog. It indicates the
961      *         user can go ahead with parsing the rest of the file. It
962      *         returns 'false' to indicate that the parser could parse the
963      *         prolog (which means the token will not be valid.)
964      *
965      * @see #parseNext
966      * @see #parseFirst(char*,...)
967      * @see #parseFirst(InputSource&,...)
968      */
969    bool parseFirst
970    (
971        const   XMLCh* const    systemId
972        ,       XMLPScanToken&  toFill
973    );
974
975    /** Begin a progressive parse operation
976      *
977      * This method is used to start a progressive parse on a XML file.
978      * To continue parsing, subsequent calls must be to the parseNext
979      * method.
980      *
981      * It scans through the prolog and returns a token to be used on
982      * subsequent scanNext() calls. If the return value is true, then the
983      * token is legal and ready for further use. If it returns false, then
984      * the scan of the prolog failed and the token is not going to work on
985      * subsequent scanNext() calls.
986      *
987      * @param systemId A pointer to a regular native string represting
988      *                 the path to the XML file to be parsed.
989      * @param toFill   A token maintaing state information to maintain
990      *                 internal consIstency between invocation of 'parseNext'
991      *                 calls.
992      *
993      * @return 'true', if successful in parsing the prolog. It indicates the
994      *         user can go ahead with parsing the rest of the file. It
995      *         returns 'false' to indicate that the parser could not parse
996      *         the prolog.
997      *
998      * @see #parseNext
999      * @see #parseFirst(XMLCh*,...)
1000      * @see #parseFirst(InputSource&,...)
1001      */
1002    bool parseFirst
1003    (
1004        const   char* const     systemId
1005        ,       XMLPScanToken&  toFill
1006    );
1007
1008    /** Begin a progressive parse operation
1009      *
1010      * This method is used to start a progressive parse on a XML file.
1011      * To continue parsing, subsequent calls must be to the parseNext
1012      * method.
1013      *
1014      * It scans through the prolog and returns a token to be used on
1015      * subsequent scanNext() calls. If the return value is true, then the
1016      * token is legal and ready for further use. If it returns false, then
1017      * the scan of the prolog failed and the token is not going to work on
1018      * subsequent scanNext() calls.
1019      *
1020      * @param source   A const reference to the InputSource object which
1021      *                 points to the XML file to be parsed.
1022      * @param toFill   A token maintaing state information to maintain
1023      *                 internal consistency between invocation of 'parseNext'
1024      *                 calls.
1025      *
1026      * @return 'true', if successful in parsing the prolog. It indicates the
1027      *         user can go ahead with parsing the rest of the file. It
1028      *         returns 'false' to indicate that the parser could not parse
1029      *         the prolog.
1030      *
1031      * @see #parseNext
1032      * @see #parseFirst(XMLCh*,...)
1033      * @see #parseFirst(char*,...)
1034      */
1035    bool parseFirst
1036    (
1037        const   InputSource&    source
1038        ,       XMLPScanToken&  toFill
1039    );
1040
1041    /** Continue a progressive parse operation
1042      *
1043      * This method is used to continue with progressive parsing of
1044      * XML files started by a call to 'parseFirst' method.
1045      *
1046      * It parses the XML file and stops as soon as it comes across
1047      * a XML token (as defined in the XML specification). Relevant
1048      * callback handlers are invoked as required by the SAX
1049      * specification.
1050      *
1051      * @param token A token maintaing state information to maintain
1052      *              internal consistency between invocation of 'parseNext'
1053      *              calls.
1054      *
1055      * @return 'true', if successful in parsing the next XML token.
1056      *         It indicates the user can go ahead with parsing the rest
1057      *         of the file. It returns 'false' to indicate that the parser
1058      *         could not find next token as per the XML specification
1059      *         production rule.
1060      *
1061      * @see #parseFirst(XMLCh*,...)
1062      * @see #parseFirst(char*,...)
1063      * @see #parseFirst(InputSource&,...)
1064      */
1065    bool parseNext(XMLPScanToken& token);
1066
1067    /** Reset the parser after a progressive parse
1068      *
1069      * If a progressive parse loop exits before the end of the document
1070      * is reached, the parser has no way of knowing this. So it will leave
1071      * open any files or sockets or memory buffers that were in use at
1072      * the time that the parse loop exited.
1073      *
1074      * The next parse operation will cause these open files and such to
1075      * be closed, but the next parse operation might occur at some unknown
1076      * future point. To avoid this problem, you should reset the parser if
1077      * you exit the loop early.
1078      *
1079      * If you exited because of an error, then this cleanup will be done
1080      * for you. Its only when you exit the file prematurely of your own
1081      * accord, because you've found what you wanted in the file most
1082      * likely.
1083      *
1084      * @param token A token maintaing state information to maintain
1085      *              internal consistency between invocation of 'parseNext'
1086      *              calls.
1087      */
1088    void parseReset(XMLPScanToken& token);
1089
1090    //@}
1091
1092    // -----------------------------------------------------------------------
1093    //  Grammar preparsing interface
1094    // -----------------------------------------------------------------------
1095
1096    /** @name Implementation of Grammar preparsing interface's. */
1097    //@{
1098    /**
1099      * Preparse schema grammar (XML Schema, DTD, etc.) via an input source
1100      * object.
1101      *
1102      * This method invokes the preparsing process on a schema grammar XML
1103      * file specified by the SAX InputSource parameter. If the 'toCache' flag
1104      * is enabled, the parser will cache the grammars for re-use. If a grammar
1105      * key is found in the pool, no caching of any grammar will take place.
1106      *
1107      * <p><b>"Experimental - subject to change"</b></p>
1108      *
1109      * @param source A const reference to the SAX InputSource object which
1110      *               points to the schema grammar file to be preparsed.
1111      * @param grammarType The grammar type (Schema or DTD).
1112      * @param toCache If <code>true</code>, we cache the preparsed grammar,
1113      *                otherwise, no chaching. Default is <code>false</code>.
1114      * @return The preparsed schema grammar object (SchemaGrammar or
1115      *         DTDGrammar). That grammar object is owned by the parser.
1116      *
1117      * @exception SAXException Any SAX exception, possibly
1118      *            wrapping another exception.
1119      * @exception XMLException An exception from the parser or client
1120      *            handler code.
1121      * @exception DOMException A DOM exception as per DOM spec.
1122      *
1123      * @see InputSource#InputSource
1124      */
1125    Grammar* loadGrammar(const InputSource& source,
1126                         const short grammarType,
1127                         const bool toCache = false);
1128
1129    /**
1130      * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
1131      *
1132      * This method invokes the preparsing process on a schema grammar XML
1133      * file specified by the file path parameter. If the 'toCache' flag
1134      * is enabled, the parser will cache the grammars for re-use. If a grammar
1135      * key is found in the pool, no caching of any grammar will take place.
1136      *
1137      * <p><b>"Experimental - subject to change"</b></p>
1138      *
1139      * @param systemId A const XMLCh pointer to the Unicode string which
1140      *                 contains the path to the XML grammar file to be
1141      *                 preparsed.
1142      * @param grammarType The grammar type (Schema or DTD).
1143      * @param toCache If <code>true</code>, we cache the preparsed grammar,
1144      *                otherwise, no chaching. Default is <code>false</code>.
1145      * @return The preparsed schema grammar object (SchemaGrammar or
1146      *         DTDGrammar). That grammar object is owned by the parser.
1147      *
1148      * @exception SAXException Any SAX exception, possibly
1149      *            wrapping another exception.
1150      * @exception XMLException An exception from the parser or client
1151      *            handler code.
1152      * @exception DOMException A DOM exception as per DOM spec.
1153      */
1154    Grammar* loadGrammar(const XMLCh* const systemId,
1155                         const short grammarType,
1156                         const bool toCache = false);
1157
1158    /**
1159      * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
1160      *
1161      * This method invokes the preparsing process on a schema grammar XML
1162      * file specified by the file path parameter. If the 'toCache' flag
1163      * is enabled, the parser will cache the grammars for re-use. If a grammar
1164      * key is found in the pool, no caching of any grammar will take place.
1165      *
1166      * <p><b>"Experimental - subject to change"</b></p>
1167      *
1168      * @param systemId A const char pointer to a native string which contains
1169      *                 the path to the XML grammar file to be preparsed.
1170      * @param grammarType The grammar type (Schema or DTD).
1171      * @param toCache If <code>true</code>, we cache the preparsed grammar,
1172      *                otherwise, no chaching. Default is <code>false</code>.
1173      * @return The preparsed schema grammar object (SchemaGrammar or
1174      *         DTDGrammar). That grammar object is owned by the parser.
1175      *
1176      * @exception SAXException Any SAX exception, possibly
1177      *            wrapping another exception.
1178      * @exception XMLException An exception from the parser or client
1179      *            handler code.
1180      * @exception DOMException A DOM exception as per DOM spec.
1181      */
1182    Grammar* loadGrammar(const char* const systemId,
1183                         const short grammarType,
1184                         const bool toCache = false);
1185
1186    /**
1187      * This method allows the user to reset the pool of cached grammars.
1188      */
1189    void resetCachedGrammarPool();
1190
1191    //@}
1192
1193
1194    // -----------------------------------------------------------------------
1195    //  Implementation of the SAX Parser interface
1196    // -----------------------------------------------------------------------
1197
1198    /** @name Implementation of SAX 1.0 Parser interface's. */
1199    //@{
1200    /**
1201      * This method invokes the parsing process on the XML file specified
1202      * by the InputSource parameter.
1203      *
1204      * @param source A const reference to the InputSource object which
1205      *               points to the XML file to be parsed.
1206      *
1207      * @see Parser#parse(InputSource)
1208      */
1209    virtual void parse(const InputSource& source);
1210
1211    /**
1212      * This method invokes the parsing process on the XML file specified by
1213      * the Unicode string parameter 'systemId'.
1214      *
1215      * @param systemId A const XMLCh pointer to the Unicode string which
1216      *                 contains the path to the XML file to be parsed.
1217      *
1218      * @see Parser#parse(XMLCh*)
1219      */
1220    virtual void parse(const XMLCh* const systemId);
1221
1222    /**
1223      * This method invokes the parsing process on the XML file specified by
1224      * the native char* string parameter 'systemId'.
1225      *
1226      * @param systemId A const char pointer to a native string which
1227      *                 contains the path to the XML file to be parsed.
1228      */
1229    virtual void parse(const char* const systemId);
1230
1231    /**
1232      * This method installs the user specified SAX Document Handler
1233      * callback function on parser.
1234      *
1235      * @param handler A pointer to the document handler to be called
1236      *                when the parser comes across 'document' events
1237      *                as per the SAX specification.
1238      *
1239      * @see Parser#parse(char*)
1240      */
1241    virtual void setDocumentHandler(DocumentHandler* const handler);
1242
1243    /**
1244      * This method installs the user specified DTD handler on the parser.
1245      *
1246      * @param handler A pointer to the DTD handler to be called
1247      *                when the parser comes across 'DTD' events
1248      *                as per the SAX specification.
1249      *
1250      * @see Parser#setDTDHandler
1251      */
1252    virtual void setDTDHandler(DTDHandler* const handler);
1253
1254    /**
1255      * This method installs the user specified error handler on
1256      * the parser.
1257      *
1258      * @param handler A pointer to the error handler to be called
1259      *                when the parser comes across 'error' events
1260      *                as per the SAX specification.
1261      *
1262      * @see Parser#setErrorHandler
1263      */
1264    virtual void setErrorHandler(ErrorHandler* const handler);
1265
1266    /**
1267      * This method installs the user specified PSVI handler on
1268      * the parser.
1269      *
1270      * @param handler A pointer to the PSVI handler to be called
1271      *                when the parser comes across 'PSVI' events
1272      *                as per the schema specification.
1273      *
1274      * @see Parser#setPSVIHandler
1275      */
1276    virtual void setPSVIHandler(PSVIHandler* const handler);
1277
1278    /**
1279      * This method installs the user specified entity resolver on the
1280      * parser. It allows applications to trap and redirect calls to
1281      * external entities.
1282      *
1283      * <i>Any previously set entity resolver is merely dropped, since the parser
1284      * does not own them.  If both setEntityResolver and setXMLEntityResolver
1285      * are called, then the last one is used.</i>
1286      *
1287      * @param resolver A pointer to the entity resolver to be called
1288      *                 when the parser comes across references to
1289      *                 entities in the XML file.
1290      *
1291      * @see Parser#setEntityResolver
1292      */
1293    virtual void setEntityResolver(EntityResolver* const resolver);
1294
1295    /**
1296      * This method installs the user specified entity resolver on the
1297      * parser. It allows applications to trap and redirect calls to
1298      * external entities.
1299      *
1300      * <i>Any previously set entity resolver is merely dropped, since the parser
1301      * does not own them.  If both setEntityResolver and setXMLEntityResolver
1302      * are called, then the last one is used.</i>
1303      *
1304      * @param resolver A pointer to the entity resolver to be called
1305      *                 when the parser comes across references to
1306      *                 entities in the XML file.
1307      *
1308      * @see Parser#setXMLEntityResolver
1309      */
1310    virtual void setXMLEntityResolver(XMLEntityResolver* const resolver);
1311
1312    //@}
1313
1314
1315    // -----------------------------------------------------------------------
1316    //  Implementation of the XMLDocumentHandler interface
1317    // -----------------------------------------------------------------------
1318
1319    /** @name Implementation of the XMLDocumentHandler Interface. */
1320    //@{
1321    /**
1322      * This method is used to report all the characters scanned
1323      * by the parser. The driver will invoke the 'characters'
1324      * method of the user installed SAX Document Handler.
1325      *
1326      * <p>If any advanced callback handlers are installed, the
1327      * corresponding 'docCharacters' method will also be invoked.</p>
1328      *
1329      * @param chars   A const pointer to a Unicode string representing the
1330      *                character data.
1331      * @param length  The length of the Unicode string returned in 'chars'.
1332      * @param cdataSection  A flag indicating if the characters represent
1333      *                      content from the CDATA section.
1334      * @see DocumentHandler#characters
1335      */
1336    virtual void docCharacters
1337    (
1338        const   XMLCh* const    chars
1339        , const unsigned int    length
1340        , const bool            cdataSection
1341    );
1342
1343    /**
1344      * This method is used to report any comments scanned by the parser.
1345      * This method is a no-op unless, unless an advanced callback handler
1346      * is installed, in which case the corresponding 'docComment' method
1347      * is invoked.
1348      *
1349      * @param comment A const pointer to a null terminated Unicode
1350      *                string representing the comment text.
1351      */
1352    virtual void docComment
1353    (
1354        const   XMLCh* const    comment
1355    );
1356
1357    /**
1358      * This method is used to report any PI scanned by the parser.
1359      *
1360      * <p>Any PI's occurring before any 'content' are not reported
1361      * to any SAX handler as per the specification. However, all
1362      * PI's within content are reported via the SAX Document Handler's
1363      * 'processingInstruction' method.
1364      *
1365      * <p>If any advanced callback handlers are installed, the
1366      * corresponding 'docPI' method will be invoked.</p>
1367      *
1368      * @param target A const pointer to a Unicode string representing the
1369      *               target of the PI declaration.
1370      * @param data   A const pointer to a Unicode string representing the
1371      *               data of the PI declaration. See the PI production rule
1372      *               in the XML specification for details.
1373      *
1374      * @see DocumentHandler#processingInstruction
1375      */
1376    virtual void docPI
1377    (
1378        const   XMLCh* const    target
1379        , const XMLCh* const    data
1380    );
1381
1382    /**
1383      * This method is used to indicate the end of root element
1384      * was just scanned by the parser. Corresponding 'endDocument'
1385      * method of the user installed SAX Document Handler will also
1386      * be invoked.
1387      *
1388      * <p>In addition, if any advanced callback handlers are installed,
1389      * the corresponding 'endDocument' method is invoked.</p>
1390      *
1391      * @see DocumentHandler#endDocument
1392      */
1393    virtual void endDocument();
1394
1395    /**
1396      * This method is used to indicate the end tag of an element.
1397      * The driver will invoke the corresponding 'endElement' method of
1398      * the SAX Document Handler interface.
1399      *
1400      * <p>If any advanced callback handlers are installed, the
1401      * corresponding 'endElement' method is also invoked.</p>
1402      *
1403      * @param elemDecl A const reference to the object containing element
1404      *                 declaration information.
1405      * @param urlId    An id referring to the namespace prefix, if
1406      *                 namespaces setting is switched on.
1407      * @param isRoot   A flag indicating whether this element was the
1408      *                 root element.
1409      * @param elemPrefix A const pointer to a Unicode string containing
1410      *                   the namespace prefix for this element. Applicable
1411      *                   only when namespace processing is enabled.
1412      * @see DocumentHandler#endElement
1413      */
1414    virtual void endElement
1415    (
1416        const   XMLElementDecl& elemDecl
1417        , const unsigned int    urlId
1418        , const bool            isRoot
1419        , const XMLCh* const    elemPrefix
1420    );
1421
1422    /**
1423      * This method is used to indicate that an end of an entity reference
1424      * was just scanned.
1425      *
1426      * <p>If any advanced callback handlers are installed, the
1427      * corresponding 'endEnityReference' method is invoked.</p>
1428      *
1429      * @param entDecl A const reference to the object containing the
1430      *                entity declaration information.
1431      */
1432    virtual void endEntityReference
1433    (
1434        const   XMLEntityDecl&  entDecl
1435    );
1436
1437    /**
1438      * This method is used to report all the whitespace characters,
1439      * which are determined to be 'ignorable'. This distinction
1440      * between characters is only made, if validation is enabled.
1441      * Corresponding 'ignorableWhitespace' method of the user installed
1442      * SAX Document Handler interface is called.
1443      *
1444      * <p>Any whitespace before content is not reported to the SAX
1445      * Document Handler method, as per the SAX specification.
1446      * However, if any advanced callback handlers are installed, the
1447      * corresponding 'ignorableWhitespace' method is invoked.</p>
1448      *
1449      * @param chars   A const pointer to a Unicode string representing the
1450      *                ignorable whitespace character data.
1451      * @param length  The length of the Unicode string 'chars'.
1452      * @param cdataSection  A flag indicating if the characters represent
1453      *                      content from the CDATA section.
1454      * @see DocumentHandler#ignorableWhitespace
1455      */
1456    virtual void ignorableWhitespace
1457    (
1458        const   XMLCh* const    chars
1459        , const unsigned int    length
1460        , const bool            cdataSection
1461    );
1462
1463    /**
1464      * This method allows the user installed Document Handler and
1465      * any advanced callback handlers to 'reset' themselves.
1466      */
1467    virtual void resetDocument();
1468
1469    /**
1470      * This method is used to report the start of the parsing process.
1471      * The corresponding user installed SAX Document Handler's method
1472      * 'startDocument' is invoked.
1473      *
1474      * <p>If any advanced callback handlers are installed, then the
1475      * corresponding 'startDocument' method is also called.</p>
1476      *
1477      * @see DocumentHandler#startDocument
1478      */
1479    virtual void startDocument();
1480
1481    /**
1482      * This method is used to report the start of an element. It is
1483      * called at the end of the element, by which time all attributes
1484      * specified are also parsed. The corresponding user installed
1485      * SAX Document Handler's method 'startElement' is invoked.
1486      *
1487      * <p>If any advanced callback handlers are installed, then the
1488      * corresponding 'startElement' method is also called.</p>
1489      *
1490      * @param elemDecl A const reference to the object containing element
1491      *                 declaration information.
1492      * @param urlId    An id referring to the namespace prefix, if
1493      *                 namespaces setting is switched on.
1494      * @param elemPrefix A const pointer to a Unicode string containing
1495      *                   the namespace prefix for this element. Applicable
1496      *                   only when namespace processing is enabled.
1497      * @param attrList  A const reference to the object containing the
1498      *                  list of attributes just scanned for this element.
1499      * @param attrCount A count of number of attributes in the list
1500      *                  specified by the parameter 'attrList'.
1501      * @param isEmpty  A flag indicating whether this is an empty element
1502      *                 or not.
1503      * @param isRoot   A flag indicating whether this element was the
1504      *                 root element.
1505      * @see DocumentHandler#startElement
1506      */
1507    virtual void startElement
1508    (
1509        const   XMLElementDecl&         elemDecl
1510        , const unsigned int            urlId
1511        , const XMLCh* const            elemPrefix
1512        , const RefVectorOf<XMLAttr>&   attrList
1513        , const unsigned int            attrCount
1514        , const bool                    isEmpty
1515        , const bool                    isRoot
1516    );
1517
1518    /**
1519      * This method is used to indicate the start of an entity reference.
1520      *
1521      * <p>If any advanced callback handlers are installed, the
1522      * corresponding 'endEnityReference' method is invoked.</p>
1523      *
1524      * @param entDecl A const reference to the object containing the
1525      *                entity declaration information.
1526      */
1527    virtual void startEntityReference
1528    (
1529        const   XMLEntityDecl&  entDecl
1530    );
1531
1532    /**
1533      * This method is used to report the XML decl scanned by the parser.
1534      * Refer to the XML specification to see the meaning of parameters.
1535      *
1536      * <b>This method is a no-op for this SAX driver
1537      * implementation.</b>
1538      *
1539      * @param versionStr A const pointer to a Unicode string representing
1540      *                   version string value.
1541      * @param encodingStr A const pointer to a Unicode string representing
1542      *                    the encoding string value.
1543      * @param standaloneStr A const pointer to a Unicode string
1544      *                      representing the standalone string value.
1545      * @param actualEncodingStr A const pointer to a Unicode string
1546      *                          representing the actual encoding string
1547      *                          value.
1548      */
1549    virtual void XMLDecl
1550    (
1551        const   XMLCh* const    versionStr
1552        , const XMLCh* const    encodingStr
1553        , const XMLCh* const    standaloneStr
1554        , const XMLCh* const    actualEncodingStr
1555    );
1556    //@}
1557
1558
1559    // -----------------------------------------------------------------------
1560    //  Implementation of the XMLErrorReporter interface
1561    // -----------------------------------------------------------------------
1562
1563    /** @name Implementation of the XMLErrorReporter Interface. */
1564    //@{
1565    /**
1566      * This method is used to report back errors found while parsing the
1567      * XML file. The driver will call the corresponding user installed
1568      * SAX Error Handler methods: 'fatal', 'error', 'warning' depending
1569      * on the severity of the error. This classification is defined by
1570      * the XML specification.
1571      *
1572      * @param errCode An integer code for the error.
1573      * @param msgDomain A const pointer to an Unicode string representing
1574      *                  the message domain to use.
1575      * @param errType An enumeration classifying the severity of the error.
1576      * @param errorText A const pointer to an Unicode string representing
1577      *                  the text of the error message.
1578      * @param systemId  A const pointer to an Unicode string representing
1579      *                  the system id of the XML file where this error
1580      *                  was discovered.
1581      * @param publicId  A const pointer to an Unicode string representing
1582      *                  the public id of the XML file where this error
1583      *                  was discovered.
1584      * @param lineNum   The line number where the error occurred.
1585      * @param colNum    The column number where the error occurred.
1586      * @see ErrorHandler
1587      */
1588    virtual void error
1589    (
1590        const   unsigned int                errCode
1591        , const XMLCh* const                msgDomain
1592        , const XMLErrorReporter::ErrTypes  errType
1593        , const XMLCh* const                errorText
1594        , const XMLCh* const                systemId
1595        , const XMLCh* const                publicId
1596        , const XMLSSize_t                  lineNum
1597        , const XMLSSize_t                  colNum
1598    );
1599
1600    /**
1601      * This method allows the user installed Error Handler
1602      * callback to 'reset' itself.
1603      *
1604      * <b>This method is a no-op for this SAX driver
1605      * implementation.</b>
1606      *
1607      */
1608    virtual void resetErrors();
1609    //@}
1610
1611
1612    // -----------------------------------------------------------------------
1613    //  Implementation of the XMLEntityHandler interface
1614    // -----------------------------------------------------------------------
1615
1616    /** @name Implementation of the XMLEntityHandler Interface. */
1617    //@{
1618    /**
1619      * This method is used to indicate the end of parsing of an external
1620      * entity file.
1621      *
1622      * <b>This method is a no-op for this SAX driver
1623      * implementation.</b>
1624      *
1625      * @param inputSource A const reference to the InputSource object
1626      *                    which points to the XML file being parsed.
1627      * @see InputSource
1628      */
1629    virtual void endInputSource(const InputSource& inputSource);
1630
1631    /**
1632      * This method allows an installed XMLEntityHandler to further
1633      * process any system id's of enternal entities encountered in
1634      * the XML file being parsed, such as redirection etc.
1635      *
1636      * <b>This method always returns 'false'
1637      * for this SAX driver implementation.</b>
1638      *
1639      * @param systemId  A const pointer to an Unicode string representing
1640      *                  the system id scanned by the parser.
1641      * @param toFill    A pointer to a buffer in which the application
1642      *                  processed system id is stored.
1643      * @return 'true', if any processing is done, 'false' otherwise.
1644      */
1645    virtual bool expandSystemId
1646    (
1647        const   XMLCh* const    systemId
1648        ,       XMLBuffer&      toFill
1649    );
1650
1651    /**
1652      * This method allows the installed XMLEntityHandler to reset
1653      * itself.
1654      *
1655      * <b>This method is a no-op for this SAX driver
1656      * implementation.</b>
1657      */
1658    virtual void resetEntities();
1659
1660    /**
1661      * This method allows a user installed entity handler to further
1662      * process any pointers to external entities. The applications
1663      * can implement 'redirection' via this callback. The driver
1664      * should call the SAX EntityHandler 'resolveEntity' method.
1665      *
1666      * @deprecated This method is no longer called (the other resolveEntity one is).
1667      *
1668      * @param publicId A const pointer to a Unicode string representing the
1669      *                 public id of the entity just parsed.
1670      * @param systemId A const pointer to a Unicode string representing the
1671      *                 system id of the entity just parsed.
1672      * @param baseURI  A const pointer to a Unicode string representing the
1673      *                 base URI of the entity just parsed,
1674      *                 or <code>null</code> if there is no base URI.
1675      * @return The value returned by the SAX resolveEntity method or
1676      *         NULL otherwise to indicate no processing was done.
1677      *         The returned InputSource is owned by the parser which is
1678      *         responsible to clean up the memory.
1679      * @see EntityResolver
1680      * @see XMLEntityHandler
1681      */
1682    virtual InputSource* resolveEntity
1683    (
1684        const   XMLCh* const    publicId
1685        , const XMLCh* const    systemId
1686        , const XMLCh* const    baseURI = 0
1687    );
1688
1689    /** Resolve a public/system id
1690      *
1691      * This method allows a user installed entity handler to further
1692      * process any pointers to external entities. The applications can
1693      * implement 'redirection' via this callback. 
1694      *
1695      * @param resourceIdentifier An object containing the type of
1696      *        resource to be resolved and the associated data members
1697      *        corresponding to this type.
1698      * @return The value returned by the user installed resolveEntity
1699      *         method or NULL otherwise to indicate no processing was done.
1700      *         The returned InputSource is owned by the parser which is
1701      *         responsible to clean up the memory.
1702      * @see XMLEntityHandler
1703      * @see XMLEntityResolver
1704      */
1705    virtual InputSource* resolveEntity
1706    (
1707        XMLResourceIdentifier* resourceIdentifier
1708    );
1709
1710    /**
1711      * This method is used to indicate the start of parsing an
1712      * external entity file.
1713      *
1714      * <b>This method is a no-op for this SAX driver
1715      * implementation.</b>
1716      *
1717      * @param inputSource A const reference to the InputSource object
1718      *                    which points to the external entity
1719      *                    being parsed.
1720      */
1721    virtual void startInputSource(const InputSource& inputSource);
1722    //@}
1723
1724
1725    // -----------------------------------------------------------------------
1726    //  Implementation of the Deprecated DocTypeHandler Interface
1727    // -----------------------------------------------------------------------
1728    /** @name Implementation of the deprecated DocTypeHandler Interface */
1729    //@{
1730    /**
1731      * This method is used to report an attribute definition.
1732      *
1733      * <b>This method is a no-op for this SAX
1734      * driver implementation.</b>
1735      *
1736      * @param elemDecl A const reference to the object containing information
1737      *                 about the element whose attribute definition was just
1738      *                 parsed.
1739      * @param attDef   A const reference to the object containing information
1740      *                 attribute definition.
1741      * @param ignore   The flag indicating whether this attribute definition
1742      *                 was ignored by the parser or not.
1743      */
1744    virtual void attDef
1745    (
1746        const   DTDElementDecl& elemDecl
1747        , const DTDAttDef&      attDef
1748        , const bool            ignore
1749    );
1750
1751    /**
1752      * This method is used to report a comment occurring within the DTD.
1753      *
1754      * <b>This method is a no-op for this SAX driver
1755      * implementation.</b>
1756      *
1757      * @param comment  A const pointer to a Unicode string representing the
1758      *                 text of the comment just parsed.
1759      */
1760    virtual void doctypeComment
1761    (
1762        const   XMLCh* const    comment
1763    );
1764
1765    /**
1766      * This method is used to report the DOCTYPE declaration.
1767      *
1768      * <b>This method is a no-op for this SAX driver
1769      * implementation.</b>
1770      *
1771      * @param elemDecl A const reference to the object containing information
1772      *                 about the root element definition declaration of the
1773      *                 XML document being parsed.
1774      * @param publicId A const pointer to a Unicode string representing the
1775      *                 public id of the DTD file.
1776      * @param systemId A const pointer to a Unicode string representing the
1777      *                 system id of the DTD file.
1778      * @param hasIntSubset A flag indicating if this XML file contains any
1779      *                     internal subset.
1780      * @param hasExtSubset A flag indicating if this XML file contains any
1781      *                     external subset. Default is false.
1782      */
1783    virtual void doctypeDecl
1784    (
1785        const   DTDElementDecl& elemDecl
1786        , const XMLCh* const    publicId
1787        , const XMLCh* const    systemId
1788        , const bool            hasIntSubset
1789        , const bool            hasExtSubset = false
1790    );
1791
1792    /**
1793      * This method is used to report any PI declarations
1794      * occurring inside the DTD definition block.
1795      *
1796      * <b>This method is a no-op for this SAX driver
1797      * implementation.</b>
1798      *
1799      * @param target A const pointer to a Unicode string representing the
1800      *               target of the PI declaration.
1801      * @param data   A const pointer to a Unicode string representing the
1802      *               data of the PI declaration. See the PI production rule
1803      *               in the XML specification for details.
1804      */
1805    virtual void doctypePI
1806    (
1807        const   XMLCh* const    target
1808        , const XMLCh* const    data
1809    );
1810
1811    /**
1812      * This method is used to report any whitespaces
1813      * occurring inside the DTD definition block.
1814      *
1815      * <b>This method is a no-op for this SAX driver
1816      * implementation.</b>
1817      *
1818      * @param chars  A const pointer to a Unicode string representing the
1819      *               whitespace characters.
1820      * @param length The length of the whitespace Unicode string.
1821      */
1822    virtual void doctypeWhitespace
1823    (
1824        const   XMLCh* const    chars
1825        , const unsigned int    length
1826    );
1827
1828    /**
1829      * This method is used to report an element declarations
1830      * successfully scanned by the parser.
1831      *
1832      * <b>This method is a no-op for this SAX driver
1833      * implementation.</b>
1834      *
1835      * @param decl   A const reference to the object containing element
1836      *               declaration information.
1837      * @param isIgnored The flag indicating whether this definition was
1838      *                  ignored by the parser or not.
1839      */
1840    virtual void elementDecl
1841    (
1842        const   DTDElementDecl& decl
1843        , const bool            isIgnored
1844    );
1845
1846    /**
1847      * This method is used to report the end of an attribute
1848      * list declaration for an element.
1849      *
1850      * <b>This method is a no-op for this SAX driver
1851      * implementation.</b>
1852      *
1853      * @param elemDecl A const reference to the object containing element
1854      *                 declaration information.
1855      */
1856    virtual void endAttList
1857    (
1858        const   DTDElementDecl& elemDecl
1859    );
1860
1861    /**
1862      * This method is used to report the end of the internal subset.
1863      *
1864      * <b>This method is a no-op for this SAX driver
1865      * implementation.</b>
1866      */
1867    virtual void endIntSubset();
1868
1869    /**
1870      * This method is used to report the end of the external subset.
1871      *
1872      * <b>This method is a no-op for this SAX driver
1873      * implementation.</b>
1874      */
1875    virtual void endExtSubset();
1876
1877    /**
1878      * This method is used to report any entity declarations.
1879      * For unparsed entities, this driver will invoke the
1880      * SAX DTDHandler::unparsedEntityDecl callback.
1881      *
1882      * @param entityDecl A const reference to the object containing
1883      *                   the entity declaration information.
1884      * @param isPEDecl  The flag indicating whether this was a
1885      *                  parameter entity declaration or not.
1886      * @param isIgnored The flag indicating whether this definition
1887      *                  was ignored by the parser or not.
1888      *
1889      * @see DTDHandler#unparsedEntityDecl
1890      */
1891    virtual void entityDecl
1892    (
1893        const   DTDEntityDecl&  entityDecl
1894        , const bool            isPEDecl
1895        , const bool            isIgnored
1896    );
1897
1898    /**
1899      * This method allows the user installed DTD handler to
1900      * reset itself.
1901      */
1902    virtual void resetDocType();
1903
1904    /**
1905      * This method is used to report any notation declarations.
1906      * If there is a user installed DTDHandler, then the driver will
1907      * invoke the SAX DTDHandler::notationDecl callback.
1908      *
1909      * @param notDecl A const reference to the object containing the notation
1910      *                declaration information.
1911      * @param isIgnored The flag indicating whether this definition was ignored
1912      *                  by the parser or not.
1913      *
1914      * @see DTDHandler#notationDecl
1915      */
1916    virtual void notationDecl
1917    (
1918        const   XMLNotationDecl&    notDecl
1919        , const bool                isIgnored
1920    );
1921
1922    /**
1923      * This method is used to indicate the start of an element's attribute
1924      * list declaration.
1925      *
1926      * <b>This method is a no-op for this SAX driver
1927      * implementation.</b>
1928      *
1929      * @param elemDecl A const reference to the object containing element
1930      *                 declaration information.
1931      */
1932    virtual void startAttList
1933    (
1934        const   DTDElementDecl& elemDecl
1935    );
1936
1937    /**
1938      * This method is used indicate the start of the internal subset.
1939      *
1940      * <b>This method is a no-op for this SAX driver
1941      * implementation.</b>
1942      */
1943    virtual void startIntSubset();
1944
1945    /**
1946      * This method is used indicate the start of the external subset.
1947      *
1948      * <b>This method is a no-op for this SAX driver
1949      * implementation.</b>
1950      */
1951    virtual void startExtSubset();
1952
1953    /**
1954      * This method is used to report the TextDecl. Refer to the XML
1955      * specification for the syntax of a TextDecl.
1956      *
1957      * <b>This method is a no-op for this SAX driver
1958      * implementation.</b>
1959      *
1960      * @param versionStr A const pointer to a Unicode string representing
1961      *                   the version number of the 'version' clause.
1962      * @param encodingStr A const pointer to a Unicode string representing
1963      *                    the encoding name of the 'encoding' clause.
1964      */
1965    virtual void TextDecl
1966    (
1967        const   XMLCh* const    versionStr
1968        , const XMLCh* const    encodingStr
1969    );
1970    //@}
1971
1972
1973    // -----------------------------------------------------------------------
1974    //  Deprecated Methods
1975    // -----------------------------------------------------------------------
1976    /** @name Deprecated Methods */
1977    //@{
1978    /**
1979      * This method returns the state of the parser's validation
1980      * handling flag which controls whether validation checks
1981      * are enforced or not.
1982      *
1983      * @return true, if the parser is currently configured to
1984      *         do validation, false otherwise.
1985      *
1986      * @see #setDoValidation
1987      */
1988    bool getDoValidation() const;
1989
1990    /**
1991      * This method allows users to enable or disable the parser's validation
1992      * checks.
1993      *
1994      * <p>By default, the parser does not to any validation. The default
1995      * value is false.</p>
1996      *
1997      * @param newState The value specifying whether the parser should
1998      *                 do validity checks or not against the DTD in the
1999      *                 input XML document.
2000      *
2001      * @see #getDoValidation
2002      */
2003    void setDoValidation(const bool newState);
2004    //@}
2005
2006
2007protected :
2008    // -----------------------------------------------------------------------
2009    //  Protected Methods
2010    // -----------------------------------------------------------------------
2011    /**
2012      * This method returns a reference to the underlying scanner object.
2013      * It allows read only access to data maintained in the scanner.
2014      *
2015      * @return A const reference to the underlying scanner object.
2016      */
2017    const XMLScanner& getScanner() const;
2018
2019    /** Get the Grammar resolver
2020      *
2021      * This provides derived classes with access to the grammar resolver.
2022      */
2023    GrammarResolver* getGrammarResolver() const;
2024
2025
2026private:
2027    // -----------------------------------------------------------------------
2028    //  Unimplemented constructors and operators
2029    // -----------------------------------------------------------------------
2030    SAXParser(const SAXParser&);
2031    SAXParser& operator=(const SAXParser&);
2032
2033    // -----------------------------------------------------------------------
2034    //  Initialize/Cleanup methods
2035    // -----------------------------------------------------------------------
2036    void initialize();
2037    void cleanUp();
2038    void resetInProgress();
2039
2040    // -----------------------------------------------------------------------
2041    //  Private data members
2042    //
2043    //  fAttrList
2044    //      A temporary implementation of the basic SAX attribute list
2045    //      interface. We use this one over and over on each startElement
2046    //      event to allow SAX-like access to the element attributes.
2047    //
2048    //  fDocHandler
2049    //      The installed SAX doc handler, if any. Null if none.
2050    //
2051    //  fDTDHandler
2052    //      The installed SAX DTD handler, if any. Null if none.
2053    //
2054    //  fElemDepth
2055    //      This is used to track the element nesting depth, so that we can
2056    //      know when we are inside content. This is so we can ignore char
2057    //      data outside of content.
2058    //
2059    //  fEntityResolver
2060    //      The installed SAX entity handler, if any. Null if none.
2061    //
2062    //  fErrorHandler
2063    //      The installed SAX error handler, if any. Null if none.
2064    //
2065    //  fPSVIHandler
2066    //      The installed PSVI handler, if any. Null if none.
2067    //
2068    //  fAdvDHCount
2069    //  fAdvDHList
2070    //  fAdvDHListSize
2071    //      This is an array of pointers to XMLDocumentHandlers, which is
2072    //      how we see installed advanced document handlers. There will
2073    //      usually not be very many at all, so a simple array is used
2074    //      instead of a collection, for performance. It will grow if needed,
2075    //      but that is unlikely.
2076    //
2077    //      The count is how many handlers are currently installed. The size
2078    //      is how big the array itself is (for expansion purposes.) When
2079    //      count == size, is time to expand.
2080    //
2081    //  fParseInProgress
2082    //      This flag is set once a parse starts. It is used to prevent
2083    //      multiple entrance or reentrance of the parser.
2084    //
2085    //  fScanner
2086    //      The scanner being used by this parser. It is created internally
2087    //      during construction.
2088    //
2089    //   fGrammarPool
2090    //      The grammar pool passed from external application (through derivatives).
2091    //      which could be 0, not owned.
2092    //
2093    // -----------------------------------------------------------------------
2094    bool                 fParseInProgress;
2095    unsigned int         fElemDepth;
2096    unsigned int         fAdvDHCount;
2097    unsigned int         fAdvDHListSize;
2098    VecAttrListImpl      fAttrList;
2099    DocumentHandler*     fDocHandler;
2100    DTDHandler*          fDTDHandler;
2101    EntityResolver*      fEntityResolver;
2102    XMLEntityResolver*   fXMLEntityResolver;
2103    ErrorHandler*        fErrorHandler;
2104    PSVIHandler*         fPSVIHandler;
2105    XMLDocumentHandler** fAdvDHList;
2106    XMLScanner*          fScanner;
2107    GrammarResolver*     fGrammarResolver;
2108    XMLStringPool*       fURIStringPool;
2109    XMLValidator*        fValidator;
2110    MemoryManager*       fMemoryManager;
2111    XMLGrammarPool*      fGrammarPool;
2112    XMLBuffer            fElemQNameBuf;
2113};
2114
2115
2116// ---------------------------------------------------------------------------
2117//  SAXParser: Getter methods
2118// ---------------------------------------------------------------------------
2119inline DocumentHandler* SAXParser::getDocumentHandler()
2120{
2121    return fDocHandler;
2122}
2123
2124inline const DocumentHandler* SAXParser::getDocumentHandler() const
2125{
2126    return fDocHandler;
2127}
2128
2129inline EntityResolver* SAXParser::getEntityResolver()
2130{
2131    return fEntityResolver;
2132}
2133
2134inline XMLEntityResolver* SAXParser::getXMLEntityResolver()
2135{
2136    return fXMLEntityResolver;
2137}
2138
2139inline const XMLEntityResolver* SAXParser::getXMLEntityResolver() const
2140{
2141    return fXMLEntityResolver;
2142}
2143
2144inline const EntityResolver* SAXParser::getEntityResolver() const
2145{
2146    return fEntityResolver;
2147}
2148
2149inline ErrorHandler* SAXParser::getErrorHandler()
2150{
2151    return fErrorHandler;
2152}
2153
2154inline const ErrorHandler* SAXParser::getErrorHandler() const
2155{
2156    return fErrorHandler;
2157}
2158
2159inline PSVIHandler* SAXParser::getPSVIHandler()
2160{
2161    return fPSVIHandler;
2162}
2163
2164inline const PSVIHandler* SAXParser::getPSVIHandler() const
2165{
2166    return fPSVIHandler;
2167}
2168
2169inline const XMLScanner& SAXParser::getScanner() const
2170{
2171    return *fScanner;
2172}
2173
2174inline GrammarResolver* SAXParser::getGrammarResolver() const
2175{
2176    return fGrammarResolver;
2177}
2178
2179XERCES_CPP_NAMESPACE_END
2180
2181#endif
Note: See TracBrowser for help on using the repository browser.