source: icXML/icXML-devel/src/icxercesc/parsers/AbstractDOMParser.hpp @ 2721

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

Fix imports in icXML modified Xerces files

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