📄 saxparser.hpp
字号:
/* * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Xerces" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact apache\@apache.org. * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation, and was * originally based on software copyright (c) 1999, International * Business Machines, Inc., http://www.ibm.com . For more information * on the Apache Software Foundation, please see * <http://www.apache.org/>. *//* * $Log: SAXParser.hpp,v $ * Revision 1.28 2003/12/01 23:23:26 neilg * fix for bug 25118; thanks to Jeroen Witmond * * Revision 1.27 2003/11/06 15:30:07 neilg * 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. * * Revision 1.26 2003/10/30 21:37:31 knoaman * Enhanced Entity Resolver Support. Thanks to David Cargill. * * Revision 1.25 2003/10/20 13:41:10 amassari * Added getGrammarResolver API * * Revision 1.24 2003/06/20 18:55:54 peiyongz * Stateless Grammar Pool :: Part I * * Revision 1.23 2003/05/15 18:26:50 knoaman * Partial implementation of the configurable memory manager. * * Revision 1.22 2003/04/17 21:58:50 neilg * Adding a new property, * http://apache.org/xml/properties/security-manager, with * appropriate getSecurityManager/setSecurityManager methods on DOM * and SAX parsers. Also adding a new SecurityManager class. * * The purpose of these modifications is to permit applications a * means to have the parser reject documents whose processing would * otherwise consume large amounts of system resources. Malicious * use of such documents could be used to launch a denial-of-service * attack against a system running the parser. Initially, the * SecurityManager only knows about attacks that can result from * exponential entity expansion; this is the only known attack that * involves processing a single XML document. Other, simlar attacks * can be launched if arbitrary schemas may be parsed; there already * exist means (via use of the EntityResolver interface) by which * applications can deny processing of untrusted schemas. In future, * the SecurityManager will be expanded to take these other exploits * into account. * * Add support for the SecurityManager * * Revision 1.21 2003/03/07 18:09:17 tng * Return a reference instead of void for operator= * * Revision 1.20 2003/02/04 19:27:43 knoaman * Performance: use global buffer to eliminate repetitive memory creation/deletion. * * Revision 1.19 2003/01/09 19:07:08 tng * [Bug 15802] Add "const" qualifier to getURIText. * * Revision 1.18 2003/01/03 20:09:36 tng * New feature StandardUriConformant to force strict standard uri conformance. * * Revision 1.17 2002/12/30 20:15:51 knoaman * Make calculate src offset option false by default. * * Revision 1.16 2002/12/23 15:23:18 knoaman * Added a public api to various parsers to return the src offset within the input * source. * * Revision 1.15 2002/12/04 01:57:09 knoaman * Scanner re-organization. * * Revision 1.14 2002/11/04 14:57:03 tng * C++ Namespace Support. * * Revision 1.13 2002/08/14 15:20:38 knoaman * [Bug 3111] Problem with LexicalHandler::startDTD() and LexicalHandler::endDTD(). * * Revision 1.12 2002/07/11 18:27:03 knoaman * Grammar caching/preparsing - initial implementation. * * Revision 1.11 2002/06/27 18:48:04 tng * API Documentation Update and move getScanner as protected * * Revision 1.10 2002/06/17 15:41:44 tng * Update API Documentation * * Revision 1.9 2002/06/06 20:38:18 tng * Document Fix: document that the returned object from resolveEntity is owned by the parser * * Revision 1.8 2002/05/31 15:13:53 tng * Fix doxygen documentation. * * Revision 1.7 2002/05/30 16:39:06 knoaman * DOM L3 LS. * * Revision 1.6 2002/05/30 16:20:09 tng * Add feature to optionally ignore external DTD. * * Revision 1.5 2002/05/29 21:37:47 knoaman * Add baseURI to resolveEntity to support DOMInputSource. * * Revision 1.4 2002/05/28 20:44:14 tng * [Bug 9104] prefixes dissapearing when schema validation turned on. * * Revision 1.3 2002/05/27 18:39:21 tng * To get ready for 64 bit large file, use XMLSSize_t to represent line and column number. * * Revision 1.2 2002/02/20 18:17:01 tng * [Bug 5977] Warnings on generating apiDocs. * * Revision 1.1.1.1 2002/02/01 22:22:07 peiyongz * sane_include * * Revision 1.22 2001/12/05 22:09:02 tng * Update documentation for setExternalSchemaLocation and setExternalNoNamespaceSchemaLocation. * * Revision 1.21 2001/11/20 18:51:44 tng * 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). * * Revision 1.20 2001/08/01 19:11:02 tng * Add full schema constraint checking flag to the samples and the parser. * * Revision 1.19 2001/07/27 20:24:21 tng * put getScanner() back as they were there before, not to break existing apps. * * Revision 1.18 2001/07/16 12:52:09 tng * APIDocs fix: default for schema processing in DOMParser, IDOMParser, and SAXParser should be false. * * Revision 1.17 2001/06/23 14:13:16 tng * Remove getScanner from the Parser headers as this is not needed and Scanner is not internal class. * * Revision 1.16 2001/06/03 19:26:20 jberry * Add support for querying error count following parse; enables simple parse without requiring error handler. * * Revision 1.15 2001/05/11 13:26:22 tng * Copyright update. * * Revision 1.14 2001/05/03 19:09:25 knoaman * Support Warning/Error/FatalError messaging. * Validity constraints errors are treated as errors, with the ability by user to set * validity constraints as fatal errors. * * Revision 1.13 2001/03/30 16:46:57 tng * Schema: Use setDoSchema instead of setSchemaValidation which makes more sense. * * Revision 1.12 2001/03/21 21:56:09 tng * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. * * Revision 1.11 2001/02/15 15:56:29 tng * Schema: Add setSchemaValidation and getSchemaValidation for DOMParser and SAXParser. * Add feature "http://apache.org/xml/features/validation/schema" for SAX2XMLReader. * New data field fSchemaValidation in XMLScanner as the flag. * * Revision 1.10 2001/01/12 21:23:41 tng * Documentation Enhancement: explain values of Val_Scheme * * Revision 1.9 2000/08/02 18:05:15 jpolast * changes required for sax2 * (changed private members to protected) * * Revision 1.8 2000/04/12 22:58:30 roddey * Added support for 'auto validate' mode. * * Revision 1.7 2000/03/03 01:29:34 roddey * Added a scanReset()/parseReset() method to the scanner and * parsers, to allow for reset after early exit from a progressive parse. * Added calls to new Terminate() call to all of the samples. Improved * documentation in SAX and DOM parsers. * * Revision 1.6 2000/02/17 03:54:27 rahulj * Added some new getters to query the parser state and * clarified the documentation. * * Revision 1.5 2000/02/16 03:42:58 rahulj * Finished documenting the SAX Driver implementation. * * Revision 1.4 2000/02/15 04:47:37 rahulj * Documenting the SAXParser framework. Not done yet. * * Revision 1.3 2000/02/06 07:47:56 rahulj * Year 2K copyright swat. * * Revision 1.2 1999/12/15 19:57:48 roddey * Got rid of redundant 'const' on boolean return value. Some compilers choke * on this and its useless. * * Revision 1.1.1.1 1999/11/09 01:07:51 twl * Initial checkin * * Revision 1.6 1999/11/08 20:44:54 rahul * Swat for adding in Product name and CVS comment log variable. * */#if !defined(SAXPARSER_HPP)#define SAXPARSER_HPP#include <xercesc/sax/Parser.hpp>#include <xercesc/internal/VecAttrListImpl.hpp>#include <xercesc/framework/XMLDocumentHandler.hpp>#include <xercesc/framework/XMLElementDecl.hpp>#include <xercesc/framework/XMLEntityHandler.hpp>#include <xercesc/framework/XMLErrorReporter.hpp>#include <xercesc/framework/XMLBuffer.hpp>#include <xercesc/util/SecurityManager.hpp>#include <xercesc/validators/DTD/DocTypeHandler.hpp>XERCES_CPP_NAMESPACE_BEGINclass DocumentHandler;class EntityResolver;class XMLPScanToken;class XMLScanner;class XMLValidator;class Grammar;class GrammarResolver;class XMLGrammarPool;class XMLEntityResolver;class XMLResourceIdentifier;class PSVIHandler;/** * This class implements the SAX 'Parser' interface and should be * used by applications wishing to parse the XML files using SAX. * It allows the client program to install SAX handlers for event * callbacks. * * <p>It can be used to instantiate a validating or non-validating * parser, by setting a member flag.</p> */class PARSERS_EXPORT SAXParser : public XMemory , public Parser , public XMLDocumentHandler , public XMLErrorReporter , public XMLEntityHandler , public DocTypeHandler {public : // ----------------------------------------------------------------------- // Class types // ----------------------------------------------------------------------- /** ValScheme enum used in setValidationScheme * Val_Never: Do not report validation errors. * Val_Always: The parser will always report validation errors. * Val_Auto: The parser will report validation errors only if a grammar is specified. * * @see #setValidationScheme */ enum ValSchemes { Val_Never , Val_Always , Val_Auto }; // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- /** @name Constructors and Destructor */ //@{ /** Constructor with an instance of validator class to use for * validation. * @param valToAdopt Pointer to the validator instance to use. The * parser is responsible for freeing the memory. * @param manager Pointer to the memory manager to be used to * allocate objects. * @param gramPool The collection of cached grammers. */ SAXParser ( XMLValidator* const valToAdopt = 0 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager , XMLGrammarPool* const gramPool = 0 ); /** * Destructor */ ~SAXParser(); //@} // -----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -