SAX2XMLReader.hpp Source File

| 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  * The Apache Software License, Version 1.1
    00003  *
    00004  * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    00005  * reserved.
    00006  *
    00007  * Redistribution and use in source and binary forms, with or without
    00008  * modification, are permitted provided that the following conditions
    00009  * are met:
    00010  *
    00011  * 1. Redistributions of source code must retain the above copyright
    00012  *    notice, this list of conditions and the following disclaimer.
    00013  *
    00014  * 2. Redistributions in binary form must reproduce the above copyright
    00015  *    notice, this list of conditions and the following disclaimer in
    00016  *    the documentation and/or other materials provided with the
    00017  *    distribution.
    00018  *
    00019  * 3. The end-user documentation included with the redistribution,
    00020  *    if any, must include the following acknowledgment:
    00021  *       "This product includes software developed by the
    00022  *        Apache Software Foundation (http://www.apache.org/)."
    00023  *    Alternately, this acknowledgment may appear in the software itself,
    00024  *    if and wherever such third-party acknowledgments normally appear.
    00025  *
    00026  * 4. The names "Xerces" and "Apache Software Foundation" must
    00027  *    not be used to endorse or promote products derived from this
    00028  *    software without prior written permission. For written
    00029  *    permission, please contact apache\@apache.org.
    00030  *
    00031  * 5. Products derived from this software may not be called "Apache",
    00032  *    nor may "Apache" appear in their name, without prior written
    00033  *    permission of the Apache Software Foundation.
    00034  *
    00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00046  * SUCH DAMAGE.
    00047  * ====================================================================
    00048  *
    00049  * This software consists of voluntary contributions made by many
    00050  * individuals on behalf of the Apache Software Foundation, and was
    00051  * originally based on software copyright (c) 1999, International
    00052  * Business Machines, Inc., http://www.ibm.com .  For more information
    00053  * on the Apache Software Foundation, please see
    00054  * <http://www.apache.org/>.
    00055  */
    00056
    00057 /*
    00058  * $Log: SAX2XMLReader.hpp,v $
    00059  * Revision 1.10  2003/03/07 18:10:30  tng
    00060  * Return a reference instead of void for operator=
    00061  *
    00062  * Revision 1.9  2003/01/09 19:07:27  tng
    00063  * [Bug 15802] Add "const" qualifier to getURIText.
    00064  *
    00065  * Revision 1.8  2002/12/23 15:23:18  knoaman
    00066  * Added a public api to various parsers to return the src offset within the input
    00067  * source.
    00068  *
    00069  * Revision 1.7  2002/11/04 14:55:45  tng
    00070  * C++ Namespace Support.
    00071  *
    00072  * Revision 1.6  2002/07/11 18:29:09  knoaman
    00073  * Grammar caching/preparsing - initial implementation.
    00074  *
    00075  * Revision 1.5  2002/07/04 15:35:44  tng
    00076  * API Documentation typo fix.
    00077  *
    00078  * Revision 1.4  2002/06/27 18:46:53  tng
    00079  * API Documentation Update.
    00080  *
    00081  * Revision 1.3  2002/06/17 15:39:49  tng
    00082  * To be consistent, SAX2 is updated with:
    00083  * 1. the progressive parse methods should use the fReuseGrammar flag set from setFeature instead of using parameter
    00084  * 2. add feature "http://apache.org/xml/features/continue-after-fatal-error", and users should use setFeature instead of setExitOnFirstFatalError
    00085  * 3. add feature "http://apache.org/xml/features/validation-error-as-fatal", and users should use setFeature instead of setValidationConstraintFatal
    00086  *
    00087  * Revision 1.2  2002/05/30 16:22:53  tng
    00088  * Add feature to optionally ignore external DTD.
    00089  *
    00090  * Revision 1.1.1.1  2002/02/01 22:22:09  peiyongz
    00091  * sane_include
    00092  *
    00093  * Revision 1.18  2002/01/28 18:45:40  knoaman
    00094  * Update documentation for SAX2 feature 'namespace-prefixes'.
    00095  *
    00096  * Revision 1.17  2002/01/28 17:08:33  knoaman
    00097  * SAX2-ext's DeclHandler support.
    00098  *
    00099  * Revision 1.16  2002/01/18 16:31:26  tng
    00100  * Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml, program-dom.xml, program-idom.xml.
    00101  *
    00102  * Revision 1.15  2002/01/02 15:36:54  tng
    00103  * Some documentation update.
    00104  *
    00105  * Revision 1.14  2001/11/20 18:51:44  tng
    00106  * 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).
    00107  *
    00108  * Revision 1.13  2001/11/14 14:15:59  tng
    00109  * Update SAX2 feature documentation.
    00110  *
    00111  * Revision 1.12  2001/09/12 13:03:43  tng
    00112  * [Bug 3155] SAX2 does not offer progressive parse.
    00113  *
    00114  * Revision 1.11  2001/08/01 19:11:02  tng
    00115  * Add full schema constraint checking flag to the samples and the parser.
    00116  *
    00117  * Revision 1.10  2001/06/27 17:40:16  knoaman
    00118  * Fix for bug #2353.
    00119  *
    00120  * Revision 1.9  2001/06/19 16:44:31  tng
    00121  * Add installAdvDocHandler to SAX2XMLReader as the code is there already.
    00122  *
    00123  * Revision 1.8  2001/06/04 21:03:07  jberry
    00124  * Add pure virtual getErrorCount to SAX2XMLReader interface.
    00125  *
    00126  * Revision 1.7  2001/05/11 13:26:25  tng
    00127  * Copyright update.
    00128  *
    00129  * Revision 1.6  2001/02/15 15:56:31  tng
    00130  * Schema: Add setSchemaValidation and getSchemaValidation for DOMParser and SAXParser.
    00131  * Add feature "http://apache.org/xml/features/validation/schema" for SAX2XMLReader.
    00132  * New data field  fSchemaValidation in XMLScanner as the flag.
    00133  *
    00134  * Revision 1.5  2001/01/12 21:22:00  tng
    00135  * Documentation Enhancement: Add list of SAX2 feature strings that are supported.
    00136  *
    00137  * Revision 1.4  2000/12/22 15:17:04  tng
    00138  * SAX2-ext's LexicalHandler support added by David Bertoni.
    00139  *
    00140  * Revision 1.3  2000/08/09 22:19:29  jpolast
    00141  * many conformance & stability changes:
    00142  *   - ContentHandler::resetDocument() removed
    00143  *   - attrs param of ContentHandler::startDocument() made const
    00144  *   - SAXExceptions thrown now have msgs
    00145  *   - removed duplicate function signatures that had 'const'
    00146  *       [ eg: getContentHander() ]
    00147  *   - changed getFeature and getProperty to apply to const objs
    00148  *   - setProperty now takes a void* instead of const void*
    00149  *   - SAX2XMLReaderImpl does not inherit from SAXParser anymore
    00150  *   - Reuse Validator (http://apache.org/xml/features/reuse-validator) implemented
    00151  *   - Features & Properties now read-only during parse
    00152  *
    00153  * Revision 1.2  2000/08/07 18:21:27  jpolast
    00154  * change  module to
    00155  *
    00156  * Revision 1.1  2000/08/02 18:02:35  jpolast
    00157  * initial checkin of sax2 implementation
    00158  * submitted by Simon Fell (simon@fell.com)
    00159  * and Joe Polastre (jpolast@apache.org)
    00160  *
    00161  *
    00162  */
    00163
    00164 #ifndef SAX2XMLReader_HPP
    00165 #define SAX2XMLReader_HPP
    00166
    00167 #include <xercesc/util/XercesDefs.hpp>
    00168 #include <xercesc/util/XMLUniDefs.hpp>
    00169 #include <xercesc/framework/XMLValidator.hpp>
    00170 #include <xercesc/framework/XMLPScanToken.hpp>
    00171
    00172 XERCES_CPP_NAMESPACE_BEGIN
    00173
    00174 class ContentHandler ;
    00175 class DTDHandler;
    00176 class EntityResolver;
    00177 class ErrorHandler;
    00178 class InputSource;
    00179 class LexicalHandler;
    00180 class DeclHandler;
    00181 class XMLDocumentHandler;
    00182 class Grammar;
    00183
    00184 class  SAX2XMLReader
    00185 {
    00186 public:
    00187     // -----------------------------------------------------------------------
    00188     //  Class types
    00189     // -----------------------------------------------------------------------
    00192
    00200     enum ValSchemes
    00201     {
    00202         Val_Never
    00203         , Val_Always
    00204         , Val_Auto
    00205     };
    00207
    00208
    00209     // -----------------------------------------------------------------------
    00210     //  Constructors and Destructor
    00211     // -----------------------------------------------------------------------
    00215     SAX2XMLReader()
    00216     {
    00217     }
    00219     virtual ~SAX2XMLReader()
    00220     {
    00221     }
    00223
    00224     //-----------------------------------------------------------------------
    00225     // The XMLReader interface
    00226     //-----------------------------------------------------------------------
    00229
    00235     virtual ContentHandler* getContentHandler() const = 0 ;
    00236
    00242     virtual DTDHandler* getDTDHandler() const = 0;
    00243
    00249     virtual EntityResolver* getEntityResolver() const = 0 ;
    00250
    00256     virtual ErrorHandler* getErrorHandler() const = 0 ;
    00257
    00265     virtual bool getFeature(const XMLCh* const name) const = 0;
    00266
    00286     virtual void* getProperty(const XMLCh* const name) const = 0 ;
    00287
    00304     virtual void setContentHandler(ContentHandler* const handler) = 0;
    00305
    00321     virtual void setDTDHandler(DTDHandler* const handler) = 0;
    00322
    00339     virtual void setEntityResolver(EntityResolver* const resolver) = 0;
    00340
    00358     virtual void setErrorHandler(ErrorHandler* const handler) = 0;
    00359
    00383     virtual void setFeature(const XMLCh* const name, const bool value) = 0;
    00384
    00408     virtual void setProperty(const XMLCh* const name, void* value) = 0 ;
    00409
    00435     virtual void parse
    00436     (
    00437         const   InputSource&    source
    00438     ) = 0;
    00439
    00459     virtual void parse
    00460     (
    00461         const   XMLCh* const    systemId
    00462     ) = 0;
    00463
    00483     virtual void parse
    00484     (
    00485         const   char* const     systemId
    00486     ) = 0;
    00487
    00489
    00490     // -----------------------------------------------------------------------
    00491     //  SAX 2.0-ext
    00492     // -----------------------------------------------------------------------
    00500     virtual DeclHandler* getDeclarationHandler() const = 0 ;
    00501
    00507     virtual LexicalHandler* getLexicalHandler() const = 0 ;
    00508
    00525     virtual void setDeclarationHandler(DeclHandler* const handler) = 0;
    00526
    00543     virtual void setLexicalHandler(LexicalHandler* const handler) = 0;
    00544
    00546
    00547     // -----------------------------------------------------------------------
    00548     //  Getter Methods
    00549     // -----------------------------------------------------------------------
    00562     virtual XMLValidator* getValidator() const = 0;
    00563
    00574     virtual int getErrorCount() const = 0 ;
    00575
    00589     virtual bool getExitOnFirstFatalError() const = 0;
    00590
    00605     virtual bool getValidationConstraintFatal() const = 0;
    00606
    00613     virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) = 0;
    00614
    00620     virtual Grammar* getRootGrammar() = 0;
    00621
    00628     virtual const XMLCh* getURIText(unsigned int uriId) const = 0;
    00629
    00635     virtual unsigned int getSrcOffset() const = 0;
    00636
    00638
    00639     // -----------------------------------------------------------------------
    00640     //  Setter Methods
    00641     // -----------------------------------------------------------------------
    00653     virtual void setValidator(XMLValidator* valueToAdopt) = 0;
    00654
    00676     virtual void setExitOnFirstFatalError(const bool newState) = 0;
    00677
    00703     virtual void setValidationConstraintFatal(const bool newState) = 0;
    00705
    00706
    00707     // -----------------------------------------------------------------------
    00708     //  Progressive scan methods
    00709     // -----------------------------------------------------------------------
    00710
    00713
    00741     virtual bool parseFirst
    00742     (
    00743         const   XMLCh* const    systemId
    00744         ,       XMLPScanToken&  toFill
    00745     ) = 0;
    00746
    00774     virtual bool parseFirst
    00775     (
    00776         const   char* const     systemId
    00777         ,       XMLPScanToken&  toFill
    00778     ) = 0;
    00779
    00807     virtual bool parseFirst
    00808     (
    00809         const   InputSource&    source
    00810         ,       XMLPScanToken&  toFill
    00811     ) = 0;
    00812
    00837     virtual bool parseNext(XMLPScanToken& token) = 0;
    00838
    00860     virtual void parseReset(XMLPScanToken& token) = 0;
    00861
    00863
    00864     // -----------------------------------------------------------------------
    00865     //  Grammar preparsing interface
    00866     // -----------------------------------------------------------------------
    00867
    00897     virtual Grammar* loadGrammar(const InputSource& source,
    00898                                  const short grammarType,
    00899                                  const bool toCache = false) = 0;
    00900
    00926     virtual Grammar* loadGrammar(const XMLCh* const systemId,
    00927                                  const short grammarType,
    00928                                  const bool toCache = false) = 0;
    00929
    00954     virtual Grammar* loadGrammar(const char* const systemId,
    00955                                  const short grammarType,
    00956                                  const bool toCache = false) = 0;
    00957
    00961     virtual void resetCachedGrammarPool() = 0;
    00962
    00964
    00965
    00966     // -----------------------------------------------------------------------
    00967     //  Advanced document handler list maintenance methods
    00968     // -----------------------------------------------------------------------
    00969
    00985     virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) = 0;
    00986
    00996     virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) = 0;
    00998
    00999 private :
    01000     /* The copy constructor, you cannot call this directly */
    01001     SAX2XMLReader(const SAX2XMLReader&);
    01002
    01003     /* The assignment operator, you cannot call this directly */
    01004     SAX2XMLReader& operator=(const SAX2XMLReader&);
    01005
    01006 };
    01007
    01008 XERCES_CPP_NAMESPACE_END
    01009
    01010 #endif

Copyright © 2000 The Apache Software Foundation. All Rights Reserved.