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  * 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.9  2003/01/09 19:07:27  tng
00060  * [Bug 15802] Add "const" qualifier to getURIText.
00061  *
00062  * Revision 1.8  2002/12/23 15:23:18  knoaman
00063  * Added a public api to various parsers to return the src offset within the input
00064  * source.
00065  *
00066  * Revision 1.7  2002/11/04 14:55:45  tng
00067  * C++ Namespace Support.
00068  *
00069  * Revision 1.6  2002/07/11 18:29:09  knoaman
00070  * Grammar caching/preparsing - initial implementation.
00071  *
00072  * Revision 1.5  2002/07/04 15:35:44  tng
00073  * API Documentation typo fix.
00074  *
00075  * Revision 1.4  2002/06/27 18:46:53  tng
00076  * API Documentation Update.
00077  *
00078  * Revision 1.3  2002/06/17 15:39:49  tng
00079  * To be consistent, SAX2 is updated with:
00080  * 1. the progressive parse methods should use the fReuseGrammar flag set from setFeature instead of using parameter
00081  * 2. add feature "http://apache.org/xml/features/continue-after-fatal-error", and users should use setFeature instead of setExitOnFirstFatalError
00082  * 3. add feature "http://apache.org/xml/features/validation-error-as-fatal", and users should use setFeature instead of setValidationConstraintFatal
00083  *
00084  * Revision 1.2  2002/05/30 16:22:53  tng
00085  * Add feature to optionally ignore external DTD.
00086  *
00087  * Revision 1.1.1.1  2002/02/01 22:22:09  peiyongz
00088  * sane_include
00089  *
00090  * Revision 1.18  2002/01/28 18:45:40  knoaman
00091  * Update documentation for SAX2 feature 'namespace-prefixes'.
00092  *
00093  * Revision 1.17  2002/01/28 17:08:33  knoaman
00094  * SAX2-ext's DeclHandler support.
00095  *
00096  * Revision 1.16  2002/01/18 16:31:26  tng
00097  * Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml, program-dom.xml, program-idom.xml.
00098  *
00099  * Revision 1.15  2002/01/02 15:36:54  tng
00100  * Some documentation update.
00101  *
00102  * Revision 1.14  2001/11/20 18:51:44  tng
00103  * 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).
00104  *
00105  * Revision 1.13  2001/11/14 14:15:59  tng
00106  * Update SAX2 feature documentation.
00107  *
00108  * Revision 1.12  2001/09/12 13:03:43  tng
00109  * [Bug 3155] SAX2 does not offer progressive parse.
00110  *
00111  * Revision 1.11  2001/08/01 19:11:02  tng
00112  * Add full schema constraint checking flag to the samples and the parser.
00113  *
00114  * Revision 1.10  2001/06/27 17:40:16  knoaman
00115  * Fix for bug #2353.
00116  *
00117  * Revision 1.9  2001/06/19 16:44:31  tng
00118  * Add installAdvDocHandler to SAX2XMLReader as the code is there already.
00119  *
00120  * Revision 1.8  2001/06/04 21:03:07  jberry
00121  * Add pure virtual getErrorCount to SAX2XMLReader interface.
00122  *
00123  * Revision 1.7  2001/05/11 13:26:25  tng
00124  * Copyright update.
00125  *
00126  * Revision 1.6  2001/02/15 15:56:31  tng
00127  * Schema: Add setSchemaValidation and getSchemaValidation for DOMParser and SAXParser.
00128  * Add feature "http://apache.org/xml/features/validation/schema" for SAX2XMLReader.
00129  * New data field  fSchemaValidation in XMLScanner as the flag.
00130  *
00131  * Revision 1.5  2001/01/12 21:22:00  tng
00132  * Documentation Enhancement: Add list of SAX2 feature strings that are supported.
00133  *
00134  * Revision 1.4  2000/12/22 15:17:04  tng
00135  * SAX2-ext's LexicalHandler support added by David Bertoni.
00136  *
00137  * Revision 1.3  2000/08/09 22:19:29  jpolast
00138  * many conformance & stability changes:
00139  *   - ContentHandler::resetDocument() removed
00140  *   - attrs param of ContentHandler::startDocument() made const
00141  *   - SAXExceptions thrown now have msgs
00142  *   - removed duplicate function signatures that had 'const'
00143  *       [ eg: getContentHander() ]
00144  *   - changed getFeature and getProperty to apply to const objs
00145  *   - setProperty now takes a void* instead of const void*
00146  *   - SAX2XMLReaderImpl does not inherit from SAXParser anymore
00147  *   - Reuse Validator (http://apache.org/xml/features/reuse-validator) implemented
00148  *   - Features & Properties now read-only during parse
00149  *
00150  * Revision 1.2  2000/08/07 18:21:27  jpolast
00151  * change  module to 
00152  *
00153  * Revision 1.1  2000/08/02 18:02:35  jpolast
00154  * initial checkin of sax2 implementation
00155  * submitted by Simon Fell (simon@fell.com)
00156  * and Joe Polastre (jpolast@apache.org)
00157  *
00158  *
00159  */
00160 
00161 #ifndef SAX2XMLReader_HPP
00162 #define SAX2XMLReader_HPP
00163 
00164 #include <xercesc/util/XercesDefs.hpp>
00165 #include <xercesc/util/XMLUniDefs.hpp>
00166 #include <xercesc/framework/XMLValidator.hpp>
00167 #include <xercesc/framework/XMLPScanToken.hpp>
00168 
00169 XERCES_CPP_NAMESPACE_BEGIN
00170 
00171 class ContentHandler ;
00172 class DTDHandler;
00173 class EntityResolver;
00174 class ErrorHandler;
00175 class InputSource;
00176 class LexicalHandler;
00177 class DeclHandler;
00178 class XMLDocumentHandler;
00179 class Grammar;
00180 
00181 class  SAX2XMLReader
00182 {
00183 public:
00184     // -----------------------------------------------------------------------
00185     //  Class types
00186     // -----------------------------------------------------------------------
00189 
00197     enum ValSchemes
00198     {
00199         Val_Never
00200         , Val_Always
00201         , Val_Auto
00202     };
00204 
00205 
00206     // -----------------------------------------------------------------------
00207     //  Constructors and Destructor
00208     // -----------------------------------------------------------------------
00212     SAX2XMLReader()
00213     {
00214     }
00216     virtual ~SAX2XMLReader()
00217     {
00218     }
00220 
00221     //-----------------------------------------------------------------------
00222     // The XMLReader interface
00223     //-----------------------------------------------------------------------
00226 
00232     virtual ContentHandler* getContentHandler() const = 0 ;
00233 
00239     virtual DTDHandler* getDTDHandler() const = 0;
00240 
00246     virtual EntityResolver* getEntityResolver() const = 0 ;
00247 
00253     virtual ErrorHandler* getErrorHandler() const = 0 ;
00254 
00262     virtual bool getFeature(const XMLCh* const name) const = 0;
00263 
00283     virtual void* getProperty(const XMLCh* const name) const = 0 ;
00284 
00301     virtual void setContentHandler(ContentHandler* const handler) = 0;
00302 
00318     virtual void setDTDHandler(DTDHandler* const handler) = 0;
00319 
00336     virtual void setEntityResolver(EntityResolver* const resolver) = 0;
00337 
00355     virtual void setErrorHandler(ErrorHandler* const handler) = 0;
00356 
00380     virtual void setFeature(const XMLCh* const name, const bool value) = 0;
00381 
00405     virtual void setProperty(const XMLCh* const name, void* value) = 0 ;
00406 
00432     virtual void parse
00433     (
00434         const   InputSource&    source
00435     ) = 0;
00436 
00456     virtual void parse
00457     (
00458         const   XMLCh* const    systemId
00459     ) = 0;
00460 
00480     virtual void parse
00481     (
00482         const   char* const     systemId
00483     ) = 0;
00484     
00486 
00487     // -----------------------------------------------------------------------
00488     //  SAX 2.0-ext
00489     // -----------------------------------------------------------------------
00497     virtual DeclHandler* getDeclarationHandler() const = 0 ;
00498 
00504     virtual LexicalHandler* getLexicalHandler() const = 0 ;
00505 
00522     virtual void setDeclarationHandler(DeclHandler* const handler) = 0;
00523 
00540     virtual void setLexicalHandler(LexicalHandler* const handler) = 0;
00541 
00543 
00544     // -----------------------------------------------------------------------
00545     //  Getter Methods
00546     // -----------------------------------------------------------------------
00559     virtual XMLValidator* getValidator() const = 0;
00560 
00571     virtual int getErrorCount() const = 0 ;
00572 
00586     virtual bool getExitOnFirstFatalError() const = 0;
00587 
00602     virtual bool getValidationConstraintFatal() const = 0;
00603 
00610     virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) = 0;
00611 
00617     virtual Grammar* getRootGrammar() = 0;
00618 
00625     virtual const XMLCh* getURIText(unsigned int uriId) const = 0;
00626 
00632     virtual unsigned int getSrcOffset() const = 0;
00633 
00635 
00636     // -----------------------------------------------------------------------
00637     //  Setter Methods
00638     // -----------------------------------------------------------------------
00650     virtual void setValidator(XMLValidator* valueToAdopt) = 0;
00651 
00673     virtual void setExitOnFirstFatalError(const bool newState) = 0;
00674 
00700     virtual void setValidationConstraintFatal(const bool newState) = 0;
00702 
00703 
00704     // -----------------------------------------------------------------------
00705     //  Progressive scan methods
00706     // -----------------------------------------------------------------------
00707 
00710 
00738     virtual bool parseFirst
00739     (
00740         const   XMLCh* const    systemId
00741         ,       XMLPScanToken&  toFill
00742     ) = 0;
00743 
00771     virtual bool parseFirst
00772     (
00773         const   char* const     systemId
00774         ,       XMLPScanToken&  toFill
00775     ) = 0;
00776 
00804     virtual bool parseFirst
00805     (
00806         const   InputSource&    source
00807         ,       XMLPScanToken&  toFill
00808     ) = 0;
00809 
00834     virtual bool parseNext(XMLPScanToken& token) = 0;
00835 
00857     virtual void parseReset(XMLPScanToken& token) = 0;
00858 
00860 
00861     // -----------------------------------------------------------------------
00862     //  Grammar preparsing interface
00863     // -----------------------------------------------------------------------
00864 
00894     virtual Grammar* loadGrammar(const InputSource& source,
00895                                  const short grammarType,
00896                                  const bool toCache = false) = 0;
00897 
00923     virtual Grammar* loadGrammar(const XMLCh* const systemId,
00924                                  const short grammarType,
00925                                  const bool toCache = false) = 0;
00926 
00951     virtual Grammar* loadGrammar(const char* const systemId,
00952                                  const short grammarType,
00953                                  const bool toCache = false) = 0;
00954 
00958     virtual void resetCachedGrammarPool() = 0;
00959 
00961 
00962 
00963     // -----------------------------------------------------------------------
00964     //  Advanced document handler list maintenance methods
00965     // -----------------------------------------------------------------------
00966 
00982     virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) = 0;
00983 
00993     virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) = 0;
00995 
00996 private :
00997     /* The copy constructor, you cannot call this directly */
00998     SAX2XMLReader(const SAX2XMLReader&);
00999 
01000     /* The assignment operator, you cannot call this directly */
01001     void operator=(const SAX2XMLReader&);
01002 
01003 };
01004 
01005 XERCES_CPP_NAMESPACE_END
01006 
01007 #endif


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