source: NonGTP/Xerces/xerces/include/xercesc/dom/deprecated/DOMParser.hpp @ 358

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

xerces added

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