source: trunk/VUT/GtpVisibilityPreprocessor/support/xerces/include/xercesc/parsers/AbstractDOMParser.hpp @ 358

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

xerces added

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