source: NonGTP/Xerces/xercesc/dom/deprecated/DOMParser.hpp @ 188

Revision 188, 73.8 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

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