http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

SAX2XMLReader.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2001,2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * $Log: SAX2XMLReader.hpp,v $
00019  * Revision 1.12  2004/09/30 14:07:43  peiyongz
00020  * setInputBufferSize
00021  *
00022  * Revision 1.11  2004/09/08 13:56:20  peiyongz
00023  * Apache License Version 2.0
00024  *
00025  * Revision 1.10  2003/03/07 18:10:30  tng
00026  * Return a reference instead of void for operator=
00027  *
00028  * Revision 1.9  2003/01/09 19:07:27  tng
00029  * [Bug 15802] Add "const" qualifier to getURIText.
00030  *
00031  * Revision 1.8  2002/12/23 15:23:18  knoaman
00032  * Added a public api to various parsers to return the src offset within the input
00033  * source.
00034  *
00035  * Revision 1.7  2002/11/04 14:55:45  tng
00036  * C++ Namespace Support.
00037  *
00038  * Revision 1.6  2002/07/11 18:29:09  knoaman
00039  * Grammar caching/preparsing - initial implementation.
00040  *
00041  * Revision 1.5  2002/07/04 15:35:44  tng
00042  * API Documentation typo fix.
00043  *
00044  * Revision 1.4  2002/06/27 18:46:53  tng
00045  * API Documentation Update.
00046  *
00047  * Revision 1.3  2002/06/17 15:39:49  tng
00048  * To be consistent, SAX2 is updated with:
00049  * 1. the progressive parse methods should use the fReuseGrammar flag set from setFeature instead of using parameter
00050  * 2. add feature "http://apache.org/xml/features/continue-after-fatal-error", and users should use setFeature instead of setExitOnFirstFatalError
00051  * 3. add feature "http://apache.org/xml/features/validation-error-as-fatal", and users should use setFeature instead of setValidationConstraintFatal
00052  *
00053  * Revision 1.2  2002/05/30 16:22:53  tng
00054  * Add feature to optionally ignore external DTD.
00055  *
00056  * Revision 1.1.1.1  2002/02/01 22:22:09  peiyongz
00057  * sane_include
00058  *
00059  * Revision 1.18  2002/01/28 18:45:40  knoaman
00060  * Update documentation for SAX2 feature 'namespace-prefixes'.
00061  *
00062  * Revision 1.17  2002/01/28 17:08:33  knoaman
00063  * SAX2-ext's DeclHandler support.
00064  *
00065  * Revision 1.16  2002/01/18 16:31:26  tng
00066  * Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml, program-dom.xml, program-idom.xml.
00067  *
00068  * Revision 1.15  2002/01/02 15:36:54  tng
00069  * Some documentation update.
00070  *
00071  * Revision 1.14  2001/11/20 18:51:44  tng
00072  * 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).
00073  *
00074  * Revision 1.13  2001/11/14 14:15:59  tng
00075  * Update SAX2 feature documentation.
00076  *
00077  * Revision 1.12  2001/09/12 13:03:43  tng
00078  * [Bug 3155] SAX2 does not offer progressive parse.
00079  *
00080  * Revision 1.11  2001/08/01 19:11:02  tng
00081  * Add full schema constraint checking flag to the samples and the parser.
00082  *
00083  * Revision 1.10  2001/06/27 17:40:16  knoaman
00084  * Fix for bug #2353.
00085  *
00086  * Revision 1.9  2001/06/19 16:44:31  tng
00087  * Add installAdvDocHandler to SAX2XMLReader as the code is there already.
00088  *
00089  * Revision 1.8  2001/06/04 21:03:07  jberry
00090  * Add pure virtual getErrorCount to SAX2XMLReader interface.
00091  *
00092  * Revision 1.7  2001/05/11 13:26:25  tng
00093  * Copyright update.
00094  *
00095  * Revision 1.6  2001/02/15 15:56:31  tng
00096  * Schema: Add setSchemaValidation and getSchemaValidation for DOMParser and SAXParser.
00097  * Add feature "http://apache.org/xml/features/validation/schema" for SAX2XMLReader.
00098  * New data field  fSchemaValidation in XMLScanner as the flag.
00099  *
00100  * Revision 1.5  2001/01/12 21:22:00  tng
00101  * Documentation Enhancement: Add list of SAX2 feature strings that are supported.
00102  *
00103  * Revision 1.4  2000/12/22 15:17:04  tng
00104  * SAX2-ext's LexicalHandler support added by David Bertoni.
00105  *
00106  * Revision 1.3  2000/08/09 22:19:29  jpolast
00107  * many conformance & stability changes:
00108  *   - ContentHandler::resetDocument() removed
00109  *   - attrs param of ContentHandler::startDocument() made const
00110  *   - SAXExceptions thrown now have msgs
00111  *   - removed duplicate function signatures that had 'const'
00112  *       [ eg: getContentHander() ]
00113  *   - changed getFeature and getProperty to apply to const objs
00114  *   - setProperty now takes a void* instead of const void*
00115  *   - SAX2XMLReaderImpl does not inherit from SAXParser anymore
00116  *   - Reuse Validator (http://apache.org/xml/features/reuse-validator) implemented
00117  *   - Features & Properties now read-only during parse
00118  *
00119  * Revision 1.2  2000/08/07 18:21:27  jpolast
00120  * change  module to 
00121  *
00122  * Revision 1.1  2000/08/02 18:02:35  jpolast
00123  * initial checkin of sax2 implementation
00124  * submitted by Simon Fell (simon@fell.com)
00125  * and Joe Polastre (jpolast@apache.org)
00126  *
00127  *
00128  */
00129 
00130 #ifndef SAX2XMLReader_HPP
00131 #define SAX2XMLReader_HPP
00132 
00133 #include <xercesc/util/XercesDefs.hpp>
00134 #include <xercesc/util/XMLUniDefs.hpp>
00135 #include <xercesc/framework/XMLValidator.hpp>
00136 #include <xercesc/framework/XMLPScanToken.hpp>
00137 
00138 XERCES_CPP_NAMESPACE_BEGIN
00139 
00140 class ContentHandler ;
00141 class DTDHandler;
00142 class EntityResolver;
00143 class ErrorHandler;
00144 class InputSource;
00145 class LexicalHandler;
00146 class DeclHandler;
00147 class XMLDocumentHandler;
00148 class Grammar;
00149 
00150 class  SAX2XMLReader
00151 {
00152 public:
00153     // -----------------------------------------------------------------------
00154     //  Class types
00155     // -----------------------------------------------------------------------
00158 
00166     enum ValSchemes
00167     {
00168         Val_Never
00169         , Val_Always
00170         , Val_Auto
00171     };
00173 
00174 
00175     // -----------------------------------------------------------------------
00176     //  Constructors and Destructor
00177     // -----------------------------------------------------------------------
00181     SAX2XMLReader()
00182     {
00183     }
00185     virtual ~SAX2XMLReader()
00186     {
00187     }
00189 
00190     //-----------------------------------------------------------------------
00191     // The XMLReader interface
00192     //-----------------------------------------------------------------------
00195 
00201     virtual ContentHandler* getContentHandler() const = 0 ;
00202 
00208     virtual DTDHandler* getDTDHandler() const = 0;
00209 
00215     virtual EntityResolver* getEntityResolver() const = 0 ;
00216 
00222     virtual ErrorHandler* getErrorHandler() const = 0 ;
00223 
00231     virtual bool getFeature(const XMLCh* const name) const = 0;
00232 
00252     virtual void* getProperty(const XMLCh* const name) const = 0 ;
00253 
00270     virtual void setContentHandler(ContentHandler* const handler) = 0;
00271 
00287     virtual void setDTDHandler(DTDHandler* const handler) = 0;
00288 
00305     virtual void setEntityResolver(EntityResolver* const resolver) = 0;
00306 
00324     virtual void setErrorHandler(ErrorHandler* const handler) = 0;
00325 
00349     virtual void setFeature(const XMLCh* const name, const bool value) = 0;
00350 
00374     virtual void setProperty(const XMLCh* const name, void* value) = 0 ;
00375 
00401     virtual void parse
00402     (
00403         const   InputSource&    source
00404     ) = 0;
00405 
00425     virtual void parse
00426     (
00427         const   XMLCh* const    systemId
00428     ) = 0;
00429 
00449     virtual void parse
00450     (
00451         const   char* const     systemId
00452     ) = 0;
00453     
00455 
00456     // -----------------------------------------------------------------------
00457     //  SAX 2.0-ext
00458     // -----------------------------------------------------------------------
00466     virtual DeclHandler* getDeclarationHandler() const = 0 ;
00467 
00473     virtual LexicalHandler* getLexicalHandler() const = 0 ;
00474 
00491     virtual void setDeclarationHandler(DeclHandler* const handler) = 0;
00492 
00509     virtual void setLexicalHandler(LexicalHandler* const handler) = 0;
00510 
00512 
00513     // -----------------------------------------------------------------------
00514     //  Getter Methods
00515     // -----------------------------------------------------------------------
00528     virtual XMLValidator* getValidator() const = 0;
00529 
00540     virtual int getErrorCount() const = 0 ;
00541 
00555     virtual bool getExitOnFirstFatalError() const = 0;
00556 
00571     virtual bool getValidationConstraintFatal() const = 0;
00572 
00579     virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) = 0;
00580 
00586     virtual Grammar* getRootGrammar() = 0;
00587 
00594     virtual const XMLCh* getURIText(unsigned int uriId) const = 0;
00595 
00601     virtual unsigned int getSrcOffset() const = 0;
00602 
00604 
00605     // -----------------------------------------------------------------------
00606     //  Setter Methods
00607     // -----------------------------------------------------------------------
00619     virtual void setValidator(XMLValidator* valueToAdopt) = 0;
00620 
00642     virtual void setExitOnFirstFatalError(const bool newState) = 0;
00643 
00669     virtual void setValidationConstraintFatal(const bool newState) = 0;
00671 
00672 
00673     // -----------------------------------------------------------------------
00674     //  Progressive scan methods
00675     // -----------------------------------------------------------------------
00676 
00679 
00707     virtual bool parseFirst
00708     (
00709         const   XMLCh* const    systemId
00710         ,       XMLPScanToken&  toFill
00711     ) = 0;
00712 
00740     virtual bool parseFirst
00741     (
00742         const   char* const     systemId
00743         ,       XMLPScanToken&  toFill
00744     ) = 0;
00745 
00773     virtual bool parseFirst
00774     (
00775         const   InputSource&    source
00776         ,       XMLPScanToken&  toFill
00777     ) = 0;
00778 
00803     virtual bool parseNext(XMLPScanToken& token) = 0;
00804 
00826     virtual void parseReset(XMLPScanToken& token) = 0;
00827 
00829 
00830     // -----------------------------------------------------------------------
00831     //  Grammar preparsing interface
00832     // -----------------------------------------------------------------------
00833 
00863     virtual Grammar* loadGrammar(const InputSource& source,
00864                                  const short grammarType,
00865                                  const bool toCache = false) = 0;
00866 
00892     virtual Grammar* loadGrammar(const XMLCh* const systemId,
00893                                  const short grammarType,
00894                                  const bool toCache = false) = 0;
00895 
00920     virtual Grammar* loadGrammar(const char* const systemId,
00921                                  const short grammarType,
00922                                  const bool toCache = false) = 0;
00923 
00927     virtual void resetCachedGrammarPool() = 0;
00928 
00939     void setInputBufferSize(const size_t bufferSize) {};
00940 
00942 
00943 
00944     // -----------------------------------------------------------------------
00945     //  Advanced document handler list maintenance methods
00946     // -----------------------------------------------------------------------
00947 
00963     virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) = 0;
00964 
00974     virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) = 0;
00976 
00977 private :
00978     /* The copy constructor, you cannot call this directly */
00979     SAX2XMLReader(const SAX2XMLReader&);
00980 
00981     /* The assignment operator, you cannot call this directly */
00982     SAX2XMLReader& operator=(const SAX2XMLReader&);
00983 
00984 };
00985 
00986 XERCES_CPP_NAMESPACE_END
00987 
00988 #endif


Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.