source: NonGTP/Xerces/xercesc/parsers/SAX2XMLReaderImpl.hpp @ 188

Revision 188, 77.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-2003 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 * $Log: SAX2XMLReaderImpl.hpp,v $
59 * Revision 1.24  2003/11/06 15:30:07  neilg
60 * first part of PSVI/schema component model implementation, thanks to David Cargill.  This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
61 *
62 * Revision 1.23  2003/10/30 21:37:31  knoaman
63 * Enhanced Entity Resolver Support. Thanks to David Cargill.
64 *
65 * Revision 1.22  2003/06/20 18:55:54  peiyongz
66 * Stateless Grammar Pool :: Part I
67 *
68 * Revision 1.21  2003/05/22 02:10:51  knoaman
69 * Default the memory manager.
70 *
71 * Revision 1.20  2003/05/15 18:26:50  knoaman
72 * Partial implementation of the configurable memory manager.
73 *
74 * Revision 1.19  2003/04/17 21:58:50  neilg
75 * Adding a new property,
76 * http://apache.org/xml/properties/security-manager, with
77 * appropriate getSecurityManager/setSecurityManager methods on DOM
78 * and SAX parsers.  Also adding a new SecurityManager class.
79 *
80 * The purpose of these modifications is to permit applications a
81 * means to have the parser reject documents whose processing would
82 * otherwise consume large amounts of system resources.  Malicious
83 * use of such documents could be used to launch a denial-of-service
84 * attack against a system running the parser.  Initially, the
85 * SecurityManager only knows about attacks that can result from
86 * exponential entity expansion; this is the only known attack that
87 * involves processing a single XML document.  Other, simlar attacks
88 * can be launched if arbitrary schemas may be parsed; there already
89 * exist means (via use of the EntityResolver interface) by which
90 * applications can deny processing of untrusted schemas.  In future,
91 * the SecurityManager will be expanded to take these other exploits
92 * into account.
93 *
94 * Adding SecurityManager support
95 *
96 * Revision 1.18  2003/03/07 18:09:16  tng
97 * Return a reference instead of void for operator=
98 *
99 * Revision 1.17  2003/01/09 19:07:08  tng
100 * [Bug 15802] Add "const" qualifier to getURIText.
101 *
102 * Revision 1.16  2002/12/23 15:23:18  knoaman
103 * Added a public api to various parsers to return the src offset within the input
104 * source.
105 *
106 * Revision 1.15  2002/12/04 01:57:09  knoaman
107 * Scanner re-organization.
108 *
109 * Revision 1.14  2002/11/04 14:57:03  tng
110 * C++ Namespace Support.
111 *
112 * Revision 1.13  2002/08/14 15:20:38  knoaman
113 * [Bug 3111] Problem with LexicalHandler::startDTD() and LexicalHandler::endDTD().
114 *
115 * Revision 1.12  2002/07/11 18:27:04  knoaman
116 * Grammar caching/preparsing - initial implementation.
117 *
118 * Revision 1.11  2002/06/27 18:47:32  tng
119 * API Documentation Update.
120 *
121 * Revision 1.10  2002/06/17 15:41:15  tng
122 * To be consistent, SAX2 is updated with:
123 * 1. the progressive parse methods should use the fReuseGrammar flag set from setFeature instead of using parameter
124 * 2. add feature "http://apache.org/xml/features/continue-after-fatal-error", and users should use setFeature instead of setExitOnFirstFatalError
125 * 3. add feature "http://apache.org/xml/features/validation-error-as-fatal", and users should use setFeature instead of setValidationConstraintFatal
126 *
127 * Revision 1.9  2002/06/06 20:38:18  tng
128 * Document Fix: document that the returned object from resolveEntity is owned by the parser
129 *
130 * Revision 1.8  2002/05/31 15:13:53  tng
131 * Fix doxygen documentation.
132 *
133 * Revision 1.7  2002/05/30 16:39:06  knoaman
134 * DOM L3 LS.
135 *
136 * Revision 1.6  2002/05/30 16:20:09  tng
137 * Add feature to optionally ignore external DTD.
138 *
139 * Revision 1.5  2002/05/29 21:37:47  knoaman
140 * Add baseURI to resolveEntity to support DOMInputSource.
141 *
142 * Revision 1.4  2002/05/28 20:44:14  tng
143 * [Bug 9104] prefixes dissapearing when schema validation turned on.
144 *
145 * Revision 1.3  2002/05/27 18:39:21  tng
146 * To get ready for 64 bit large file, use XMLSSize_t to represent line and column number.
147 *
148 * Revision 1.2  2002/02/13 16:09:24  knoaman
149 * Move SAX2 features/properties names constants to XMLUni.
150 *
151 * Revision 1.1.1.1  2002/02/01 22:22:07  peiyongz
152 * sane_include
153 *
154 * Revision 1.21  2002/01/28 18:45:40  knoaman
155 * Update documentation for SAX2 feature 'namespace-prefixes'.
156 *
157 * Revision 1.20  2002/01/28 17:08:47  knoaman
158 * SAX2-ext's DeclHandler support.
159 *
160 * Revision 1.19  2002/01/24 16:30:34  tng
161 * [Bug 3111] Problem with LexicalHandler::startDTD() and LexicalHandler::endDTD() .
162 *
163 * Revision 1.18  2002/01/18 16:31:38  tng
164 * Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml, program-dom.xml, program-idom.xml.
165 *
166 * Revision 1.17  2002/01/02 15:36:41  tng
167 * Some documentation update.
168 *
169 * Revision 1.16  2001/11/20 18:51:44  tng
170 * Schema: schemaLocation and noNamespaceSchemaLocation to be specified outside the instance document.  New methods setExternalSchemaLocation and setExternalNoNamespaceSchemaLocation are added (for SAX2, two new properties are added).
171 *
172 * Revision 1.15  2001/11/14 14:15:42  tng
173 * Update SAX2 feature documentation.
174 *
175 * Revision 1.14  2001/09/12 13:03:43  tng
176 * [Bug 3155] SAX2 does not offer progressive parse.
177 *
178 * Revision 1.13  2001/08/01 19:11:02  tng
179 * Add full schema constraint checking flag to the samples and the parser.
180 *
181 * Revision 1.12  2001/06/27 17:39:52  knoaman
182 * Fix for bug #2353.
183 *
184 * Revision 1.11  2001/06/19 16:45:08  tng
185 * Add installAdvDocHandler to SAX2XMLReader as the code is there already.
186 *
187 * Revision 1.10  2001/06/04 21:01:49  jberry
188 * getErrorCount is virtual in this class reflecting derivation from SAX2XMLReader.
189 *
190 * Revision 1.9  2001/06/03 19:26:19  jberry
191 * Add support for querying error count following parse; enables simple parse without requiring error handler.
192 *
193 * Revision 1.8  2001/05/11 13:26:21  tng
194 * Copyright update.
195 *
196 * Revision 1.7  2001/03/30 16:46:57  tng
197 * Schema: Use setDoSchema instead of setSchemaValidation which makes more sense.
198 *
199 * Revision 1.6  2001/03/21 21:56:08  tng
200 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
201 *
202 * Revision 1.5  2001/02/15 15:56:29  tng
203 * Schema: Add setSchemaValidation and getSchemaValidation for DOMParser and SAXParser.
204 * Add feature "http://apache.org/xml/features/validation/schema" for SAX2XMLReader.
205 * New data field  fSchemaValidation in XMLScanner as the flag.
206 *
207 * Revision 1.4  2000/12/22 15:16:53  tng
208 * SAX2-ext's LexicalHandler support added by David Bertoni.
209 *
210 * Revision 1.3  2000/08/09 22:16:13  jpolast
211 * many conformance & stability changes:
212 *   - ContentHandler::resetDocument() removed
213 *   - attrs param of ContentHandler::startDocument() made const
214 *   - SAXExceptions thrown now have msgs
215 *   - removed duplicate function signatures that had 'const'
216 *       [ eg: getContentHander() ]
217 *   - changed getFeature and getProperty to apply to const objs
218 *   - setProperty now takes a void* instead of const void*
219 *   - SAX2XMLReaderImpl does not inherit from SAXParser anymore
220 *   - Reuse Validator (http://apache.org/xml/features/reuse-validator) implemented
221 *   - Features & Properties now read-only during parse
222 *
223 * Revision 1.2  2000/08/02 20:46:32  aruna1
224 * sax2 changes
225 *
226 * Revision 1.1  2000/08/02 18:04:41  jpolast
227 * initial checkin of sax2 implemenation
228 * submitted by Simon Fell (simon@fell.com)
229 * and Joe Polastre (jpolast@apache.org)
230 *
231 *
232 */
233
234#if !defined(SAX2XMLReaderImpl_HPP)
235#define SAX2XMLReaderImpl_HPP
236
237#include <xercesc/parsers/SAXParser.hpp>
238#include <xercesc/sax/Parser.hpp>
239#include <xercesc/framework/XMLBuffer.hpp>
240#include <xercesc/internal/VecAttributesImpl.hpp>
241#include <xercesc/sax2/SAX2XMLReader.hpp>
242#include <xercesc/util/RefStackOf.hpp>
243#include <xercesc/util/SecurityManager.hpp>
244#include <xercesc/util/ValueStackOf.hpp>
245#include <xercesc/framework/XMLBufferMgr.hpp>
246
247XERCES_CPP_NAMESPACE_BEGIN
248
249
250class ContentHandler;
251class LexicalHandler;
252class DeclHandler;
253class GrammarResolver;
254class XMLGrammarPool;
255class XMLResourceIdentifier;
256class PSVIHandler;
257
258/**
259  * This class implements the SAX2 'XMLReader' interface and should be
260  * used by applications wishing to parse the XML files using SAX2.
261  * It allows the client program to install SAX2 handlers for event
262  * callbacks.
263  *
264  * <p>It can be used to instantiate a validating or non-validating
265  * parser, by setting a member flag.</p>
266  *
267  * we basically re-use the existing SAX1 parser code, but provide a
268  * new implementation of XMLContentHandler that raises the new
269  * SAX2 style events
270  *
271  */
272
273class PARSERS_EXPORT SAX2XMLReaderImpl :
274        public XMemory
275    , public SAX2XMLReader
276    , public XMLDocumentHandler
277    , public XMLErrorReporter
278    , public XMLEntityHandler
279    , public DocTypeHandler
280{
281public :
282    // -----------------------------------------------------------------------
283    //  Constructors and Destructor
284    // -----------------------------------------------------------------------
285    /** @name Constructors and Destructor */
286    //@{
287    /** The default constructor */
288        SAX2XMLReaderImpl(
289                            MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
290                          , XMLGrammarPool* const gramPool = 0
291                          );
292
293    /** The destructor */       
294        ~SAX2XMLReaderImpl() ;
295   //@}
296
297    //-----------------------------------------------------------------------
298    // Implementation of SAX2XMLReader Interface
299    //-----------------------------------------------------------------------
300    //-----------------------------------------------------------------------
301    // The XMLReader interface
302    //-----------------------------------------------------------------------
303    /** @name Implementation of SAX 2.0 XMLReader interface's. */
304    //@{
305
306    /**
307      * This method returns the installed content handler.
308      *
309      * @return A pointer to the installed content handler object.
310      */
311    virtual ContentHandler* getContentHandler() const ;
312
313    /**
314      * This method returns the installed DTD handler.
315      *
316      * @return A pointer to the installed DTD handler object.
317      */
318    virtual DTDHandler* getDTDHandler() const ;
319
320    /**
321      * This method returns the installed entity resolver.
322      *
323      * @return A pointer to the installed entity resolver object.
324      */
325    virtual EntityResolver* getEntityResolver() const ;
326
327    /**
328      * This method returns the installed entity resolver.
329      *
330      * @return A pointer to the installed entity resolver object.
331      */
332    virtual XMLEntityResolver* getXMLEntityResolver() const ;
333
334    /**
335      * This method returns the installed error handler.
336      *
337      * @return A pointer to the installed error handler object.
338      */
339    virtual ErrorHandler* getErrorHandler() const ;
340
341    /**
342      * This method returns the installed PSVI handler.
343      *
344      * @return A pointer to the installed PSVI handler object.
345      */
346    virtual PSVIHandler* getPSVIHandler() const ;
347
348        /**
349     * Query the current state of any feature in a SAX2 XMLReader.
350          *
351          * @param name The unique identifier (URI) of the feature being set.
352          * @return The current state of the feature.
353     * @exception SAXNotRecognizedException If the requested feature is not known.
354          */
355        virtual bool getFeature(const XMLCh* const name) const ;
356
357        /**
358     * Query the current value of a property in a SAX2 XMLReader.
359     *
360     * The parser owns the returned pointer.  The memory allocated for
361     * the returned pointer will be destroyed when the parser is deleted.
362     *
363     * To ensure assessiblity of the returned information after the parser
364     * is deleted, callers need to copy and store the returned information
365     * somewhere else; otherwise you may get unexpected result.  Since the returned
366     * pointer is a generic void pointer, see
367     * http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn
368     * exactly what type of property value each property returns for replication.
369     *
370     * @param name The unique identifier (URI) of the property being set.
371     * @return     The current value of the property.  The pointer spans the same
372     *             life-time as the parser.  A null pointer is returned if nothing
373     *             was specified externally.
374     * @exception  SAXNotRecognizedException If the requested property is not known.
375     */
376        virtual void* getProperty(const XMLCh* const name) const ;
377
378  /**
379    * Allow an application to register a document event handler.
380    *
381    * If the application does not register a document handler, all
382    * document events reported by the SAX parser will be silently
383    * ignored (this is the default behaviour implemented by
384    * HandlerBase).
385    *
386    * Applications may register a new or different handler in the
387    * middle of a parse, and the SAX parser must begin using the new
388    * handler immediately.
389    *
390    * @param handler The document handler.
391    * @see DocumentHandler#DocumentHandler
392    * @see HandlerBase#HandlerBase
393    */
394    virtual void setContentHandler(ContentHandler* const handler) ;
395
396  /**
397    * Allow an application to register a DTD event handler.
398    *
399    * If the application does not register a DTD handler, all DTD
400    * events reported by the SAX parser will be silently ignored (this
401    * is the default behaviour implemented by HandlerBase).
402    *
403    * Applications may register a new or different handler in the middle
404    * of a parse, and the SAX parser must begin using the new handler
405    * immediately.
406    *
407    * @param handler The DTD handler.
408    * @see DTDHandler#DTDHandler
409    * @see HandlerBase#HandlerBase
410    */
411    virtual void setDTDHandler(DTDHandler* const handler) ;
412
413  /**
414    * Allow an application to register a custom entity resolver.
415    *
416    * If the application does not register an entity resolver, the
417    * SAX parser will resolve system identifiers and open connections
418    * to entities itself (this is the default behaviour implemented in
419    * DefaultHandler).
420    *
421    * Applications may register a new or different entity resolver
422    * in the middle of a parse, and the SAX parser must begin using
423    * the new resolver immediately.
424    *
425    * <i>Any previously set entity resolver is merely dropped, since the parser
426    * does not own them.  If both setEntityResolver and setXMLEntityResolver
427    * are called, then the last one is used.</i>
428    *
429    * @param resolver The object for resolving entities.
430    * @see EntityResolver#EntityResolver
431    * @see DefaultHandler#DefaultHandler
432    */
433    virtual void setEntityResolver(EntityResolver* const resolver) ;
434   
435  /** Set the entity resolver
436    *
437    * This method allows applications to install their own entity
438    * resolver. By installing an entity resolver, the applications
439    * can trap and potentially redirect references to external
440    * entities.
441    *
442    * <i>Any previously set entity resolver is merely dropped, since the parser
443    * does not own them.  If both setEntityResolver and setXMLEntityResolver
444    * are called, then the last one is used.</i>
445    *
446    * @param resolver  A const pointer to the user supplied entity
447    *                  resolver.
448    *
449    * @see #getXMLEntityResolver
450    */
451    virtual void setXMLEntityResolver(XMLEntityResolver* const resolver) ;
452
453  /**
454    * Allow an application to register an error event handler.
455    *
456    * If the application does not register an error event handler,
457    * all error events reported by the SAX parser will be silently
458    * ignored, except for fatalError, which will throw a SAXException
459    * (this is the default behaviour implemented by HandlerBase).
460    *
461    * Applications may register a new or different handler in the
462    * middle of a parse, and the SAX parser must begin using the new
463    * handler immediately.
464    *
465    * @param handler The error handler.
466    * @see ErrorHandler#ErrorHandler
467    * @see SAXException#SAXException
468    * @see HandlerBase#HandlerBase
469    */
470    virtual void setErrorHandler(ErrorHandler* const handler) ;
471
472  /**
473    * This method installs the user specified PSVI handler on
474    * the parser.
475    *
476    * @param handler A pointer to the PSVI handler to be called
477    *                when the parser comes across 'PSVI' events
478    *                as per the schema specification.
479    */
480    virtual void setPSVIHandler(PSVIHandler* const handler);
481
482  /**
483    * Set the state of any feature in a SAX2 XMLReader.
484    * Supported features in SAX2 for xerces-c are:
485    * <br>(See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Features for detail description).
486    *
487    * <br>http://xml.org/sax/features/validation (default: true)
488    * <br>http://xml.org/sax/features/namespaces (default: true)
489    * <br>http://xml.org/sax/features/namespace-prefixes (default: false)
490    * <br>http://apache.org/xml/features/validation/dynamic (default: false)
491    * <br>http://apache.org/xml/features/validation/reuse-grammar (default: false)
492    * <br>http://apache.org/xml/features/validation/schema (default: true)
493    * <br>http://apache.org/xml/features/validation/schema-full-checking (default: false)
494    * <br>http://apache.org/xml/features/nonvalidating/load-external-dtd (default: true)
495    * <br>http://apache.org/xml/features/continue-after-fatal-error (default: false)
496    * <br>http://apache.org/xml/features/validation-error-as-fatal (default: false)
497    * <br>http://apache.org/xml/features/validation/reuse-validator (Deprecated) (default: false)
498    *
499    * @param name The unique identifier (URI) of the feature.
500    * @param value The requested state of the feature (true or false).
501    * @exception SAXNotRecognizedException If the requested feature is not known.
502    * @exception SAXNotSupportedException Feature modification is not supported during parse
503    *
504    */
505        virtual void setFeature(const XMLCh* const name, const bool value) ;
506
507  /**
508    * Set the value of any property in a SAX2 XMLReader.
509    * Supported properties in SAX2 for xerces-c are:
510    * <br>(See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties for detail description).
511    *
512    * <br>http://apache.org/xml/properties/schema/external-schemaLocation
513    * <br>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation.
514    *
515    * It takes a void pointer as the property value.  Application is required to initialize this void
516    * pointer to a correct type.  See http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties
517    * to learn exactly what type of property value each property expects for processing.
518    * Passing a void pointer that was initialized with a wrong type will lead to unexpected result.
519    * If the same property is set more than once, the last one takes effect.
520    *
521    * @param name The unique identifier (URI) of the property being set.
522    * @param value The requested value for the property.  See
523    *            http://xml.apache.org/xerces-c/program-sax2.html#SAX2Properties to learn
524    *            exactly what type of property value each property expects for processing.
525    *            Passing a void pointer that was initialized with a wrong type will lead
526    *            to unexpected result.
527    * @exception SAXNotRecognizedException If the requested property is not known.
528    * @exception SAXNotSupportedException Property modification is not supported during parse
529    */
530        virtual void setProperty(const XMLCh* const name, void* value) ;
531
532  /**
533    * Parse an XML document.
534    *
535    * The application can use this method to instruct the SAX parser
536    * to begin parsing an XML document from any valid input
537    * source (a character stream, a byte stream, or a URI).
538    *
539    * Applications may not invoke this method while a parse is in
540    * progress (they should create a new Parser instead for each
541    * additional XML document).  Once a parse is complete, an
542    * application may reuse the same Parser object, possibly with a
543    * different input source.
544    *
545    * @param source The input source for the top-level of the
546    *               XML document.
547    * @exception SAXException Any SAX exception, possibly
548    *            wrapping another exception.
549    * @exception XMLException An exception from the parser or client
550    *            handler code.
551    * @see InputSource#InputSource
552    * @see #setEntityResolver
553    * @see #setDTDHandler
554    * @see #setDocumentHandler
555    * @see #setErrorHandler
556    */
557    virtual void parse
558    (
559        const   InputSource&    source
560    ) ;
561
562  /**
563    * Parse an XML document from a system identifier (URI).
564    *
565    * This method is a shortcut for the common case of reading a
566    * document from a system identifier.  It is the exact equivalent
567    * of the following:
568    *
569    * parse(new URLInputSource(systemId));
570    *
571    * If the system identifier is a URL, it must be fully resolved
572    * by the application before it is passed to the parser.
573    *
574    * @param systemId The system identifier (URI).
575    * @exception SAXException Any SAX exception, possibly
576    *            wrapping another exception.
577    * @exception XMLException An exception from the parser or client
578    *            handler code.
579    * @see #parse(InputSource)
580    */
581    virtual void parse
582    (
583        const   XMLCh* const    systemId
584    ) ;
585
586  /**
587    * Parse an XML document from a system identifier (URI).
588    *
589    * This method is a shortcut for the common case of reading a
590    * document from a system identifier.  It is the exact equivalent
591    * of the following:
592    *
593    * parse(new URLInputSource(systemId));
594    *
595    * If the system identifier is a URL, it must be fully resolved
596    * by the application before it is passed to the parser.
597    *
598    * @param systemId The system identifier (URI).
599    * @exception SAXException Any SAX exception, possibly
600    *            wrapping another exception.
601    * @exception XMLException An exception from the parser or client
602    *            handler code.
603    * @see #parse(InputSource)
604    */
605    virtual void parse
606    (
607        const   char* const     systemId
608    ) ;
609       
610    //@}
611
612    // -----------------------------------------------------------------------
613    //  SAX 2.0-ext
614    // -----------------------------------------------------------------------
615    /** @name SAX 2.0-ext */
616    //@{
617    /**
618      * This method returns the installed declaration handler.
619      *
620      * @return A pointer to the installed declaration handler object.
621      */
622    virtual DeclHandler* getDeclarationHandler() const ;
623
624        /**
625      * This method returns the installed lexical handler.
626      *
627      * @return A pointer to the installed lexical handler object.
628      */
629    virtual LexicalHandler* getLexicalHandler() const ;
630
631   /**
632    * Allow an application to register a declaration event handler.
633    *
634    * If the application does not register a declaration handler,
635    * all events reported by the SAX parser will be silently
636    * ignored. (this is the default behaviour implemented by DefaultHandler).
637    *
638    * Applications may register a new or different handler in the
639    * middle of a parse, and the SAX parser must begin using the new
640    * handler immediately.
641    *
642    * @param handler The DTD declaration handler.
643    * @see DeclHandler#DeclHandler
644    * @see SAXException#SAXException
645    * @see DefaultHandler#DefaultHandler
646    */
647    virtual void setDeclarationHandler(DeclHandler* const handler) ;
648
649   /**
650    * Allow an application to register a lexical event handler.
651    *
652    * If the application does not register a lexical handler,
653    * all events reported by the SAX parser will be silently
654    * ignored. (this is the default behaviour implemented by HandlerBase).
655    *
656    * Applications may register a new or different handler in the
657    * middle of a parse, and the SAX parser must begin using the new
658    * handler immediately.
659    *
660    * @param handler The error handler.
661    * @see LexicalHandler#LexicalHandler
662    * @see SAXException#SAXException
663    * @see HandlerBase#HandlerBase
664    */
665    virtual void setLexicalHandler(LexicalHandler* const handler) ;
666
667    //@}
668
669    // -----------------------------------------------------------------------
670    //  Getter Methods
671    // -----------------------------------------------------------------------
672    /** @name Getter Methods (Xerces-C specific) */
673    //@{
674    /**
675          * This method is used to get the current validator.
676          *
677          * <b>SAX2XMLReader assumes responsibility for the validator.  It will be
678          * deleted when the XMLReader is destroyed.</b>
679          *
680          * @return A pointer to the validator.  An application should not deleted
681          * the object returned.
682          *
683          */
684        virtual XMLValidator* getValidator() const ;
685    //@}
686
687    /** Get error count from the last parse operation.
688      *
689      * This method returns the error count from the last parse
690      * operation. Note that this count is actually stored in the
691      * scanner, so this method simply returns what the
692      * scanner reports.
693      *
694      * @return number of errors encountered during the latest
695      *                 parse operation.
696      */
697    virtual int getErrorCount() const ;
698
699    /**
700      * This method returns the state of the parser's
701      * exit-on-First-Fatal-Error flag.
702      *
703      * <p>Or you can query the feature "http://apache.org/xml/features/continue-after-fatal-error"
704      * which indicates the opposite state.</p>
705      *
706      * @return true, if the parser is currently configured to
707      *         exit on the first fatal error, false otherwise.
708      *
709      * @see #setExitOnFirstFatalError
710      * @see #getFeature
711      */
712    virtual bool getExitOnFirstFatalError() const ;
713
714    /**
715      * This method returns the state of the parser's
716      * validation-constraint-fatal flag.
717      *
718      * <p>Or you can query the feature "http://apache.org/xml/features/validation-error-as-fatal"
719      * which means the same thing.
720      *
721      * @return true, if the parser is currently configured to
722      *         set validation constraint errors as fatal, false
723      *         otherwise.
724      *
725      * @see #setValidationContraintFatal
726      * @see #getFeature
727      */
728    virtual bool getValidationConstraintFatal() const ;
729
730    /**
731      * Retrieve the grammar that is associated with the specified namespace key
732      *
733      * @param  nameSpaceKey Namespace key
734      * @return Grammar associated with the Namespace key.
735      */
736    virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey);
737
738    /**
739      * Retrieve the grammar where the root element is declared.
740      *
741      * @return Grammar where root element declared
742      */
743    virtual Grammar* getRootGrammar();
744
745    /**
746      * Returns the string corresponding to a URI id from the URI string pool.
747      *
748      * @param uriId id of the string in the URI string pool.
749      * @return URI string corresponding to the URI id.
750      */
751    virtual const XMLCh* getURIText(unsigned int uriId) const;
752
753    /**
754      * Returns the current src offset within the input source.
755      *
756      * @return offset within the input source
757      */
758    virtual unsigned int getSrcOffset() const;
759
760    //@}
761
762    // -----------------------------------------------------------------------
763    //  Setter Methods
764    // -----------------------------------------------------------------------
765    /** @name Setter Methods (Xerces-C specific) */
766    //@{
767    /**
768          * This method is used to set a validator.
769          *
770          * <b>SAX2XMLReader assumes responsibility for the validator.  It will be
771          * deleted when the XMLReader is destroyed.</b>
772          *
773          * @param valueToAdopt A pointer to the validator that the reader should use.
774          *
775          */
776        virtual void setValidator(XMLValidator* valueToAdopt) ;
777
778    /**
779      * This method allows users to set the parser's behaviour when it
780      * encounters the first fatal error. If set to true, the parser
781      * will exit at the first fatal error. If false, then it will
782      * report the error and continue processing.
783      *
784      * <p>The default value is 'true' and the parser exits on the
785      * first fatal error.</p>
786      *
787      * <p>Or you can set the feature "http://apache.org/xml/features/continue-after-fatal-error"
788      * which has the opposite behaviour.</p>
789      *
790      * <p>If both the feature above and this function are used, the latter takes effect.</p>
791      *
792      * @param newState The value specifying whether the parser should
793      *                 continue or exit when it encounters the first
794      *                 fatal error.
795      *
796      * @see #getExitOnFirstFatalError
797      * @see #setFeature
798      */
799    virtual void setExitOnFirstFatalError(const bool newState) ;
800
801    /**
802      * This method allows users to set the parser's behaviour when it
803      * encounters a validtion constraint error. If set to true, and the
804      * the parser will treat validation error as fatal and will exit depends on the
805      * state of "getExitOnFirstFatalError". If false, then it will
806      * report the error and continue processing.
807      *
808      * Note: setting this true does not mean the validation error will be printed with
809      * the word "Fatal Error".   It is still printed as "Error", but the parser
810      * will exit if "setExitOnFirstFatalError" is set to true.
811      *
812      * <p>The default value is 'false'.</p>
813      *
814      * <p>Or you can set the feature "http://apache.org/xml/features/validation-error-as-fatal"
815      * which means the same thing.</p>
816      *
817      * <p>If both the feature above and this function are used, the latter takes effect.</p>
818      *
819      * @param newState If true, the parser will exit if "setExitOnFirstFatalError"
820      *                 is set to true.
821      *
822      * @see #getValidationConstraintFatal
823      * @see #setExitOnFirstFatalError
824      * @see #setFeature
825      */
826    virtual void setValidationConstraintFatal(const bool newState) ;
827    //@}
828
829
830    // -----------------------------------------------------------------------
831    //  Progressive scan methods
832    // -----------------------------------------------------------------------
833
834    /** @name Progressive scan methods */
835    //@{
836
837    /** Begin a progressive parse operation
838      *
839      * This method is used to start a progressive parse on a XML file.
840      * To continue parsing, subsequent calls must be to the parseNext
841      * method.
842      *
843      * It scans through the prolog and returns a token to be used on
844      * subsequent scanNext() calls. If the return value is true, then the
845      * token is legal and ready for further use. If it returns false, then
846      * the scan of the prolog failed and the token is not going to work on
847      * subsequent scanNext() calls.
848      *
849      * @param systemId A pointer to a Unicode string represting the path
850      *                 to the XML file to be parsed.
851      * @param toFill   A token maintaing state information to maintain
852      *                 internal consistency between invocation of 'parseNext'
853      *                 calls.
854      *
855      * @return 'true', if successful in parsing the prolog. It indicates the
856      *         user can go ahead with parsing the rest of the file. It
857      *         returns 'false' to indicate that the parser could parse the
858      *         prolog (which means the token will not be valid.)
859      *
860      * @see #parseNext
861      * @see #parseFirst(char*,...)
862      * @see #parseFirst(InputSource&,...)
863      */
864    virtual bool parseFirst
865    (
866        const   XMLCh* const    systemId
867        ,       XMLPScanToken&  toFill
868    ) ;
869
870    /** Begin a progressive parse operation
871      *
872      * This method is used to start a progressive parse on a XML file.
873      * To continue parsing, subsequent calls must be to the parseNext
874      * method.
875      *
876      * It scans through the prolog and returns a token to be used on
877      * subsequent scanNext() calls. If the return value is true, then the
878      * token is legal and ready for further use. If it returns false, then
879      * the scan of the prolog failed and the token is not going to work on
880      * subsequent scanNext() calls.
881      *
882      * @param systemId A pointer to a regular native string represting
883      *                 the path to the XML file to be parsed.
884      * @param toFill   A token maintaing state information to maintain
885      *                 internal consIstency between invocation of 'parseNext'
886      *                 calls.
887      *
888      * @return 'true', if successful in parsing the prolog. It indicates the
889      *         user can go ahead with parsing the rest of the file. It
890      *         returns 'false' to indicate that the parser could not parse
891      *         the prolog.
892      *
893      * @see #parseNext
894      * @see #parseFirst(XMLCh*,...)
895      * @see #parseFirst(InputSource&,...)
896      */
897    virtual bool parseFirst
898    (
899        const   char* const     systemId
900        ,       XMLPScanToken&  toFill
901    ) ;
902
903    /** Begin a progressive parse operation
904      *
905      * This method is used to start a progressive parse on a XML file.
906      * To continue parsing, subsequent calls must be to the parseNext
907      * method.
908      *
909      * It scans through the prolog and returns a token to be used on
910      * subsequent scanNext() calls. If the return value is true, then the
911      * token is legal and ready for further use. If it returns false, then
912      * the scan of the prolog failed and the token is not going to work on
913      * subsequent scanNext() calls.
914      *
915      * @param source   A const reference to the InputSource object which
916      *                 points to the XML file to be parsed.
917      * @param toFill   A token maintaing state information to maintain
918      *                 internal consistency between invocation of 'parseNext'
919      *                 calls.
920      *
921      * @return 'true', if successful in parsing the prolog. It indicates the
922      *         user can go ahead with parsing the rest of the file. It
923      *         returns 'false' to indicate that the parser could not parse
924      *         the prolog.
925      *
926      * @see #parseNext
927      * @see #parseFirst(XMLCh*,...)
928      * @see #parseFirst(char*,...)
929      */
930    virtual bool parseFirst
931    (
932        const   InputSource&    source
933        ,       XMLPScanToken&  toFill
934    ) ;
935
936    /** Continue a progressive parse operation
937      *
938      * This method is used to continue with progressive parsing of
939      * XML files started by a call to 'parseFirst' method.
940      *
941      * It parses the XML file and stops as soon as it comes across
942      * a XML token (as defined in the XML specification). Relevant
943      * callback handlers are invoked as required by the SAX
944      * specification.
945      *
946      * @param token 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 next XML token.
951      *         It indicates the user can go ahead with parsing the rest
952      *         of the file. It returns 'false' to indicate that the parser
953      *         could not find next token as per the XML specification
954      *         production rule.
955      *
956      * @see #parseFirst(XMLCh*,...)
957      * @see #parseFirst(char*,...)
958      * @see #parseFirst(InputSource&,...)
959      */
960    virtual bool parseNext(XMLPScanToken& token) ;
961
962    /** Reset the parser after a progressive parse
963      *
964      * If a progressive parse loop exits before the end of the document
965      * is reached, the parser has no way of knowing this. So it will leave
966      * open any files or sockets or memory buffers that were in use at
967      * the time that the parse loop exited.
968      *
969      * The next parse operation will cause these open files and such to
970      * be closed, but the next parse operation might occur at some unknown
971      * future point. To avoid this problem, you should reset the parser if
972      * you exit the loop early.
973      *
974      * If you exited because of an error, then this cleanup will be done
975      * for you. Its only when you exit the file prematurely of your own
976      * accord, because you've found what you wanted in the file most
977      * likely.
978      *
979      * @param token A token maintaing state information to maintain
980      *              internal consistency between invocation of 'parseNext'
981      *              calls.
982      */
983    virtual void parseReset(XMLPScanToken& token) ;
984
985    //@}
986
987    // -----------------------------------------------------------------------
988    //  Implementation of the grammar preparsing interface
989    // -----------------------------------------------------------------------
990
991    /** @name Implementation of Grammar preparsing interface's. */
992    //@{
993    /**
994      * Preparse schema grammar (XML Schema, DTD, etc.) via an input source
995      * object.
996      *
997      * This method invokes the preparsing process on a schema grammar XML
998      * file specified by the SAX InputSource parameter.
999      *
1000      * <p><b>"Experimental - subject to change"</b></p>
1001      *
1002      * @param source A const reference to the SAX InputSource object which
1003      *               points to the schema grammar file to be preparsed.
1004      * @param grammarType The grammar type (Schema or DTD).
1005      * @param toCache If <code>true</code>, we cache the preparsed grammar,
1006      *                otherwise, no chaching. Default is <code>false</code>.
1007      * @return The preparsed schema grammar object (SchemaGrammar or
1008      *         DTDGrammar). That grammar object is owned by the parser.
1009      *
1010      * @exception SAXException Any SAX exception, possibly
1011      *            wrapping another exception.
1012      * @exception XMLException An exception from the parser or client
1013      *            handler code.
1014      * @exception DOMException A DOM exception as per DOM spec.
1015      *
1016      * @see InputSource#InputSource
1017      */
1018    virtual Grammar* loadGrammar(const InputSource& source,
1019                                 const short grammarType,
1020                                 const bool toCache = false);
1021
1022    /**
1023      * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
1024      *
1025      * This method invokes the preparsing process on a schema grammar XML
1026      * file specified by the file path parameter.
1027      *
1028      * <p><b>"Experimental - subject to change"</b></p>
1029      *
1030      * @param systemId A const XMLCh pointer to the Unicode string which
1031      *                 contains the path to the XML grammar file to be
1032      *                 preparsed.
1033      * @param grammarType The grammar type (Schema or DTD).
1034      * @param toCache If <code>true</code>, we cache the preparsed grammar,
1035      *                otherwise, no chaching. Default is <code>false</code>.
1036      * @return The preparsed schema grammar object (SchemaGrammar or
1037      *         DTDGrammar). That grammar object is owned by the parser.
1038      *
1039      * @exception SAXException Any SAX exception, possibly
1040      *            wrapping another exception.
1041      * @exception XMLException An exception from the parser or client
1042      *            handler code.
1043      * @exception DOMException A DOM exception as per DOM spec.
1044      */
1045    virtual Grammar* loadGrammar(const XMLCh* const systemId,
1046                                 const short grammarType,
1047                                 const bool toCache = false);
1048
1049    /**
1050      * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
1051      *
1052      * This method invokes the preparsing process on a schema grammar XML
1053      * file specified by the file path parameter.
1054      *
1055      * <p><b>"Experimental - subject to change"</b></p>
1056      *
1057      * @param systemId A const char pointer to a native string which contains
1058      *                 the path to the XML grammar file to be preparsed.
1059      * @param grammarType The grammar type (Schema or DTD).
1060      * @param toCache If <code>true</code>, we cache the preparsed grammar,
1061      *                otherwise, no chaching. Default is <code>false</code>.
1062      * @return The preparsed schema grammar object (SchemaGrammar or
1063      *         DTDGrammar). That grammar object is owned by the parser.
1064      *
1065      * @exception SAXException Any SAX exception, possibly
1066      *            wrapping another exception.
1067      * @exception XMLException An exception from the parser or client
1068      *            handler code.
1069      * @exception DOMException A DOM exception as per DOM spec.
1070      */
1071    virtual Grammar* loadGrammar(const char* const systemId,
1072                                 const short grammarType,
1073                                 const bool toCache = false);
1074
1075    /**
1076      * Clear the cached grammar pool
1077      */
1078    virtual void resetCachedGrammarPool();
1079
1080    //@}
1081
1082
1083    // -----------------------------------------------------------------------
1084    //  Advanced document handler list maintenance methods
1085    // -----------------------------------------------------------------------
1086
1087    /** @name Advanced document handler list maintenance methods */
1088    //@{
1089    /**
1090      * This method installs the specified 'advanced' document callback
1091      * handler, thereby allowing the user to customize the processing,
1092      * if they choose to do so. Any number of advanced callback handlers
1093      * maybe installed.
1094      *
1095      * <p>The methods in the advanced callback interface represent
1096      * Xerces-C extensions. There is no specification for this interface.</p>
1097      *
1098      * @param toInstall A pointer to the users advanced callback handler.
1099      *
1100      * @see #removeAdvDocHandler
1101      */
1102    virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) ;
1103
1104    /**
1105      * This method removes the 'advanced' document handler callback from
1106      * the underlying parser scanner. If no handler is installed, advanced
1107      * callbacks are not invoked by the scanner.
1108      * @param toRemove A pointer to the advanced callback handler which
1109      *                 should be removed.
1110      *
1111      * @see #installAdvDocHandler
1112      */
1113    virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) ;
1114    //@}
1115
1116        // -----------------------------------------------------------------------
1117    //  Implementation of the XMLDocumentHandler interface
1118    // -----------------------------------------------------------------------
1119    /** @name Implementation of the XMLDocumentHandler Interface. */
1120    //@{
1121    /**
1122      * This method is used to report all the characters scanned
1123      * by the parser. The driver will invoke the 'characters'
1124      * method of the user installed SAX Document Handler.
1125      *
1126      * <p>If any advanced callback handlers are installed, the
1127      * corresponding 'docCharacters' method will also be invoked.</p>
1128      *
1129      * @param chars   A const pointer to a Unicode string representing the
1130      *                character data.
1131      * @param length  The length of the Unicode string returned in 'chars'.
1132      * @param cdataSection  A flag indicating if the characters represent
1133      *                      content from the CDATA section.
1134      * @see DocumentHandler#characters
1135      */
1136    virtual void docCharacters
1137    (
1138        const   XMLCh* const    chars
1139        , const unsigned int    length
1140        , const bool            cdataSection
1141    );
1142
1143    /**
1144      * This method is used to report any comments scanned by the parser.
1145      * This method is a no-op unless, unless an advanced callback handler
1146      * is installed, in which case the corresponding 'docComment' method
1147      * is invoked.
1148      *
1149      * @param comment A const pointer to a null terminated Unicode
1150      *                string representing the comment text.
1151      */
1152    virtual void docComment
1153    (
1154        const   XMLCh* const    comment
1155    );
1156
1157    /**
1158      * This method is used to report any PI scanned by the parser.
1159      *
1160      * <p>Any PI's occurring before any 'content' are not reported
1161      * to any SAX handler as per the specification. However, all
1162      * PI's within content are reported via the SAX Document Handler's
1163      * 'processingInstruction' method.
1164      *
1165      * <p>If any advanced callback handlers are installed, the
1166      * corresponding 'docPI' method will be invoked.</p>
1167      *
1168      * @param target A const pointer to a Unicode string representing the
1169      *               target of the PI declaration.
1170      * @param data   A const pointer to a Unicode string representing the
1171      *               data of the PI declaration. See the PI production rule
1172      *               in the XML specification for details.
1173      *
1174      * @see DocumentHandler#processingInstruction
1175      */
1176    virtual void docPI
1177    (
1178        const   XMLCh* const    target
1179        , const XMLCh* const    data
1180    );
1181
1182    /**
1183      * This method is used to indicate the end of root element
1184      * was just scanned by the parser. Corresponding 'endDocument'
1185      * method of the user installed SAX Document Handler will also
1186      * be invoked.
1187      *
1188      * <p>In addition, if any advanced callback handlers are installed,
1189      * the corresponding 'endDocument' method is invoked.</p>
1190      *
1191      * @see DocumentHandler#endDocument
1192      */
1193    virtual void endDocument();
1194
1195    /**
1196      * This method is used to indicate the end tag of an element.
1197      * The driver will invoke the corresponding 'endElement' method of
1198      * the SAX Document Handler interface.
1199      *
1200      * <p>If any advanced callback handlers are installed, the
1201      * corresponding 'endElement' method is also invoked.</p>
1202      *
1203      * @param elemDecl A const reference to the object containing element
1204      *                 declaration information.
1205      * @param urlId    An id referring to the namespace prefix, if
1206      *                 namespaces setting is switched on.
1207      * @param isRoot   A flag indicating whether this element was the
1208      *                 root element.
1209      * @param elemPrefix A const pointer to a Unicode string containing
1210      *                   the namespace prefix for this element. Applicable
1211      *                   only when namespace processing is enabled.
1212      * @see DocumentHandler#endElement
1213      */
1214    virtual void endElement
1215    (
1216        const   XMLElementDecl& elemDecl
1217        , const unsigned int    urlId
1218        , const bool            isRoot
1219        , const XMLCh* const    elemPrefix=0
1220    );
1221
1222    /**
1223      * This method is used to indicate that an end of an entity reference
1224      * was just scanned.
1225      *
1226      * <p>If any advanced callback handlers are installed, the
1227      * corresponding 'endEnityReference' method is invoked.</p>
1228      *
1229      * @param entDecl A const reference to the object containing the
1230      *                entity declaration information.
1231      */
1232    virtual void endEntityReference
1233    (
1234        const   XMLEntityDecl&  entDecl
1235    );
1236
1237    /**
1238      * This method is used to report all the whitespace characters,
1239      * which are determined to be 'ignorable'. This distinction
1240      * between characters is only made, if validation is enabled.
1241      * Corresponding 'ignorableWhitespace' method of the user installed
1242      * SAX Document Handler interface is called.
1243      *
1244      * <p>Any whitespace before content is not reported to the SAX
1245      * Document Handler method, as per the SAX specification.
1246      * However, if any advanced callback handlers are installed, the
1247      * corresponding 'ignorableWhitespace' method is invoked.</p>
1248      *
1249      * @param chars   A const pointer to a Unicode string representing the
1250      *                ignorable whitespace character data.
1251      * @param length  The length of the Unicode string 'chars'.
1252      * @param cdataSection  A flag indicating if the characters represent
1253      *                      content from the CDATA section.
1254      * @see DocumentHandler#ignorableWhitespace
1255      */
1256    virtual void ignorableWhitespace
1257    (
1258        const   XMLCh* const    chars
1259        , const unsigned int    length
1260        , const bool            cdataSection
1261    );
1262
1263    /**
1264      * This method allows the user installed Document Handler and
1265      * any advanced callback handlers to 'reset' themselves.
1266      */
1267    virtual void resetDocument();
1268
1269    /**
1270      * This method is used to report the start of the parsing process.
1271      * The corresponding user installed SAX Document Handler's method
1272      * 'startDocument' is invoked.
1273      *
1274      * <p>If any advanced callback handlers are installed, then the
1275      * corresponding 'startDocument' method is also called.</p>
1276      *
1277      * @see DocumentHandler#startDocument
1278      */
1279    virtual void startDocument();
1280
1281    /**
1282      * This method is used to report the start of an element. It is
1283      * called at the end of the element, by which time all attributes
1284      * specified are also parsed. The corresponding user installed
1285      * SAX Document Handler's method 'startElement' is invoked.
1286      *
1287      * <p>If any advanced callback handlers are installed, then the
1288      * corresponding 'startElement' method is also called.</p>
1289      *
1290      * @param elemDecl A const reference to the object containing element
1291      *                 declaration information.
1292      * @param urlId    An id referring to the namespace prefix, if
1293      *                 namespaces setting is switched on.
1294      * @param elemPrefix A const pointer to a Unicode string containing
1295      *                   the namespace prefix for this element. Applicable
1296      *                   only when namespace processing is enabled.
1297      * @param attrList  A const reference to the object containing the
1298      *                  list of attributes just scanned for this element.
1299      * @param attrCount A count of number of attributes in the list
1300      *                  specified by the parameter 'attrList'.
1301      * @param isEmpty  A flag indicating whether this is an empty element
1302      *                 or not.
1303      * @param isRoot   A flag indicating whether this element was the
1304      *                 root element.
1305      * @see DocumentHandler#startElement
1306      */
1307    virtual void startElement
1308    (
1309        const   XMLElementDecl&         elemDecl
1310        , const unsigned int            urlId
1311        , const XMLCh* const            elemPrefix
1312        , const RefVectorOf<XMLAttr>&   attrList
1313        , const unsigned int            attrCount
1314        , const bool                    isEmpty
1315        , const bool                    isRoot
1316    );
1317
1318    /**
1319      * This method is used to indicate the start of an entity reference.
1320      *
1321      * <p>If any advanced callback handlers are installed, the
1322      * corresponding 'endEnityReference' method is invoked.</p>
1323      *
1324      * @param entDecl A const reference to the object containing the
1325      *                entity declaration information.
1326      */
1327    virtual void startEntityReference
1328    (
1329        const   XMLEntityDecl&  entDecl
1330    );
1331
1332    /**
1333      * This method is used to report the XML decl scanned by the parser.
1334      * Refer to the XML specification to see the meaning of parameters.
1335      *
1336      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1337      * implementation.</font></b>
1338      *
1339      * @param versionStr A const pointer to a Unicode string representing
1340      *                   version string value.
1341      * @param encodingStr A const pointer to a Unicode string representing
1342      *                    the encoding string value.
1343      * @param standaloneStr A const pointer to a Unicode string
1344      *                      representing the standalone string value.
1345      * @param actualEncodingStr A const pointer to a Unicode string
1346      *                          representing the actual encoding string
1347      *                          value.
1348      */
1349    virtual void XMLDecl
1350    (
1351        const   XMLCh* const    versionStr
1352        , const XMLCh* const    encodingStr
1353        , const XMLCh* const    standaloneStr
1354        , const XMLCh* const    actualEncodingStr
1355    );
1356    //@}
1357
1358
1359    // -----------------------------------------------------------------------
1360    //  Implementation of the XMLErrorReporter interface
1361    // -----------------------------------------------------------------------
1362
1363    /** @name Implementation of the XMLErrorReporter Interface. */
1364    //@{
1365    /**
1366      * This method is used to report back errors found while parsing the
1367      * XML file. The driver will call the corresponding user installed
1368      * SAX Error Handler methods: 'fatal', 'error', 'warning' depending
1369      * on the severity of the error. This classification is defined by
1370      * the XML specification.
1371      *
1372      * @param errCode An integer code for the error.
1373      * @param msgDomain A const pointer to an Unicode string representing
1374      *                  the message domain to use.
1375      * @param errType An enumeration classifying the severity of the error.
1376      * @param errorText A const pointer to an Unicode string representing
1377      *                  the text of the error message.
1378      * @param systemId  A const pointer to an Unicode string representing
1379      *                  the system id of the XML file where this error
1380      *                  was discovered.
1381      * @param publicId  A const pointer to an Unicode string representing
1382      *                  the public id of the XML file where this error
1383      *                  was discovered.
1384      * @param lineNum   The line number where the error occurred.
1385      * @param colNum    The column number where the error occurred.
1386      * @see ErrorHandler
1387      */
1388    virtual void error
1389    (
1390        const   unsigned int                errCode
1391        , const XMLCh* const                msgDomain
1392        , const XMLErrorReporter::ErrTypes  errType
1393        , const XMLCh* const                errorText
1394        , const XMLCh* const                systemId
1395        , const XMLCh* const                publicId
1396        , const XMLSSize_t                   lineNum
1397        , const XMLSSize_t                   colNum
1398    );
1399
1400    /**
1401      * This method allows the user installed Error Handler
1402      * callback to 'reset' itself.
1403      *
1404      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1405      * implementation.</font></b>
1406      *
1407      */
1408    virtual void resetErrors();
1409    //@}
1410
1411
1412    // -----------------------------------------------------------------------
1413    //  Implementation of the XMLEntityHandler interface
1414    // -----------------------------------------------------------------------
1415
1416    /** @name Implementation of the XMLEntityHandler Interface. */
1417    //@{
1418    /**
1419      * This method is used to indicate the end of parsing of an external
1420      * entity file.
1421      *
1422      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1423      * implementation.</font></b>
1424      *
1425      * @param inputSource A const reference to the InputSource object
1426      *                    which points to the XML file being parsed.
1427      * @see InputSource
1428      */
1429    virtual void endInputSource(const InputSource& inputSource);
1430
1431    /**
1432      * This method allows an installed XMLEntityHandler to further
1433      * process any system id's of enternal entities encountered in
1434      * the XML file being parsed, such as redirection etc.
1435      *
1436      * <b><font color="#FF0000">This method always returns 'false'
1437      * for this SAX driver implementation.</font></b>
1438      *
1439      * @param systemId  A const pointer to an Unicode string representing
1440      *                  the system id scanned by the parser.
1441      * @param toFill    A pointer to a buffer in which the application
1442      *                  processed system id is stored.
1443      * @return 'true', if any processing is done, 'false' otherwise.
1444      */
1445    virtual bool expandSystemId
1446    (
1447        const   XMLCh* const    systemId
1448        ,       XMLBuffer&      toFill
1449    );
1450
1451    /**
1452      * This method allows the installed XMLEntityHandler to reset
1453      * itself.
1454      *
1455      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1456      * implementation.</font></b>
1457      */
1458    virtual void resetEntities();
1459
1460    /**
1461      * This method allows a user installed entity handler to further
1462      * process any pointers to external entities. The applications
1463      * can implement 'redirection' via this callback. The driver
1464      * should call the SAX EntityHandler 'resolveEntity' method.
1465      *
1466      * @deprecated This method is no longer called (the other resolveEntity one is).
1467      *
1468      * @param publicId A const pointer to a Unicode string representing the
1469      *                 public id of the entity just parsed.
1470      * @param systemId A const pointer to a Unicode string representing the
1471      *                 system id of the entity just parsed.
1472      * @param baseURI  A const pointer to a Unicode string representing the
1473      *                 base URI of the entity just parsed,
1474      *                 or <code>null</code> if there is no base URI.
1475      * @return The value returned by the SAX resolveEntity method or
1476      *         NULL otherwise to indicate no processing was done.
1477      *         The returned InputSource is owned by the parser which is
1478      *         responsible to clean up the memory.
1479      * @see EntityResolver
1480      * @see XMLEntityHandler
1481      */
1482    virtual InputSource* resolveEntity
1483    (
1484        const   XMLCh* const    publicId
1485        , const XMLCh* const    systemId
1486        , const XMLCh* const    baseURI = 0
1487    );
1488
1489    /** Resolve a public/system id
1490      *
1491      * This method allows a user installed entity handler to further
1492      * process any pointers to external entities. The applications can
1493      * implement 'redirection' via this callback. 
1494      *
1495      * @param resourceIdentifier An object containing the type of
1496      *        resource to be resolved and the associated data members
1497      *        corresponding to this type.
1498      * @return The value returned by the user installed resolveEntity
1499      *         method or NULL otherwise to indicate no processing was done.
1500      *         The returned InputSource is owned by the parser which is
1501      *         responsible to clean up the memory.
1502      * @see XMLEntityHandler
1503      * @see XMLEntityResolver
1504      */
1505    virtual InputSource* resolveEntity
1506    (
1507        XMLResourceIdentifier* resourceIdentifier
1508    );
1509
1510    /**
1511      * This method is used to indicate the start of parsing an
1512      * external entity file.
1513      *
1514      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1515      * implementation.</font></b>
1516      *
1517      * @param inputSource A const reference to the InputSource object
1518      *                    which points to the external entity
1519      *                    being parsed.
1520      */
1521    virtual void startInputSource(const InputSource& inputSource);
1522    //@}
1523
1524    // -----------------------------------------------------------------------
1525    //  Implementation of the Deprecated DocTypeHandler Interface
1526    // -----------------------------------------------------------------------
1527
1528    /** @name Implementation of the deprecated DocTypeHandler Interface */
1529    //@{
1530    /**
1531      * This method is used to report an attribute definition.
1532      *
1533      * <b><font color="#FF0000">This method is a no-op for this SAX
1534      * driver implementation.</font></b>
1535      *
1536      * @param elemDecl A const reference to the object containing information
1537      *                 about the element whose attribute definition was just
1538      *                 parsed.
1539      * @param attDef   A const reference to the object containing information
1540      *                 attribute definition.
1541      * @param ignore   The flag indicating whether this attribute definition
1542      *                 was ignored by the parser or not.
1543      */
1544    virtual void attDef
1545    (
1546        const   DTDElementDecl& elemDecl
1547        , const DTDAttDef&      attDef
1548        , const bool            ignoring
1549    );
1550
1551    /**
1552      * This method is used to report a comment occurring within the DTD.
1553      *
1554      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1555      * implementation.</font></b>
1556      *
1557      * @param comment  A const pointer to a Unicode string representing the
1558      *                 text of the comment just parsed.
1559      */
1560    virtual void doctypeComment
1561    (
1562        const   XMLCh* const    comment
1563    );
1564
1565    /**
1566      * This method is used to report the DOCTYPE declaration.
1567      *
1568      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1569      * implementation.</font></b>
1570      *
1571      * @param elemDecl A const reference to the object containing information
1572      *                 about the root element definition declaration of the
1573      *                 XML document being parsed.
1574      * @param publicId A const pointer to a Unicode string representing the
1575      *                 public id of the DTD file.
1576      * @param systemId A const pointer to a Unicode string representing the
1577      *                 system id of the DTD file.
1578      * @param hasIntSubset A flag indicating if this XML file contains any
1579      *                     internal subset.
1580      * @param hasExtSubset A flag indicating if this XML file contains any
1581      *                     external subset. Default is false.
1582      */
1583    virtual void doctypeDecl
1584    (
1585        const   DTDElementDecl& elemDecl
1586        , const XMLCh* const    publicId
1587        , const XMLCh* const    systemId
1588        , const bool            hasIntSubset
1589        , const bool            hasExtSubset = false
1590    );
1591
1592    /**
1593      * This method is used to report any PI declarations
1594      * occurring inside the DTD definition block.
1595      *
1596      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1597      * implementation.</font></b>
1598      *
1599      * @param target A const pointer to a Unicode string representing the
1600      *               target of the PI declaration.
1601      * @param data   A const pointer to a Unicode string representing the
1602      *               data of the PI declaration. See the PI production rule
1603      *               in the XML specification for details.
1604      */
1605    virtual void doctypePI
1606    (
1607        const   XMLCh* const    target
1608        , const XMLCh* const    data
1609    );
1610
1611    /**
1612      * This method is used to report any whitespaces
1613      * occurring inside the DTD definition block.
1614      *
1615      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1616      * implementation.</font></b>
1617      *
1618      * @param chars  A const pointer to a Unicode string representing the
1619      *               whitespace characters.
1620      * @param length The length of the whitespace Unicode string.
1621      */
1622    virtual void doctypeWhitespace
1623    (
1624        const   XMLCh* const    chars
1625        , const unsigned int    length
1626    );
1627
1628    /**
1629      * This method is used to report an element declarations
1630      * successfully scanned by the parser.
1631      *
1632      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1633      * implementation.</font></b>
1634      *
1635      * @param decl   A const reference to the object containing element
1636      *               declaration information.
1637      * @param isIgnored The flag indicating whether this definition was
1638      *                  ignored by the parser or not.
1639      */
1640    virtual void elementDecl
1641    (
1642        const   DTDElementDecl& decl
1643        , const bool            isIgnored
1644    );
1645
1646    /**
1647      * This method is used to report the end of an attribute
1648      * list declaration for an element.
1649      *
1650      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1651      * implementation.</font></b>
1652      *
1653      * @param elemDecl A const reference to the object containing element
1654      *                 declaration information.
1655      */
1656    virtual void endAttList
1657    (
1658        const   DTDElementDecl& elemDecl
1659    );
1660
1661    /**
1662      * This method is used to report the end of the internal subset.
1663      *
1664      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1665      * implementation.</font></b>
1666      */
1667    virtual void endIntSubset();
1668
1669    /**
1670      * This method is used to report the end of the external subset.
1671      *
1672      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1673      * implementation.</font></b>
1674      */
1675    virtual void endExtSubset();
1676
1677    /**
1678      * This method is used to report any entity declarations.
1679      * For unparsed entities, this driver will invoke the
1680      * SAX DTDHandler::unparsedEntityDecl callback.
1681      *
1682      * @param entityDecl A const reference to the object containing
1683      *                   the entity declaration information.
1684      * @param isPEDecl  The flag indicating whether this was a
1685      *                  parameter entity declaration or not.
1686      * @param isIgnored The flag indicating whether this definition
1687      *                  was ignored by the parser or not.
1688      *
1689      * @see DTDHandler#unparsedEntityDecl
1690      */
1691    virtual void entityDecl
1692    (
1693        const   DTDEntityDecl&  entityDecl
1694        , const bool            isPEDecl
1695        , const bool            isIgnored
1696    );
1697
1698    /**
1699      * This method allows the user installed DTD handler to
1700      * reset itself.
1701      */
1702    virtual void resetDocType();
1703
1704    /**
1705      * This method is used to report any notation declarations.
1706      * If there is a user installed DTDHandler, then the driver will
1707      * invoke the SAX DTDHandler::notationDecl callback.
1708      *
1709      * @param notDecl A const reference to the object containing the notation
1710      *                declaration information.
1711      * @param isIgnored The flag indicating whether this definition was ignored
1712      *                  by the parser or not.
1713      *
1714      * @see DTDHandler#notationDecl
1715      */
1716    virtual void notationDecl
1717    (
1718        const   XMLNotationDecl&    notDecl
1719        , const bool                isIgnored
1720    );
1721
1722    /**
1723      * This method is used to indicate the start of an element's attribute
1724      * list declaration.
1725      *
1726      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1727      * implementation.</font></b>
1728      *
1729      * @param elemDecl A const reference to the object containing element
1730      *                 declaration information.
1731      */
1732    virtual void startAttList
1733    (
1734        const   DTDElementDecl& elemDecl
1735    );
1736
1737    /**
1738      * This method is used indicate the start of the internal subset.
1739      *
1740      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1741      * implementation.</font></b>
1742      */
1743    virtual void startIntSubset();
1744
1745    /**
1746      * This method is used indicate the start of the external subset.
1747      *
1748      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1749      * implementation.</font></b>
1750      */
1751    virtual void startExtSubset();
1752
1753    /**
1754      * This method is used to report the TextDecl. Refer to the XML
1755      * specification for the syntax of a TextDecl.
1756      *
1757      * <b><font color="#FF0000">This method is a no-op for this SAX driver
1758      * implementation.</font></b>
1759      *
1760      * @param versionStr A const pointer to a Unicode string representing
1761      *                   the version number of the 'version' clause.
1762      * @param encodingStr A const pointer to a Unicode string representing
1763      *                    the encoding name of the 'encoding' clause.
1764      */
1765    virtual void TextDecl
1766    (
1767        const   XMLCh* const    versionStr
1768        , const XMLCh* const    encodingStr
1769    );
1770    //@}
1771
1772
1773private :
1774    // -----------------------------------------------------------------------
1775    //  Unimplemented constructors and operators
1776    // -----------------------------------------------------------------------
1777    SAX2XMLReaderImpl(const SAX2XMLReaderImpl&);
1778    SAX2XMLReaderImpl& operator=(const SAX2XMLReaderImpl&);
1779
1780    // -----------------------------------------------------------------------
1781    //  Initialize/Cleanup methods
1782    // -----------------------------------------------------------------------
1783    void initialize();
1784    void cleanUp();
1785
1786    // -----------------------------------------------------------------------
1787    //  Private data members
1788    //
1789    //  fAttrList
1790    //      A temporary implementation of the basic SAX2 Attributes
1791    //      interface. We use this one over and over on each startElement
1792    //      event to allow SAX-like access to the element attributes.
1793    //
1794    //  fDocHandler
1795    //      The installed SAX content handler, if any. Null if none.
1796    //
1797    //  fnamespacePrefix
1798    //      Indicates whether the namespace-prefix feature is on or off.
1799    //
1800    //  fautoValidation
1801    //      Indicates whether automatic validation is on or off
1802    //
1803    //  fValidation
1804    //      Indicates whether the 'validation' core features is on or off
1805    //
1806    //  fReuseGrammar
1807    //      Tells the parser whether it should reuse the grammar or not.
1808    //      If true, there cannot be any internal subset.
1809    //
1810    //  fStringBuffers
1811    //          Any temporary strings we need are pulled out of this pool
1812    //
1813    //  fPrefixes
1814    //          A Stack of the current namespace prefixes that need calls to
1815    //          endPrefixMapping
1816    //
1817    //  fPrefixCounts
1818    //          A Stack of the number of prefixes that need endPrefixMapping
1819    //          calls for that element
1820    //
1821    //  fDTDHandler
1822    //      The installed SAX DTD handler, if any. Null if none.
1823    //
1824    //  fElemDepth
1825    //      This is used to track the element nesting depth, so that we can
1826    //      know when we are inside content. This is so we can ignore char
1827    //      data outside of content.
1828    //
1829    //  fEntityResolver
1830    //      The installed SAX entity handler, if any. Null if none.
1831    //
1832    //  fErrorHandler
1833    //      The installed SAX error handler, if any. Null if none.
1834    //
1835    //  fLexicalHandler
1836    //      The installed SAX lexical handler, if any.  Null if none.
1837    //
1838    //  fDecllHandler
1839    //      The installed SAX declaration handler, if any.  Null if none.
1840    //
1841    //  fAdvDHCount
1842    //  fAdvDHList
1843    //  fAdvDHListSize
1844    //      This is an array of pointers to XMLDocumentHandlers, which is
1845    //      how we see installed advanced document handlers. There will
1846    //      usually not be very many at all, so a simple array is used
1847    //      instead of a collection, for performance. It will grow if needed,
1848    //      but that is unlikely.
1849    //
1850    //      The count is how many handlers are currently installed. The size
1851    //      is how big the array itself is (for expansion purposes.) When
1852    //      count == size, is time to expand.
1853    //
1854    //  fParseInProgress
1855    //      This flag is set once a parse starts. It is used to prevent
1856    //      multiple entrance or reentrance of the parser.
1857    //
1858    //  fScanner
1859    //      The scanner being used by this parser. It is created internally
1860    //      during construction.
1861    //
1862    //  fHasExternalSubset
1863    //      Indicate if the document has external DTD subset.
1864    //
1865    //   fGrammarPool
1866    //      The grammar pool passed from external application (through derivatives).
1867    //      which could be 0, not owned.
1868    //
1869    // -----------------------------------------------------------------------
1870    bool                        fNamespacePrefix;
1871    bool                        fAutoValidation;
1872    bool                        fValidation;
1873    bool                        fParseInProgress;
1874    bool                        fHasExternalSubset;
1875    unsigned int                fElemDepth;
1876    unsigned int                fAdvDHCount;
1877    unsigned int                fAdvDHListSize;
1878    VecAttributesImpl               fAttrList ;
1879    ContentHandler*                     fDocHandler ;
1880    RefVectorOf<XMLAttr>*       fTempAttrVec ;
1881    RefStackOf<XMLBuffer> *     fPrefixes ;
1882    ValueStackOf<unsigned int>* fPrefixCounts ;
1883    DTDHandler*                 fDTDHandler;
1884    EntityResolver*             fEntityResolver;
1885    XMLEntityResolver*          fXMLEntityResolver;
1886    ErrorHandler*               fErrorHandler;
1887    PSVIHandler*                fPSVIHandler;
1888    LexicalHandler*             fLexicalHandler;
1889    DeclHandler*                fDeclHandler;
1890    XMLDocumentHandler**        fAdvDHList;
1891    XMLScanner*                 fScanner;
1892    GrammarResolver*            fGrammarResolver;
1893    XMLStringPool*              fURIStringPool;
1894    XMLValidator*               fValidator;
1895    MemoryManager*              fMemoryManager;
1896    XMLGrammarPool*             fGrammarPool;
1897    XMLBufferMgr                fStringBuffers;
1898       
1899    // -----------------------------------------------------------------------
1900    // internal function used to set the state of the parser
1901    // -----------------------------------------------------------------------
1902    void setValidationScheme(const ValSchemes newScheme);
1903    void setDoNamespaces(const bool newState);
1904    bool getDoNamespaces() const;
1905    void setDoSchema(const bool newState);
1906    bool getDoSchema() const;
1907};
1908
1909
1910// ---------------------------------------------------------------------------
1911//  SAX2XMLReader: Getter methods
1912// ---------------------------------------------------------------------------
1913inline ContentHandler* SAX2XMLReaderImpl::getContentHandler() const
1914{
1915    return fDocHandler;
1916}
1917
1918inline DTDHandler* SAX2XMLReaderImpl::getDTDHandler() const
1919{
1920        return fDTDHandler ;
1921}
1922
1923inline EntityResolver* SAX2XMLReaderImpl::getEntityResolver() const
1924{
1925        return fEntityResolver;
1926}
1927
1928inline XMLEntityResolver* SAX2XMLReaderImpl::getXMLEntityResolver() const
1929{
1930        return fXMLEntityResolver;
1931}
1932
1933inline ErrorHandler* SAX2XMLReaderImpl::getErrorHandler() const
1934{
1935        return fErrorHandler;
1936}
1937
1938inline PSVIHandler* SAX2XMLReaderImpl::getPSVIHandler() const
1939{
1940        return fPSVIHandler;
1941}
1942
1943inline LexicalHandler* SAX2XMLReaderImpl::getLexicalHandler() const
1944{
1945   return fLexicalHandler;
1946}
1947
1948inline DeclHandler* SAX2XMLReaderImpl::getDeclarationHandler() const
1949{
1950   return fDeclHandler;
1951}
1952
1953inline bool SAX2XMLReaderImpl::getExitOnFirstFatalError() const
1954{
1955    return fScanner->getExitOnFirstFatal();
1956}
1957
1958inline bool SAX2XMLReaderImpl::getValidationConstraintFatal() const
1959{
1960    return fScanner->getValidationConstraintFatal();
1961}
1962
1963inline Grammar* SAX2XMLReaderImpl::getRootGrammar()
1964{
1965    return fScanner->getRootGrammar();
1966}
1967
1968inline const XMLCh* SAX2XMLReaderImpl::getURIText(unsigned int uriId) const
1969{
1970    return fScanner->getURIText(uriId);
1971}
1972
1973inline unsigned int SAX2XMLReaderImpl::getSrcOffset() const
1974{
1975    return fScanner->getSrcOffset();
1976}
1977
1978XERCES_CPP_NAMESPACE_END
1979
1980#endif
Note: See TracBrowser for help on using the repository browser.