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

Revision 2674, 66.6 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: AbstractDOMParser.hpp 568078 2007-08-21 11:43:25Z amassari $
20 *
21 */
22#if !defined(ABSTRACTDOMPARSER_HPP)
23#define ABSTRACTDOMPARSER_HPP
24
25#include <xercesc/dom/DOMDocument.hpp>
26#include <xercesc/framework/XMLDocumentHandler.hpp>
27#include <xercesc/framework/XMLErrorReporter.hpp>
28#include <xercesc/framework/XMLEntityHandler.hpp>
29#include <xercesc/util/SecurityManager.hpp>
30#include <xercesc/util/ValueStackOf.hpp>
31#include <xercesc/validators/DTD/DocTypeHandler.hpp>
32#include <xercesc/dom/DOMDocumentType.hpp>
33#include <xercesc/validators/DTD/DTDElementDecl.hpp>
34#include <xercesc/framework/XMLBufferMgr.hpp>
35#include <xercesc/framework/psvi/PSVIHandler.hpp>
36
37XERCES_CPP_NAMESPACE_BEGIN
38
39class XMLPScanToken;
40class XMLScanner;
41class XMLValidator;
42class DOMDocumentImpl;
43class DOMDocumentTypeImpl;
44class DOMElement;
45class GrammarResolver;
46class XMLGrammarPool;
47class PSVIHandler;
48
49/**
50  * This class implements the Document Object Model (DOM) interface.
51  * It is used as a base for DOM parsers (i.e. XercesDOMParser, DOMBuilder).
52  */
53class PARSERS_EXPORT AbstractDOMParser :
54
55    public XMemory
56    , public XMLDocumentHandler
57    , public XMLErrorReporter
58    , public XMLEntityHandler
59    , public DocTypeHandler
60    , public PSVIHandler
61{
62public :
63    // -----------------------------------------------------------------------
64    //  Class types
65    // -----------------------------------------------------------------------
66    /** @name Public constants */
67    //@{
68
69    /** ValScheme enum used in setValidationScheme
70      *    Val_Never:  Do not report validation errors.
71      *    Val_Always: The parser will always report validation errors.
72      *    Val_Auto:   The parser will report validation errors only if a grammar is specified.
73      *
74      * @see #setValidationScheme
75      */
76    enum ValSchemes
77    {
78        Val_Never
79        , Val_Always
80        , Val_Auto
81    };
82
83    //@}
84
85
86    // -----------------------------------------------------------------------
87    //  Constructors and Detructor
88    // -----------------------------------------------------------------------
89    /** @name Destructor */
90    //@{
91
92    /**
93      * Destructor
94      */
95    virtual ~AbstractDOMParser();
96
97    //@}
98
99    // -----------------------------------------------------------------------
100    //  Utility methods
101    // -----------------------------------------------------------------------
102
103    /** @name Utility methods */
104    //@{
105    /** Reset the parser
106      *
107      * This method resets the state of the DOM driver and makes
108      * it ready for a fresh parse run.
109      */
110    void reset();
111
112    /** Adopt the DOM document
113      *
114      * This method returns the DOMDocument object representing the
115      * root of the document tree.
116      *
117      * The caller will adopt the DOMDocument and thus is responsible to
118      * call DOMDocument::release() to release the associated memory.
119      * The parser will not delete it.   The ownership is transferred
120      * from the parser to the caller.
121      *
122      * @return The adopted DOMDocument object which represents the entire
123      *         XML document.
124      */
125    DOMDocument* adoptDocument();
126
127    //@}
128
129
130    // -----------------------------------------------------------------------
131    //  Getter methods
132    // -----------------------------------------------------------------------
133
134    /** @name Getter methods */
135    //@{
136
137    /** Get the DOM document
138      *
139      * This method returns the DOMDocument object representing the
140      * root of the document tree. This object provides the primary
141      * access to the document's data.
142      *
143      * The returned DOMDocument object is owned by the parser.
144      *
145      * @return The DOMDocument object which represents the entire
146      *         XML document.
147      */
148    DOMDocument* getDocument();
149
150    /** Get a const reference to the validator
151      *
152      * This method returns a reference to the parser's installed
153      * validator.
154      *
155      * @return A const reference to the installed validator object.
156      */
157    const XMLValidator& getValidator() const;
158
159    /**
160      * This method returns an enumerated value that indicates the current
161      * validation scheme set on this parser.
162      *
163      * @return The ValSchemes value current set on this parser.
164      * @see #setValidationScheme
165      */
166    ValSchemes getValidationScheme() const;
167
168    /** Get the 'do schema' flag
169      *
170      * This method returns the state of the parser's schema processing
171      * flag.
172      *
173      * @return true, if the parser is currently configured to
174      *         understand schema, false otherwise.
175      *
176      * @see #setDoSchema
177      */
178    bool getDoSchema() const;
179
180    /** Get the 'full schema constraint checking' flag
181      *
182      * This method returns the state of the parser's full schema constraint
183      * checking flag.
184      *
185      * @return true, if the parser is currently configured to
186      *         have full schema constraint checking, false otherwise.
187      *
188      * @see #setValidationSchemaFullChecking
189      */
190    bool getValidationSchemaFullChecking() const;
191
192    /** Get the identity constraint checking' flag
193      *
194      * This method returns the state of the parser's identity constraint
195      * checking flag.
196      *
197      * @return true, if the parser is currently configured to
198      *         have identity constraint checking, false otherwise.
199      *
200      * @see setIdentityConstraintChecking
201      */
202    bool getIdentityConstraintChecking() const;
203
204    /** Get error count from the last parse operation.
205      *
206      * This method returns the error count from the last parse
207      * operation. Note that this count is actually stored in the
208      * scanner, so this method simply returns what the
209      * scanner reports.
210      *
211      * @return number of errors encountered during the latest
212      *                 parse operation.
213      *
214      */
215    int getErrorCount() const;
216
217    /** Get the 'do namespaces' flag
218      *
219      * This method returns the state of the parser's namespace processing
220      * flag.
221      *
222      * @return true, if the parser is currently configured to
223      *         understand namespaces, false otherwise.
224      *
225      * @see #setDoNamespaces
226      */
227    bool getDoNamespaces() const;
228
229    /** Get the 'exit on first error' flag
230      *
231      * This method returns the state of the parser's
232      * exit-on-First-Fatal-Error flag. If this flag is true, then the
233      * parse will exit the first time it sees any non-wellformed XML or
234      * any validity error. The default state is true.
235      *
236      * @return true, if the parser is currently configured to
237      *         exit on the first fatal error, false otherwise.
238      *
239      * @see #setExitOnFirstFatalError
240      */
241    bool getExitOnFirstFatalError() const;
242
243    /**
244      * This method returns the state of the parser's
245      * validation-constraint-fatal flag.
246      *
247      * @return true, if the parser is currently configured to
248      *         set validation constraint errors as fatal, false
249      *         otherwise.
250      *
251      * @see #setValidationContraintFatal
252      */
253    bool getValidationConstraintFatal() const;
254
255    /** Get the 'include entity references' flag
256      *
257      * This method returns the flag that specifies whether the parser is
258      * creating entity reference nodes in the DOM tree being produced.
259      *
260      * @return  The state of the create entity reference node
261      *               flag.
262      * @see #setCreateEntityReferenceNodes
263      */
264    bool  getCreateEntityReferenceNodes()const;
265
266   /** Get the 'include ignorable whitespace' flag.
267      *
268      * This method returns the state of the parser's include ignorable
269      * whitespace flag.
270      *
271      * @return 'true' if the include ignorable whitespace flag is set on
272      *         the parser, 'false' otherwise.
273      *
274      * @see #setIncludeIgnorableWhitespace
275      */
276    bool getIncludeIgnorableWhitespace() const;
277
278   /** Get the set of Namespace/SchemaLocation that is specified externaly.
279      *
280      * This method returns the list of Namespace/SchemaLocation that was
281      * specified using setExternalSchemaLocation.
282      *
283      * The parser owns the returned string, and the memory allocated for
284      * the returned string will be destroyed when the parser is deleted.
285      *
286      * To ensure assessiblity of the returned information after the parser
287      * is deleted, callers need to copy and store the returned information
288      * somewhere else.
289      *
290      * @return a pointer to the list of Namespace/SchemaLocation that was
291      *         specified externally.  The pointer spans the same life-time as
292      *         the parser.  A null pointer is returned if nothing
293      *         was specified externally.
294      *
295      * @see #setExternalSchemaLocation(const XMLCh* const)
296      */
297    XMLCh* getExternalSchemaLocation() const;
298
299   /** Get the noNamespace SchemaLocation that is specified externaly.
300      *
301      * This method returns the no target namespace XML Schema Location
302      * that was specified using setExternalNoNamespaceSchemaLocation.
303      *
304      * The parser owns the returned string, and the memory allocated for
305      * the returned string will be destroyed when the parser is deleted.
306      *
307      * To ensure assessiblity of the returned information after the parser
308      * is deleted, callers need to copy and store the returned information
309      * somewhere else.
310      *
311      * @return a pointer to the no target namespace Schema Location that was
312      *         specified externally.  The pointer spans the same life-time as
313      *         the parser.  A null pointer is returned if nothing
314      *         was specified externally.
315      *
316      * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const)
317      */
318    XMLCh* getExternalNoNamespaceSchemaLocation() const;
319
320   /** Get the SecurityManager instance attached to this parser.
321      *
322      * This method returns the security manager
323      * that was specified using setSecurityManager.
324      *
325      * The SecurityManager instance must have been specified by the application;
326      * this should not be deleted until after the parser has been deleted (or
327      * a new SecurityManager instance has been supplied to the parser).
328      *
329      * @return a pointer to the SecurityManager instance
330      *         specified externally.  A null pointer is returned if nothing
331      *         was specified externally.
332      *
333      * @see #setSecurityManager(const SecurityManager* const)
334      */
335    SecurityManager* getSecurityManager() const;
336
337    /** Get the 'Loading External DTD' flag
338      *
339      * This method returns the state of the parser's loading external DTD
340      * flag.
341      *
342      * @return false, if the parser is currently configured to
343      *         ignore external DTD completely, true otherwise.
344      *
345      * @see #setLoadExternalDTD
346      * @see #getValidationScheme
347      */
348    bool getLoadExternalDTD() const;
349
350    /** Get the 'create comment node' flag
351      *
352      * This method returns the flag that specifies whether the parser is
353      * creating comment nodes in the DOM tree being produced.
354      *
355      * @return  The state of the create comment node flag.
356      * @see #setCreateCommentNodes
357      */
358    bool  getCreateCommentNodes()const;
359
360    /**
361      * Get the 'calculate src offset flag'
362      *
363      * This method returns the state of the parser's src offset calculation
364      * when parsing an XML document.
365      *
366      * @return true, if the parser is currently configured to
367      *         calculate src offsets, false otherwise.
368      *
369      * @see #setCalculateSrcOfs
370      */
371    bool getCalculateSrcOfs() const;
372
373    /**
374      * Get the 'force standard uri flag'
375      *
376      * This method returns the state if the parser forces standard uri
377      *
378      * @return true, if the parser is currently configured to
379      *         force standard uri, i.e. malformed uri will be rejected.
380      *
381      * @see #setStandardUriConformant
382      */
383    bool getStandardUriConformant() const;
384
385    /**
386      * This method returns the installed PSVI handler. Suitable
387      * for 'lvalue' usages.
388      *
389      * @return The pointer to the installed PSVI handler object.
390      */
391    PSVIHandler* getPSVIHandler();
392
393    /**
394      * This method returns the installed PSVI handler. Suitable
395      * for 'rvalue' usages.
396      *
397      * @return A const pointer to the installed PSVI handler object.
398      */
399    const PSVIHandler* getPSVIHandler() const;
400
401    /** Get the 'associate schema info' flag
402      *
403      * This method returns the flag that specifies whether
404      * the parser is storing schema informations in the element
405      * and attribute nodes in the DOM tree being produced.
406      *
407      * @return  The state of the associate schema info flag.
408      * @see #setCreateSchemaInfo
409      */
410    bool  getCreateSchemaInfo() const;
411
412    /** Get the 'generate synthetic annotations' flag
413      *   
414      * @return true, if the parser is currently configured to
415      *         generate synthetic annotations, false otherwise.
416      *         A synthetic XSAnnotation is created when a schema
417      *         component has non-schema attributes but has no
418      *         child annotations so that the non-schema attributes
419      *         can be recovered under PSVI.
420      *
421      * @see #setGenerateSyntheticAnnotations
422      */
423    bool getGenerateSyntheticAnnotations() const;
424
425    /** Get the 'validate annotations' flag
426      *   
427      * @return true, if the parser is currently configured to
428      *         validate annotations, false otherwise.
429      *
430      * @see #setValidateAnnotations
431      */
432    bool getValidateAnnotations() const;
433
434    /** Get the 'ignore annotations' flag
435      *   
436      * @return true, if the parser is currently configured to
437      *         ignore annotations, false otherwise.
438      *
439      * @see #setIgnoreAnnotations
440      */
441    bool getIgnoreAnnotations() const;
442
443    /** Get the 'disable default entity resolution' flag
444      *   
445      * @return true, if the parser is currently configured to
446      *         not perform default entity resolution, false otherwise.
447      *
448      * @see #setDisableDefaultEntityResolution
449      */
450    bool getDisableDefaultEntityResolution() const;
451
452    /** Get the 'skip DTD validation' flag
453      *   
454      * @return true, if the parser is currently configured to
455      *         skip DTD validation, false otherwise.
456      *
457      * @see #setSkipDTDValidation
458      */
459    bool getSkipDTDValidation() const;
460
461    //@}
462
463
464    // -----------------------------------------------------------------------
465    //  Setter methods
466    // -----------------------------------------------------------------------
467
468    /** @name Setter methods */
469    //@{
470    /** set the 'generate synthetic annotations' flag
471      *   
472      * @param newValue The value for specifying whether Synthetic Annotations
473      *        should be generated or not.
474      *         A synthetic XSAnnotation is created when a schema
475      *         component has non-schema attributes but has no
476      *         child annotations so that the non-schema attributes
477      *         can be recovered under PSVI.
478      *
479      * @see #getGenerateSyntheticAnnotations
480      */
481    void setGenerateSyntheticAnnotations(const bool newValue);
482
483    /** set the 'validlate annotations' flag
484      *   
485      * @param newValue The value for specifying whether Annotations
486      *        should be validated or not.
487      *
488      * @see #getValidateAnnotations
489      */
490    void setValidateAnnotations(const bool newValue);
491
492    /** Set the 'do namespaces' flag
493      *
494      * This method allows users to enable or disable the parser's
495      * namespace processing. When set to true, parser starts enforcing
496      * all the constraints and rules specified by the NameSpace
497      * specification.
498      *
499      * The parser's default state is: false.
500      *
501      * @param newState The value specifying whether NameSpace rules should
502      *                 be enforced or not.
503      *
504      * @see #getDoNamespaces
505      */
506    void setDoNamespaces(const bool newState);
507
508    /** Set the 'exit on first error' flag
509      *
510      * This method allows users to set the parser's behaviour when it
511      * encounters the first fatal error. If set to true, the parser
512      * will exit at the first fatal error. If false, then it will
513      * report the error and continue processing.
514      *
515      * The default value is 'true' and the parser exits on the
516      * first fatal error.
517      *
518      * @param newState The value specifying whether the parser should
519      *                 continue or exit when it encounters the first
520      *                 fatal error.
521      *
522      * @see #getExitOnFirstFatalError
523      */
524    void setExitOnFirstFatalError(const bool newState);
525
526    /**
527      * This method allows users to set the parser's behaviour when it
528      * encounters a validtion constraint error. If set to true, and the
529      * the parser will treat validation error as fatal and will exit depends on the
530      * state of "getExitOnFirstFatalError". If false, then it will
531      * report the error and continue processing.
532      *
533      * Note: setting this true does not mean the validation error will be printed with
534      * the word "Fatal Error".   It is still printed as "Error", but the parser
535      * will exit if "setExitOnFirstFatalError" is set to true.
536      *
537      * <p>The default value is 'false'.</p>
538      *
539      * @param newState If true, the parser will exit if "setExitOnFirstFatalError"
540      *                 is set to true.
541      *
542      * @see #getValidationConstraintFatal
543      * @see #setExitOnFirstFatalError
544      */
545    void setValidationConstraintFatal(const bool newState);
546
547     /** Set the 'include entity references' flag
548      *
549      * This method allows the user to specify whether the parser should
550      * create entity reference nodes in the DOM tree being produced.
551      * When the 'create' flag is
552      * true, the parser will create EntityReference nodes in the DOM tree.
553      * The EntityReference nodes and their child nodes will be read-only.
554      * When the 'create' flag is false, no EntityReference nodes will be created.
555      * <p>The replacement text
556      * of the entity is included in either case, either as a
557      * child of the Entity Reference node or in place at the location
558      * of the reference.
559      * <p>The default value is 'true'.
560      *
561      * @param create The new state of the create entity reference nodes
562      *               flag.
563      * @see #getCreateEntityReferenceNodes
564      */
565    void setCreateEntityReferenceNodes(const bool create);
566
567   /** Set the 'include ignorable whitespace' flag
568      *
569      * This method allows the user to specify whether a validating parser
570      * should include ignorable whitespaces as text nodes.  It has no effect
571      * on non-validating parsers which always include non-markup text.
572      * <p>When set to true (also the default), ignorable whitespaces will be
573      * added to the DOM tree as text nodes.  The method
574      * DOMText::isIgnorableWhitespace() will return true for those text
575      * nodes only.
576      * <p>When set to false, all ignorable whitespace will be discarded and
577      * no text node is added to the DOM tree.  Note: applications intended
578      * to process the "xml:space" attribute should not set this flag to false.
579      * And this flag also overrides any schema datateye whitespace facets,
580      * that is, all ignorable whitespace will be discarded even though
581      * 'preserve' is set in schema datatype whitespace facets.
582      *
583      * @param include The new state of the include ignorable whitespace
584      *                flag.
585      *
586      * @see #getIncludeIgnorableWhitespace
587      */
588    void setIncludeIgnorableWhitespace(const bool include);
589
590    /**
591      * This method allows users to set the validation scheme to be used
592      * by this parser. The value is one of the ValSchemes enumerated values
593      * defined by this class:
594      *
595      * <br>  Val_Never  - turn off validation
596      * <br>  Val_Always - turn on validation
597      * <br>  Val_Auto   - turn on validation if any internal/external
598      *                  DTD subset have been seen
599      *
600      * <p>The parser's default state is: Val_Never.</p>
601      *
602      * @param newScheme The new validation scheme to use.
603      *
604      * @see #getValidationScheme
605      */
606    void setValidationScheme(const ValSchemes newScheme);
607
608    /** Set the 'do schema' flag
609      *
610      * This method allows users to enable or disable the parser's
611      * schema processing. When set to false, parser will not process
612      * any schema found.
613      *
614      * The parser's default state is: false.
615      *
616      * Note: If set to true, namespace processing must also be turned on.
617      *
618      * @param newState The value specifying whether schema support should
619      *                 be enforced or not.
620      *
621      * @see #getDoSchema
622      */
623    void setDoSchema(const bool newState);
624
625    /**
626      * This method allows the user to turn full Schema constraint checking on/off.
627      * Only takes effect if Schema validation is enabled.
628      * If turned off, partial constraint checking is done.
629      *
630      * Full schema constraint checking includes those checking that may
631      * be time-consuming or memory intensive. Currently, particle unique
632      * attribution constraint checking and particle derivation resriction checking
633      * are controlled by this option.
634      *
635      * The parser's default state is: false.
636      *
637      * @param schemaFullChecking True to turn on full schema constraint checking.
638      *
639      * @see #getValidationSchemaFullChecking
640      */
641    void setValidationSchemaFullChecking(const bool schemaFullChecking);
642
643    /**
644      * This method allows users to enable or disable the parser's identity
645      * constraint checks.
646      *
647      * <p>By default, the parser does identity constraint checks.
648      *    The default value is true.</p>
649      *
650      * @param newState The value specifying whether the parser should
651      *                 do identity constraint checks or not in the
652      *                 input XML document.
653      *
654      * @see #getIdentityConstraintChecking
655      */
656    void setIdentityConstraintChecking(const bool newState);
657
658    /**
659      * This method allows the user to specify a list of schemas to use.
660      * If the targetNamespace of a schema specified using this method matches
661      * the targetNamespace of a schema occuring in the instance document in
662      * the schemaLocation attribute, or if the targetNamespace matches the
663      * namespace attribute of the "import" element, the schema specified by the
664      * user using this method will be used (i.e., the schemaLocation attribute
665      * in the instance document or on the "import" element will be effectively ignored).
666      *
667      * If this method is called more than once, only the last one takes effect.
668      *
669      * The syntax is the same as for schemaLocation attributes in instance
670      * documents: e.g, "http://www.example.com file_name.xsd". The user can
671      * specify more than one XML Schema in the list.
672      *
673      * @param schemaLocation the list of schemas to use
674      *
675      * @see #getExternalSchemaLocation
676      */
677
678    void setExternalSchemaLocation(const XMLCh* const schemaLocation);
679
680    /**
681      * This method is same as setExternalSchemaLocation(const XMLCh* const).
682      * It takes native char string as parameter
683      *
684      * @param schemaLocation the list of schemas to use
685      *
686      * @see #setExternalSchemaLocation(const XMLCh* const)
687      */
688    void setExternalSchemaLocation(const char* const schemaLocation);
689
690    /**
691      * This method allows the user to specify the no target namespace XML
692      * Schema Location externally.  If specified, the instance document's
693      * noNamespaceSchemaLocation attribute will be effectively ignored.
694      *
695      * If this method is called more than once, only the last one takes effect.
696      *
697      * The syntax is the same as for the noNamespaceSchemaLocation attribute
698      * that may occur in an instance document: e.g."file_name.xsd".
699      *
700      * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace
701      *
702      * @see #getExternalNoNamespaceSchemaLocation
703      */
704    void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
705
706    /**
707      * This method is same as setExternalNoNamespaceSchemaLocation(const XMLCh* const).
708      * It takes native char string as parameter
709      *
710      * @param noNamespaceSchemaLocation the XML Schema Location with no target namespace
711      *
712      * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const)
713      */
714    void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
715
716    /**
717      * This allows an application to set a SecurityManager on
718      * the parser; this object stores information that various
719      * components use to limit their consumption of system
720      * resources while processing documents.
721      *
722      * If this method is called more than once, only the last one takes effect.
723      * It may not be reset during a parse.
724      *
725      *
726      * @param securityManager  the SecurityManager instance to
727      * be used by this parser
728      *
729      * @see #getSecurityManager
730      */
731    void setSecurityManager(SecurityManager* const securityManager);
732
733    /** Set the 'Loading External DTD' flag
734      *
735      * This method allows users to enable or disable the loading of external DTD.
736      * When set to false, the parser will ignore any external DTD completely
737      * if the validationScheme is set to Val_Never.
738      *
739      * The parser's default state is: true.
740      *
741      * This flag is ignored if the validationScheme is set to Val_Always or Val_Auto.
742      *
743      * @param newState The value specifying whether external DTD should
744      *                 be loaded or not.
745      *
746      * @see #getLoadExternalDTD
747      * @see #setValidationScheme
748      */
749    void setLoadExternalDTD(const bool newState);
750
751     /** Set the 'create comment nodes' flag
752      *
753      * This method allows the user to specify whether the parser should
754      * create comment nodes in the DOM tree being produced.
755      * <p>The default value is 'true'.
756      *
757      * @param create The new state of the create comment nodes
758      *               flag.
759      * @see #getCreateCommentNodes
760      */
761    void setCreateCommentNodes(const bool create);
762
763    /** Enable/disable src offset calculation
764      *
765      * This method allows users to enable/disable src offset calculation.
766      * Disabling the calculation will improve performance.
767      *
768      * The parser's default state is: false.
769      *
770      * @param newState The value specifying whether we should enable or
771      *                 disable src offset calculation
772      *
773      * @see #getCalculateSrcOfs
774      */
775    void setCalculateSrcOfs(const bool newState);
776
777    /** Force standard uri
778      *
779      * This method allows users to tell the parser to force standard uri conformance.
780      *
781      * The parser's default state is: false.
782      *
783      * @param newState The value specifying whether the parser should reject malformed URI.
784      *
785      * @see #getStandardUriConformant
786      */
787    void setStandardUriConformant(const bool newState);
788
789    /** Set the scanner to use when scanning the XML document
790      *
791      * This method allows users to set the  scanner to use
792      * when scanning a given XML document.
793      *
794      * @param scannerName The name of the desired scanner
795      */
796    void useScanner(const XMLCh* const scannerName);
797
798    /** Set the implementation to use when creating the  document
799      *
800      * This method allows users to set the implementation to use
801      * to create the document when parseing.
802      *
803      * @param implementationFeatures The names of the desired features the implementation should have.
804      */
805    void useImplementation(const XMLCh* const implementationFeatures);
806
807    /**
808      * This method installs the user specified PSVI handler on
809      * the parser.
810      *
811      * @param handler A pointer to the PSVI handler to be called
812      *                when the parser comes across 'PSVI' events
813      *                as per the schema specification.
814      */
815    virtual void setPSVIHandler(PSVIHandler* const handler);
816
817    /** Set the 'associate schema info' flag
818      *
819      * This method allows users to specify whether
820      * the parser should store schema informations in the element
821      * and attribute nodes in the DOM tree being produced.
822      *
823      * @return  The state of the associate schema info flag.
824      * @see #getCreateSchemaInfo
825      */
826    void  setCreateSchemaInfo(const bool newState);
827
828    /** Set the 'ignore annotation' flag
829      *
830      * This method gives users the option to not generate XSAnnotations
831      * when "traversing" a schema.
832      *
833      * The parser's default state is false
834      *
835      * @param newValue The state to set
836      */
837    void setIgnoreAnnotations(const bool newValue);
838
839    /** Set the 'disable default entity resolution' flag
840      *
841      * This method gives users the option to not perform default entity
842      * resolution.  If the user's resolveEntity method returns NULL the
843      * parser will try to resolve the entity on its own.  When this option
844      * is set to true, the parser will not attempt to resolve the entity
845      * when the resolveEntity method returns NULL.
846      *   
847      * The parser's default state is false
848      *
849      * @param newValue The state to set
850      *
851      * @see #entityResolver
852      */
853    void setDisableDefaultEntityResolution(const bool newValue);
854
855    /** Set the 'skip DTD validation' flag
856      *
857      * This method gives users the option to skip DTD validation only when
858      * schema validation is on (i.e. when performing validation,  we will
859      * ignore the DTD, except for entities, when schema validation is enabled).
860      *
861      * NOTE: This option is ignored if schema validation is disabled.
862      *
863      * The parser's default state is false
864      *
865      * @param newValue The state to set
866      */
867    void setSkipDTDValidation(const bool newValue);
868    //@}
869
870
871    // -----------------------------------------------------------------------
872    //  Parsing methods
873    // -----------------------------------------------------------------------
874
875    /** @name Parsing methods */
876    //@{
877
878    /** Parse via an input source object
879      *
880      * This method invokes the parsing process on the XML file specified
881      * by the InputSource parameter. This API is borrowed from the
882      * SAX Parser interface.
883      *
884      * @param source A const reference to the InputSource object which
885      *               points to the XML file to be parsed.
886      * @exception SAXException Any SAX exception, possibly
887      *            wrapping another exception.
888      * @exception XMLException An exception from the parser or client
889      *            handler code.
890      * @exception DOMException A DOM exception as per DOM spec.
891      * @see InputSource#InputSource
892      */
893    void parse(const InputSource& source);
894
895    /** Parse via a file path or URL
896      *
897      * This method invokes the parsing process on the XML file specified by
898      * the Unicode string parameter 'systemId'. This method is borrowed
899      * from the SAX Parser interface.
900      *
901      * @param systemId A const XMLCh pointer to the Unicode string which
902      *                 contains the path to the XML file to be parsed.
903      *
904      * @exception SAXException Any SAX exception, possibly
905      *            wrapping another exception.
906      * @exception XMLException An exception from the parser or client
907      *            handler code.
908      * @exception DOMException A DOM exception as per DOM spec.
909      * @see #parse(InputSource,...)
910      */
911    void parse(const XMLCh* const systemId);
912
913    /** Parse via a file path or URL (in the local code page)
914      *
915      * This method invokes the parsing process on the XML file specified by
916      * the native char* string parameter 'systemId'.
917      *
918      * @param systemId A const char pointer to a native string which
919      *                 contains the path to the XML file to be parsed.
920      *
921      * @exception SAXException Any SAX exception, possibly
922      *            wrapping another exception.
923      * @exception XMLException An exception from the parser or client
924      *            handler code.
925      * @exception DOMException A DOM exception as per DOM spec.
926      * @see #parse(InputSource,...)
927      */
928    void parse(const char* const systemId);
929
930    /** Begin a progressive parse operation
931      *
932      * This method is used to start a progressive parse on a XML file.
933      * To continue parsing, subsequent calls must be to the parseNext
934      * method.
935      *
936      * It scans through the prolog and returns a token to be used on
937      * subsequent scanNext() calls. If the return value is true, then the
938      * token is legal and ready for further use. If it returns false, then
939      * the scan of the prolog failed and the token is not going to work on
940      * subsequent scanNext() calls.
941      *
942      * @param systemId A pointer to a Unicode string represting the path
943      *                 to the XML file to be parsed.
944      * @param toFill   A token maintaing state information to maintain
945      *                 internal consistency between invocation of 'parseNext'
946      *                 calls.
947      * @return 'true', if successful in parsing the prolog. It indicates the
948      *         user can go ahead with parsing the rest of the file. It
949      *         returns 'false' to indicate that the parser could not parse
950      *         the prolog.
951      *
952      * @see #parseNext
953      * @see #parseFirst(char*,...)
954      * @see #parseFirst(InputSource&,...)
955      */
956    bool parseFirst
957    (
958        const   XMLCh* const    systemId
959        ,       XMLPScanToken&  toFill
960    );
961
962    /** Begin a progressive parse operation
963      *
964      * This method is used to start a progressive parse on a XML file.
965      * To continue parsing, subsequent calls must be to the parseNext
966      * method.
967      *
968      * It scans through the prolog and returns a token to be used on
969      * subsequent scanNext() calls. If the return value is true, then the
970      * token is legal and ready for further use. If it returns false, then
971      * the scan of the prolog failed and the token is not going to work on
972      * subsequent scanNext() calls.
973      *
974      * @param systemId A pointer to a regular native string represting
975      *                 the path to the XML file to be parsed.
976      * @param toFill   A token maintaing state information to maintain
977      *                 internal consistency between invocation of 'parseNext'
978      *                 calls.
979      *
980      * @return 'true', if successful in parsing the prolog. It indicates the
981      *         user can go ahead with parsing the rest of the file. It
982      *         returns 'false' to indicate that the parser could not parse
983      *         the prolog.
984      *
985      * @see #parseNext
986      * @see #parseFirst(XMLCh*,...)
987      * @see #parseFirst(InputSource&,...)
988      */
989    bool parseFirst
990    (
991        const   char* const     systemId
992        ,       XMLPScanToken&  toFill
993    );
994
995    /** Begin a progressive parse operation
996      *
997      * This method is used to start a progressive parse on a XML file.
998      * To continue parsing, subsequent calls must be to the parseNext
999      * method.
1000      *
1001      * It scans through the prolog and returns a token to be used on
1002      * subsequent scanNext() calls. If the return value is true, then the
1003      * token is legal and ready for further use. If it returns false, then
1004      * the scan of the prolog failed and the token is not going to work on
1005      * subsequent scanNext() calls.
1006      *
1007      * @param source   A const reference to the InputSource object which
1008      *                 points to the XML file to be parsed.
1009      * @param toFill   A token maintaing state information to maintain
1010      *                 internal consistency between invocation of 'parseNext'
1011      *                 calls.
1012      *
1013      * @return 'true', if successful in parsing the prolog. It indicates the
1014      *         user can go ahead with parsing the rest of the file. It
1015      *         returns 'false' to indicate that the parser could not parse
1016      *         the prolog.
1017      *
1018      * @see #parseNext
1019      * @see #parseFirst(XMLCh*,...)
1020      * @see #parseFirst(char*,...)
1021      */
1022    bool parseFirst
1023    (
1024        const   InputSource&    source
1025        ,       XMLPScanToken&  toFill
1026    );
1027
1028    /** Continue a progressive parse operation
1029      *
1030      * This method is used to continue with progressive parsing of
1031      * XML files started by a call to 'parseFirst' method.
1032      *
1033      * It parses the XML file and stops as soon as it comes across
1034      * a XML token (as defined in the XML specification).
1035      *
1036      * @param token A token maintaing state information to maintain
1037      *              internal consistency between invocation of 'parseNext'
1038      *              calls.
1039      *
1040      * @return 'true', if successful in parsing the next XML token.
1041      *         It indicates the user can go ahead with parsing the rest
1042      *         of the file. It returns 'false' to indicate that the parser
1043      *         could not find next token as per the XML specification
1044      *         production rule.
1045      *
1046      * @see #parseFirst(XMLCh*,...)
1047      * @see #parseFirst(char*,...)
1048      * @see #parseFirst(InputSource&,...)
1049      */
1050    bool parseNext(XMLPScanToken& token);
1051
1052    /** Reset the parser after a progressive parse
1053      *
1054      * If a progressive parse loop exits before the end of the document
1055      * is reached, the parser has no way of knowing this. So it will leave
1056      * open any files or sockets or memory buffers that were in use at
1057      * the time that the parse loop exited.
1058      *
1059      * The next parse operation will cause these open files and such to
1060      * be closed, but the next parse operation might occur at some unknown
1061      * future point. To avoid this problem, you should reset the parser if
1062      * you exit the loop early.
1063      *
1064      * If you exited because of an error, then this cleanup will be done
1065      * for you. Its only when you exit the file prematurely of your own
1066      * accord, because you've found what you wanted in the file most
1067      * likely.
1068      *
1069      * @param token A token maintaing state information to maintain
1070      *              internal consistency between invocation of 'parseNext'
1071      *              calls.
1072      *
1073      * @see #parseFirst(XMLCh*,...)
1074      * @see #parseFirst(char*,...)
1075      * @see #parseFirst(InputSource&,...)
1076      */
1077    void parseReset(XMLPScanToken& token);
1078
1079    //@}
1080
1081    // -----------------------------------------------------------------------
1082    //  Implementation of the PSVIHandler interface.
1083    // -----------------------------------------------------------------------
1084   
1085    /** @name Implementation of the PSVIHandler interface. */
1086    //@{
1087
1088    /** Receive notification of the PSVI properties of an element.
1089      * The scanner will issue this call after the XMLDocumentHandler
1090      * endElement call.  Since the scanner will issue the psviAttributes
1091      * call immediately after reading the start tag of an element, all element
1092      * content will be effectively bracketed by these two calls.
1093      * @param  localName The name of the element whose end tag was just
1094      *                     parsed.
1095      * @param  uri       The namespace to which the element is bound
1096      * @param  elementInfo    Object containing the element's PSVI properties
1097      */
1098    virtual void handleElementPSVI
1099    (
1100        const   XMLCh* const            localName
1101        , const XMLCh* const            uri
1102        ,       PSVIElement *           elementInfo
1103    );
1104
1105    virtual void handlePartialElementPSVI
1106    (
1107        const   XMLCh* const            localName
1108        , const XMLCh* const            uri
1109        ,       PSVIElement *           elementInfo
1110    );
1111    /**
1112      * Enables PSVI information about attributes to be passed back to the
1113      * application.  This callback will be made on *all*
1114      * elements; on elements with no attributes, the final parameter will
1115      * be null.
1116      * @param  localName The name of the element upon which start tag
1117      *          these attributes were encountered.
1118      * @param  uri       The namespace to which the element is bound
1119      * @param  psviAttributes   Object containing the attributes' PSVI properties
1120      *          with information to identify them.
1121      */
1122    virtual void handleAttributesPSVI
1123    (
1124        const   XMLCh* const            localName
1125        , const XMLCh* const            uri
1126        ,       PSVIAttributeList *     psviAttributes
1127    );
1128    //@}
1129
1130    // -----------------------------------------------------------------------
1131    //  Implementation of the XMLDocumentHandler interface.
1132    // -----------------------------------------------------------------------
1133
1134    /** @name Implementation of the XMLDocumentHandler interface. */
1135    //@{
1136
1137    /** Handle document character events
1138      *
1139      * This method is used to report all the characters scanned by the
1140      * parser. This DOM implementation stores this data in the appropriate
1141      * DOM node, creating one if necessary.
1142      *
1143      * @param chars   A const pointer to a Unicode string representing the
1144      *                character data.
1145      * @param length  The length of the Unicode string returned in 'chars'.
1146      * @param cdataSection  A flag indicating if the characters represent
1147      *                      content from the CDATA section.
1148      */
1149    virtual void docCharacters
1150    (
1151        const   XMLCh* const    chars
1152        , const unsigned int    length
1153        , const bool            cdataSection
1154    );
1155
1156    /** Handle a document comment event
1157      *
1158      * This method is used to report any comments scanned by the parser.
1159      * A new comment node is created which stores this data.
1160      *
1161      * @param comment A const pointer to a null terminated Unicode
1162      *                string representing the comment text.
1163      */
1164    virtual void docComment
1165    (
1166        const   XMLCh* const    comment
1167    );
1168
1169    /** Handle a document PI event
1170      *
1171      * This method is used to report any PI scanned by the parser. A new
1172      * PI node is created and appended as a child of the current node in
1173      * the tree.
1174      *
1175      * @param target A const pointer to a Unicode string representing the
1176      *               target of the PI declaration.
1177      * @param data   A const pointer to a Unicode string representing the
1178      *               data of the PI declaration. See the PI production rule
1179      *               in the XML specification for details.
1180      */
1181    virtual void docPI
1182    (
1183        const   XMLCh* const    target
1184        , const XMLCh* const    data
1185    );
1186
1187    /** Handle the end of document event
1188      *
1189      * This method is used to indicate the end of the current document.
1190      */
1191    virtual void endDocument();
1192
1193    /** Handle and end of element event
1194      *
1195      * This method is used to indicate the end tag of an element. The
1196      * DOM parser pops the current element off the top of the element
1197      * stack, and make it the new current element.
1198      *
1199      * @param elemDecl A const reference to the object containing element
1200      *                 declaration information.
1201      * @param urlId    An id referring to the namespace prefix, if
1202      *                 namespaces setting is switched on.
1203      * @param isRoot   A flag indicating whether this element was the
1204      *                 root element.
1205      * @param elemPrefix A const pointer to a Unicode string containing
1206      *                 the namespace prefix for this element. Applicable
1207      *                 only when namespace processing is enabled.
1208      */
1209    virtual void endElement
1210    (
1211        const   XMLElementDecl& elemDecl
1212        , const unsigned int    urlId
1213        , const bool            isRoot
1214        , const XMLCh* const    elemPrefix
1215    );
1216
1217    /** Handle and end of entity reference event
1218      *
1219      * This method is used to indicate that an end of an entity reference
1220      * was just scanned.
1221      *
1222      * @param entDecl A const reference to the object containing the
1223      *                entity declaration information.
1224      */
1225    virtual void endEntityReference
1226    (
1227        const   XMLEntityDecl&  entDecl
1228    );
1229
1230    /** Handle an ignorable whitespace vent
1231      *
1232      * This method is used to report all the whitespace characters, which
1233      * are determined to be 'ignorable'. This distinction between characters
1234      * is only made, if validation is enabled.
1235      *
1236      * Any whitespace before content is ignored. If the current node is
1237      * already of type DOMNode::TEXT_NODE, then these whitespaces are
1238      * appended, otherwise a new Text node is created which stores this
1239      * data. Essentially all contiguous ignorable characters are collected
1240      * in one node.
1241      *
1242      * @param chars   A const pointer to a Unicode string representing the
1243      *                ignorable whitespace character data.
1244      * @param length  The length of the Unicode string 'chars'.
1245      * @param cdataSection  A flag indicating if the characters represent
1246      *                      content from the CDATA section.
1247      */
1248    virtual void ignorableWhitespace
1249    (
1250        const   XMLCh* const    chars
1251        , const unsigned int    length
1252        , const bool            cdataSection
1253    );
1254
1255    /** Handle a document reset event
1256      *
1257      * This method allows the user installed Document Handler to 'reset'
1258      * itself, freeing all the memory resources. The scanner calls this
1259      * method before starting a new parse event.
1260      */
1261    virtual void resetDocument();
1262
1263    /** Handle a start document event
1264      *
1265      * This method is used to report the start of the parsing process.
1266      */
1267    virtual void startDocument();
1268
1269    /** Handle a start element event
1270      *
1271      * This method is used to report the start of an element. It is
1272      * called at the end of the element, by which time all attributes
1273      * specified are also parsed. A new DOM Element node is created
1274      * along with as many attribute nodes as required. This new element
1275      * is added appended as a child of the current node in the tree, and
1276      * then replaces it as the current node (if the isEmpty flag is false.)
1277      *
1278      * @param elemDecl A const reference to the object containing element
1279      *                 declaration information.
1280      * @param urlId    An id referring to the namespace prefix, if
1281      *                 namespaces setting is switched on.
1282      * @param elemPrefix A const pointer to a Unicode string containing
1283      *                 the namespace prefix for this element. Applicable
1284      *                 only when namespace processing is enabled.
1285      * @param attrList A const reference to the object containing the
1286      *                 list of attributes just scanned for this element.
1287      * @param attrCount A count of number of attributes in the list
1288      *                 specified by the parameter 'attrList'.
1289      * @param isEmpty  A flag indicating whether this is an empty element
1290      *                 or not. If empty, then no endElement() call will
1291      *                 be made.
1292      * @param isRoot   A flag indicating whether this element was the
1293      *                 root element.
1294      * @see DocumentHandler#startElement
1295      */
1296    virtual void startElement
1297    (
1298        const   XMLElementDecl&         elemDecl
1299        , const unsigned int            urlId
1300        , const XMLCh* const            elemPrefix
1301        , const RefVectorOf<XMLAttr>&   attrList
1302        , const unsigned int            attrCount
1303        , const bool                    isEmpty
1304        , const bool                    isRoot
1305    );
1306
1307    /** Handle a start entity reference event
1308      *
1309      * This method is used to indicate the start of an entity reference.
1310      * If the expand entity reference flag is true, then a new
1311      * DOM Entity reference node is created.
1312      *
1313      * @param entDecl A const reference to the object containing the
1314      *                entity declaration information.
1315      */
1316    virtual void startEntityReference
1317    (
1318        const   XMLEntityDecl&  entDecl
1319    );
1320
1321    /** Handle an XMLDecl event
1322      *
1323      * This method is used to report the XML decl scanned by the parser.
1324      * Refer to the XML specification to see the meaning of parameters.
1325      *
1326      * <b>This method is a no-op for this DOM
1327      * implementation.</b>
1328      *
1329      * @param versionStr A const pointer to a Unicode string representing
1330      *                   version string value.
1331      * @param encodingStr A const pointer to a Unicode string representing
1332      *                    the encoding string value.
1333      * @param standaloneStr A const pointer to a Unicode string
1334      *                      representing the standalone string value.
1335      * @param actualEncStr A const pointer to a Unicode string
1336      *                     representing the actual encoding string
1337      *                     value.
1338      */
1339    virtual void XMLDecl
1340    (
1341        const   XMLCh* const    versionStr
1342        , const XMLCh* const    encodingStr
1343        , const XMLCh* const    standaloneStr
1344        , const XMLCh* const    actualEncStr
1345    );
1346
1347    /** Receive notification of the name and namespace of the type that validated
1348      * the element corresponding to the most recent endElement event.
1349      * This event will be fired immediately after the
1350      * endElement() event that signifies the end of the element
1351      * to which it applies; no other events will intervene.
1352      * This method is <em>EXPERIMENTAL</em> and may change, disappear
1353      * or become pure virtual at any time.
1354      *
1355      * This corresponds to a part of the information required by DOM Core
1356      * level 3's TypeInfo interface.
1357      *
1358      * @param  typeName        local name of the type that actually validated
1359      *                         the content of the element corresponding to the
1360      *                         most recent endElement() callback
1361      * @param  typeURI         namespace of the type that actually validated
1362      *                         the content of the element corresponding to the
1363      *                         most recent endElement() callback
1364      * @deprecated
1365      */
1366    virtual void elementTypeInfo
1367    (
1368        const   XMLCh* const    typeName
1369        , const XMLCh* const    typeURI
1370    );
1371    //@}
1372
1373
1374    // -----------------------------------------------------------------------
1375    //  Implementation of the deprecated DocTypeHandler interface.
1376    // -----------------------------------------------------------------------
1377    /** @name Deprecated DocTypeHandler Interfaces */
1378    //@{
1379    virtual void attDef
1380    (
1381        const   DTDElementDecl&     elemDecl
1382        , const DTDAttDef&          attDef
1383        , const bool                ignoring
1384    );
1385
1386    virtual void doctypeComment
1387    (
1388        const   XMLCh* const    comment
1389    );
1390
1391    virtual void doctypeDecl
1392    (
1393        const   DTDElementDecl& elemDecl
1394        , const XMLCh* const    publicId
1395        , const XMLCh* const    systemId
1396        , const bool            hasIntSubset
1397        , const bool            hasExtSubset = false
1398    );
1399
1400    virtual void doctypePI
1401    (
1402        const   XMLCh* const    target
1403        , const XMLCh* const    data
1404    );
1405
1406    virtual void doctypeWhitespace
1407    (
1408        const   XMLCh* const    chars
1409        , const unsigned int    length
1410    );
1411
1412    virtual void elementDecl
1413    (
1414        const   DTDElementDecl& decl
1415        , const bool            isIgnored
1416    );
1417
1418    virtual void endAttList
1419    (
1420        const   DTDElementDecl& elemDecl
1421    );
1422
1423    virtual void endIntSubset();
1424
1425    virtual void endExtSubset();
1426
1427    virtual void entityDecl
1428    (
1429        const   DTDEntityDecl&  entityDecl
1430        , const bool            isPEDecl
1431        , const bool            isIgnored
1432    );
1433
1434    virtual void resetDocType();
1435
1436    virtual void notationDecl
1437    (
1438        const   XMLNotationDecl&    notDecl
1439        , const bool                isIgnored
1440    );
1441
1442    virtual void startAttList
1443    (
1444        const   DTDElementDecl& elemDecl
1445    );
1446
1447    virtual void startIntSubset();
1448
1449    virtual void startExtSubset();
1450
1451    virtual void TextDecl
1452    (
1453        const   XMLCh* const    versionStr
1454        , const XMLCh* const    encodingStr
1455    );
1456
1457
1458    //@}
1459
1460
1461    // -----------------------------------------------------------------------
1462    //  Deprecated Methods
1463    // -----------------------------------------------------------------------
1464    /** @name Deprecated Methods */
1465    //@{
1466    /**
1467      * This method returns the state of the parser's validation
1468      * handling flag which controls whether validation checks
1469      * are enforced or not.
1470      *
1471      * @return true, if the parser is currently configured to
1472      *         do validation, false otherwise.
1473      *
1474      * @see #setDoValidation
1475      */
1476    bool getDoValidation() const;
1477
1478    /**
1479      * This method allows users to enable or disable the parser's validation
1480      * checks.
1481      *
1482      * <p>By default, the parser does not to any validation. The default
1483      * value is false.</p>
1484      *
1485      * @param newState The value specifying whether the parser should
1486      *                 do validity checks or not against the DTD in the
1487      *                 input XML document.
1488      *
1489      * @see #getDoValidation
1490      */
1491    void setDoValidation(const bool newState);
1492
1493    /** Get the 'expand entity references' flag.
1494      * DEPRECATED Use getCreateEntityReferenceNodes() instead.
1495      *
1496      * This method returns the state of the parser's expand entity
1497      * references flag.
1498      *
1499      * @return 'true' if the expand entity reference flag is set on
1500      *         the parser, 'false' otherwise.
1501      *
1502      * @see #setExpandEntityReferences
1503      * @see #setCreateEntityReferenceNodes
1504      * @see #getCreateEntityReferenceNodes
1505      */
1506    bool getExpandEntityReferences() const;
1507
1508    /** Set the 'expand entity references' flag
1509      *
1510      * DEPRECATED.  USE setCreateEntityReferenceNodes instead.
1511      * This method allows the user to specify whether the parser should
1512      * expand all entity reference nodes. When the 'do expansion' flag is
1513      * true, the DOM tree does not have any entity reference nodes. It is
1514      * replaced by the sub-tree representing the replacement text of the
1515      * entity. When the 'do expansion' flag is false, the DOM tree
1516      * contains an extra entity reference node, whose children is the
1517      * sub tree of the replacement text.
1518      * <p>The default value is 'false'.
1519      *
1520      * @param expand The new state of the expand entity reference
1521      *               flag.
1522      * @see #setCreateEntityReferenceNodes
1523      */
1524    void setExpandEntityReferences(const bool expand);
1525
1526    //@}
1527
1528protected :
1529    // -----------------------------------------------------------------------
1530    //  Protected Constructor Methods
1531    // -----------------------------------------------------------------------
1532    /** @name Constructors */
1533    //@{
1534    /** Construct a AbstractDOMParser, with an optional validator
1535      *
1536      * Constructor with an instance of validator class to use for
1537      * validation. If you don't provide a validator, a default one will
1538      * be created for you in the scanner.
1539      *
1540      * @param valToAdopt Pointer to the validator instance to use. The
1541      *                   parser is responsible for freeing the memory.
1542      *
1543      * @param gramPool   Pointer to the grammar pool instance from
1544      *                   external application (through derivatives).
1545      *                   The parser does NOT own it.
1546      *
1547      * @param manager    Pointer to the memory manager to be used to
1548      *                   allocate objects.
1549      */
1550    AbstractDOMParser
1551    (
1552          XMLValidator* const   valToAdopt = 0
1553        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
1554        , XMLGrammarPool* const gramPool = 0
1555    );
1556
1557    //@}
1558
1559    // -----------------------------------------------------------------------
1560    //  Protected getter methods
1561    // -----------------------------------------------------------------------
1562    /** @name Protected getter methods */
1563    //@{
1564    /** Get the current DOM node
1565      *
1566      * This provides derived classes with access to the current node, i.e.
1567      * the node to which new nodes are being added.
1568      */
1569    DOMNode* getCurrentNode();
1570
1571    /** Get the XML scanner
1572      *
1573      * This provides derived classes with access to the XML scanner.
1574      */
1575    XMLScanner* getScanner() const;
1576
1577    /** Get the Grammar resolver
1578      *
1579      * This provides derived classes with access to the grammar resolver.
1580      */
1581    GrammarResolver* getGrammarResolver() const;
1582
1583    /** Get the parse in progress flag
1584      *
1585      * This provides derived classes with access to the parse in progress
1586      * flag.
1587      */
1588    bool getParseInProgress() const;
1589
1590    MemoryManager* getMemoryManager() const;
1591
1592    //@}
1593
1594
1595    // -----------------------------------------------------------------------
1596    //  Protected setter methods
1597    // -----------------------------------------------------------------------
1598
1599    /** @name Protected setter methods */
1600    //@{
1601
1602    /** Set the current DOM node
1603      *
1604      * This method sets the current node maintained inside the parser to
1605      * the one specified.
1606      *
1607      * @param toSet The DOM node which will be the current node.
1608      */
1609    void setCurrentNode(DOMNode* toSet);
1610
1611    /** Set the document node
1612      *
1613      * This method sets the DOM Document node to the one specified.
1614      *
1615      * @param toSet The new DOM Document node for this XML document.
1616      */
1617    void setDocument(DOMDocument* toSet);
1618
1619    /** Set the parse in progress flag
1620      *
1621      * This method sets the parse in progress flag to true or false.
1622      *
1623      * @param toSet The value of the flag to be set.
1624      */
1625    void setParseInProgress(const bool toSet);
1626    //@}
1627
1628    // -----------------------------------------------------------------------
1629    //  Protected Helper methods
1630    // -----------------------------------------------------------------------
1631    /** @name Protected helper methods */
1632    //@{
1633    virtual DOMElement* createElementNSNode(const XMLCh *fNamespaceURI,
1634                                              const XMLCh *qualifiedName);
1635
1636    void resetPool();
1637
1638    /**
1639     * Returns true if the user has adopted the document
1640     */
1641    bool isDocumentAdopted() const;
1642
1643    //@}
1644
1645
1646private :
1647    // -----------------------------------------------------------------------
1648    //  Initialize/Cleanup methods
1649    // -----------------------------------------------------------------------
1650    void initialize();
1651    void cleanUp();
1652    void resetInProgress();
1653
1654    // -----------------------------------------------------------------------
1655    //  Unimplemented constructors and operators
1656    // -----------------------------------------------------------------------
1657    AbstractDOMParser(const AbstractDOMParser&);
1658    AbstractDOMParser& operator=(const AbstractDOMParser&);
1659
1660protected:
1661    // -----------------------------------------------------------------------
1662    //  Protected data members
1663    //
1664    //  fCurrentNode
1665    //  fCurrentParent
1666    //      Used to track the current node during nested element events. Since
1667    //      the tree must be built from a set of disjoint callbacks, we need
1668    //      these to keep up with where we currently are.
1669    //
1670    //  fCurrentEntity
1671    //      Used to track the current entity decl.  If a text decl is seen later on,
1672    //      it is used to update the encoding and version information.
1673    //
1674    //  fDocument
1675    //      The root document object, filled with the document contents.
1676    //
1677    //  fCreateEntityReferenceNodes
1678    //      Indicates whether entity reference nodes should be created.
1679    //
1680    //  fIncludeIgnorableWhitespace
1681    //      Indicates whether ignorable whiltespace should be added to
1682    //      the DOM tree for validating parsers.
1683    //
1684    //  fScanner
1685    //      The scanner used for this parser. This is created during the
1686    //      constructor.
1687    //
1688    //  fImplementationFeatures
1689    //      The implementation features that we use to get an implementation
1690    //      for use in creating the DOMDocument used during parse. If this is
1691    //      null then the default DOMImplementation is used
1692    //
1693    //  fNodeStack
1694    //      Used to track previous parent nodes during nested element events.
1695    //
1696    //  fParseInProgress
1697    //      Used to prevent multiple entrance to the parser while its doing
1698    //      a parse.
1699    //
1700    //  fWithinElement
1701    //      A flag to indicate that the parser is within at least one level
1702    //      of element processing.
1703    //
1704    //  fDocumentType
1705    //      Used to store and update the documentType variable information
1706    //      in fDocument
1707    //
1708    //  fDocumentVector
1709    //      Store all the previous fDocument(s) (thus not the current fDocument)
1710    //      created in this parser.  It is destroyed when the parser is destructed.
1711    //
1712    //  fCreateCommentNodes
1713    //      Indicates whether comment nodes should be created.
1714    //
1715    //  fDocumentAdoptedByUser
1716    //      The DOMDocument ownership has been transferred to application
1717    //      If set to true, the parser does not own the document anymore
1718    //      and thus will not release its memory.
1719    //
1720    //  fInternalSubset
1721    //      Buffer for storing the internal subset information.
1722    //      Once complete (after DOCTYPE is finished scanning), send
1723    //      it to DocumentType Node
1724    //
1725    //   fGrammarPool
1726    //      The grammar pool passed from external application (through derivatives).
1727    //      which could be 0, not owned.
1728    //
1729    //  fCreateSchemaInfo
1730    //      Indicates whether element and attributes will have schema info associated
1731    //
1732    // -----------------------------------------------------------------------
1733    bool                          fCreateEntityReferenceNodes;
1734    bool                          fIncludeIgnorableWhitespace;
1735    bool                          fWithinElement;
1736    bool                          fParseInProgress;
1737    bool                          fCreateCommentNodes;
1738    bool                          fDocumentAdoptedByUser;
1739    bool                          fCreateSchemaInfo;
1740    XMLScanner*                   fScanner;
1741    XMLCh*                        fImplementationFeatures;
1742    DOMNode*                      fCurrentParent;
1743    DOMNode*                      fCurrentNode;
1744    DOMEntity*                    fCurrentEntity;
1745    DOMDocumentImpl*              fDocument;
1746    ValueStackOf<DOMNode*>*       fNodeStack;
1747    DOMDocumentTypeImpl*          fDocumentType;
1748    RefVectorOf<DOMDocumentImpl>* fDocumentVector;
1749    GrammarResolver*              fGrammarResolver;
1750    XMLStringPool*                fURIStringPool;
1751    XMLValidator*                 fValidator;
1752    MemoryManager*                fMemoryManager;
1753    XMLGrammarPool*               fGrammarPool;
1754    XMLBufferMgr                  fBufMgr;
1755    XMLBuffer&                    fInternalSubset;
1756    PSVIHandler*                  fPSVIHandler;
1757};
1758
1759
1760
1761// ---------------------------------------------------------------------------
1762//  AbstractDOMParser: Getter methods
1763// ---------------------------------------------------------------------------
1764inline bool AbstractDOMParser::getExpandEntityReferences() const
1765{
1766    return !fCreateEntityReferenceNodes;
1767}
1768inline bool AbstractDOMParser::getCreateEntityReferenceNodes() const
1769{
1770    return fCreateEntityReferenceNodes;
1771}
1772
1773inline bool AbstractDOMParser::getIncludeIgnorableWhitespace() const
1774{
1775    return fIncludeIgnorableWhitespace;
1776}
1777
1778inline bool AbstractDOMParser::getParseInProgress() const
1779{
1780    return fParseInProgress;
1781}
1782
1783inline XMLScanner* AbstractDOMParser::getScanner() const
1784{
1785    return fScanner;
1786}
1787
1788inline GrammarResolver* AbstractDOMParser::getGrammarResolver() const
1789{
1790    return fGrammarResolver;
1791}
1792
1793inline bool AbstractDOMParser::getCreateCommentNodes() const
1794{
1795    return fCreateCommentNodes;
1796}
1797
1798inline PSVIHandler* AbstractDOMParser::getPSVIHandler()
1799{
1800    return fPSVIHandler;
1801}
1802
1803inline const PSVIHandler* AbstractDOMParser::getPSVIHandler() const
1804{
1805    return fPSVIHandler;
1806}
1807
1808inline bool AbstractDOMParser::getCreateSchemaInfo() const
1809{
1810    return fCreateSchemaInfo;
1811}
1812// ---------------------------------------------------------------------------
1813//  AbstractDOMParser: Setter methods
1814// ---------------------------------------------------------------------------
1815inline void AbstractDOMParser::setExpandEntityReferences(const bool expand)
1816{
1817    fCreateEntityReferenceNodes = !expand;
1818}
1819
1820inline void AbstractDOMParser::setCreateEntityReferenceNodes(const bool create)
1821{
1822    fCreateEntityReferenceNodes = create;
1823}
1824
1825inline void AbstractDOMParser::setIncludeIgnorableWhitespace(const bool include)
1826{
1827    fIncludeIgnorableWhitespace = include;
1828}
1829
1830inline void AbstractDOMParser::setCreateCommentNodes(const bool create)
1831{
1832    fCreateCommentNodes = create;
1833}
1834
1835inline void AbstractDOMParser::useImplementation(const XMLCh* const implementationFeatures)
1836{
1837    fMemoryManager->deallocate(fImplementationFeatures);
1838    fImplementationFeatures = XMLString::replicate(implementationFeatures, fMemoryManager);
1839}
1840
1841// ---------------------------------------------------------------------------
1842//  AbstractDOMParser: Protected getter methods
1843// ---------------------------------------------------------------------------
1844inline DOMNode* AbstractDOMParser::getCurrentNode()
1845{
1846    return fCurrentNode;
1847}
1848
1849inline MemoryManager* AbstractDOMParser::getMemoryManager() const
1850{
1851    return fMemoryManager;
1852}
1853
1854// ---------------------------------------------------------------------------
1855//  AbstractDOMParser: Protected setter methods
1856// ---------------------------------------------------------------------------
1857inline void AbstractDOMParser::setCurrentNode(DOMNode* toSet)
1858{
1859    fCurrentNode = toSet;
1860}
1861
1862inline void AbstractDOMParser::setParseInProgress(const bool toSet)
1863{
1864    fParseInProgress = toSet;
1865}
1866
1867XERCES_CPP_NAMESPACE_END
1868
1869#endif
1870
1871
1872
Note: See TracBrowser for help on using the repository browser.