xmlscanner.hpp
来自「IBM的解析xml的工具Xerces的源代码」· HPP 代码 · 共 1,590 行 · 第 1/4 页
HPP
1,590 行
/* * Copyright 1999-2002,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *//* * $Log: XMLScanner.hpp,v $ * Revision 1.42 2004/09/29 21:23:34 peiyongz * default implementation provided * * Revision 1.41 2004/09/29 19:00:02 peiyongz * [jira1207] --patch from Dan Rosen * * Revision 1.40 2004/09/28 21:27:38 peiyongz * Optimized duplicated attributes checking for large number of attributes * * Revision 1.39 2004/09/28 02:14:13 cargilld * Add support for validating annotations. * * Revision 1.38 2004/09/23 01:09:55 cargilld * Add support for generating synthetic XSAnnotations. When a schema component has non-schema attributes and no child attributes create a synthetic XSAnnotation (under feature control) so the non-schema attributes can be recovered under PSVI. * * Revision 1.37 2004/09/08 13:56:14 peiyongz * Apache License Version 2.0 * * Revision 1.36 2004/06/14 15:18:53 peiyongz * Consolidated End Of Line Handling * * Revision 1.35 2004/04/13 18:57:54 peiyongz * Unrelavant comment removal * * Revision 1.34 2004/04/13 16:56:58 peiyongz * IdentityConstraintHandler * * Revision 1.33 2004/04/07 14:15:12 peiyongz * allow internalDTD (conditionally) with grammar reusing * * Revision 1.32 2003/12/31 15:40:00 cargilld * Release memory when an error is encountered. * * Revision 1.31 2003/11/28 21:18:32 knoaman * Make use of canonical representation in PSVIElement * * Revision 1.30 2003/11/28 19:54:31 knoaman * PSVIElement update * * Revision 1.29 2003/11/27 22:52:37 knoaman * PSVIElement implementation * * Revision 1.28 2003/11/24 05:09:38 neilg * implement new, statless, method for detecting duplicate attributes * * Revision 1.27 2003/11/13 15:00:44 peiyongz * Solve Compilation/Linkage error on AIX/Solaris/HP/Linux * * Revision 1.26 2003/11/12 20:29:47 peiyongz * Stateless Grammar: ValidationContext * * Revision 1.25 2003/11/06 15:30:06 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.24 2003/10/22 20:22:30 knoaman * Prepare for annotation support. * * Revision 1.23 2003/07/10 19:47:24 peiyongz * Stateless Grammar: Initialize scanner with grammarResolver, * creating grammar through grammarPool * * Revision 1.22 2003/05/16 21:36:58 knoaman * Memory manager implementation: Modify constructors to pass in the memory manager. * * Revision 1.21 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * * Revision 1.20 2003/04/22 14:52:37 knoaman * Initialize security manager in constructor. * * Revision 1.19 2003/04/17 22:00:46 neilg * This commit implements detection of exponential entity * expansions inside the scanner code. This is only done when a * security manager instance has been registered with the parser by * the application. The default number of entities which may be * expanded is 50000; this appears to work very well for SAX, but DOM * parsing applications may wish to set this limit considerably lower. * * Added SecurityManager to enable detection of exponentially-expanding entities * * Revision 1.18 2003/03/10 15:27:29 tng * XML1.0 Errata E38 * * Revision 1.17 2003/03/07 18:08:58 tng * Return a reference instead of void for operator= * * Revision 1.16 2003/01/03 20:08:40 tng * New feature StandardUriConformant to force strict standard uri conformance. * * Revision 1.15 2002/12/27 16:16:51 knoaman * Set scanner options and handlers. * * Revision 1.14 2002/12/20 22:09:56 tng * XML 1.1 * * Revision 1.13 2002/12/04 01:41:14 knoaman * Scanner re-organization. * * Revision 1.12 2002/11/04 14:58:19 tng * C++ Namespace Support. * * Revision 1.11 2002/08/27 05:56:39 knoaman * Identity Constraint: handle case of recursive elements. * * Revision 1.10 2002/08/16 15:46:17 knoaman * Bug 7698 : filenames with embedded spaces in schemaLocation strings not handled properly. * * Revision 1.9 2002/07/31 18:49:29 tng * [Bug 6227] Make method getLastExtLocation() constant. * * Revision 1.8 2002/07/11 18:22:13 knoaman * Grammar caching/preparsing - initial implementation. * * Revision 1.7 2002/06/17 16:13:01 tng * DOM L3: Add the flag fNormalizeData so that datatype normalization defined by schema is done only if asked. * * Revision 1.6 2002/06/07 18:35:49 tng * Add getReaderMgr in XMLScanner so that the parser can query encoding information. * * Revision 1.5 2002/05/30 16:20:57 tng * Add feature to optionally ignore external DTD. * * Revision 1.4 2002/05/27 18:42:14 tng * To get ready for 64 bit large file, use XMLSSize_t to represent line and column number. * * Revision 1.3 2002/05/22 20:54:33 knoaman * Prepare for DOM L3 : * - Make use of the XMLEntityHandler/XMLErrorReporter interfaces, instead of using * EntityHandler/ErrorHandler directly. * - Add 'AbstractDOMParser' class to provide common functionality for XercesDOMParser * and DOMBuilder. * * Revision 1.2 2002/03/25 20:25:32 knoaman * Move particle derivation checking from TraverseSchema to SchemaValidator. * * Revision 1.1.1.1 2002/02/01 22:22:03 peiyongz * sane_include * * Revision 1.38 2001/11/30 22:19:15 peiyongz * cleanUp function made member function * cleanUp object moved to file scope * * Revision 1.37 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.36 2001/11/13 13:27:28 tng * Move root element check to XMLScanner. * * Revision 1.35 2001/11/02 14:20:14 knoaman * Add support for identity constraints. * * Revision 1.34 2001/10/12 20:52:18 tng * Schema: Find the attributes see if they should be (un)qualified. * * Revision 1.33 2001/09/10 15:16:04 tng * Store the fGrammarType instead of calling getGrammarType all the time for faster performance. * * Revision 1.32 2001/09/10 14:06:22 tng * Schema: AnyAttribute support in Scanner and Validator. * * Revision 1.31 2001/08/13 15:06:39 knoaman * update <any> validation. * * Revision 1.30 2001/08/02 16:54:39 tng * Reset some Scanner flags in scanReset(). * * Revision 1.29 2001/08/01 19:11:01 tng * Add full schema constraint checking flag to the samples and the parser. * * Revision 1.28 2001/07/24 21:23:39 tng * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION. * * Revision 1.27 2001/07/13 16:56:48 tng * ScanId fix. * * Revision 1.26 2001/07/12 18:50:17 tng * Some performance modification regarding standalone check and xml decl check. * * Revision 1.25 2001/07/10 21:09:31 tng * Give proper error messsage when scanning external id. * * Revision 1.24 2001/07/09 13:42:08 tng * Partial Markup in Parameter Entity is validity constraint and thus should be just error, not fatal error. * * Revision 1.23 2001/07/05 13:12:11 tng * Standalone checking is validity constraint and thus should be just error, not fatal error: * * Revision 1.22 2001/06/22 12:42:33 tng * [Bug 2257] 1.5 thinks a <?xml-stylesheet ...> tag is a <?xml ...> tag * * Revision 1.21 2001/06/04 20:59:29 jberry * Add method incrementErrorCount for use by validator. Make sure to reset error count in _both_ the scanReset methods. * * Revision 1.20 2001/06/03 19:21:40 jberry * Add support for tracking error count during parse; enables simple parse without requiring error handler. * * Revision 1.19 2001/05/28 20:55:02 tng * Schema: allocate a fDTDValidator, fSchemaValidator explicitly to avoid wrong cast * * Revision 1.18 2001/05/11 15:17:28 tng * Schema: Nillable fixes. * * Revision 1.17 2001/05/11 13:26:17 tng * Copyright update. * * Revision 1.16 2001/05/03 20:34:29 tng * Schema: SchemaValidator update * * Revision 1.15 2001/05/03 19:09:09 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.14 2001/04/19 18:16:59 tng * Schema: SchemaValidator update, and use QName in Content Model * * Revision 1.13 2001/03/30 16:46:56 tng * Schema: Use setDoSchema instead of setSchemaValidation which makes more sense. * * Revision 1.12 2001/03/30 16:35:06 tng * Schema: Whitespace normalization. * * Revision 1.11 2001/03/21 21:56:05 tng * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. * * Revision 1.10 2001/02/15 15:56:27 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.9 2000/04/12 22:58:28 roddey * Added support for 'auto validate' mode. * * Revision 1.8 2000/03/03 01:29:32 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.7 2000/03/02 19:54:30 roddey * This checkin includes many changes done while waiting for the * 1.1.0 code to be finished. I can't list them all here, but a list is * available elsewhere. * * Revision 1.6 2000/02/24 20:18:07 abagchi * Swat for removing Log from API docs * * Revision 1.5 2000/02/06 07:47:54 rahulj * Year 2K copyright swat. * * Revision 1.4 2000/01/24 20:40:43 roddey * Exposed the APIs to get to the byte offset in the source XML buffer. This stuff * is not tested yet, but I wanted to get the API changes in now so that the API * can be stablized. * * Revision 1.3 2000/01/12 23:52:46 roddey * These are trivial changes required to get the C++ and Java versions * of error messages more into sync. Mostly it was where the Java version * was passing out one or more parameter than the C++ version was. In * some cases the change just required an extra parameter to get the * needed info to the place where the error was issued. * * Revision 1.2 2000/01/12 00:15:04 roddey * Changes to deal with multiply nested, relative pathed, entities and to deal * with the new URL class changes. * * Revision 1.1.1.1 1999/11/09 01:08:23 twl * Initial checkin * * Revision 1.4 1999/11/08 20:44:52 rahul * Swat for adding in Product name and CVS comment log variable. * */#if !defined(XMLSCANNER_HPP)#define XMLSCANNER_HPP#include <xercesc/framework/XMLBufferMgr.hpp>#include <xercesc/framework/XMLErrorCodes.hpp>#include <xercesc/framework/XMLRefInfo.hpp>#include <xercesc/util/PlatformUtils.hpp>#include <xercesc/util/NameIdPool.hpp>#include <xercesc/util/RefHashTableOf.hpp>#include <xercesc/util/SecurityManager.hpp>#include <xercesc/internal/ReaderMgr.hpp>#include <xercesc/internal/ElemStack.hpp>#include <xercesc/validators/DTD/DTDEntityDecl.hpp>#include <xercesc/framework/XMLAttr.hpp>#include <xercesc/framework/ValidationContext.hpp>#include <xercesc/validators/common/GrammarResolver.hpp>XERCES_CPP_NAMESPACE_BEGINclass InputSource;class XMLDocumentHandler;class XMLEntityHandler;class ErrorHandler;class DocTypeHandler;class XMLPScanToken;class XMLStringPool;class Grammar;class XMLValidator;class MemoryManager;class PSVIHandler;struct PSVIElemContext{ bool fIsSpecified; bool fErrorOccurred; int fElemDepth; int fFullValidationDepth; int fNoneValidationDepth; DatatypeValidator* fCurrentDV; ComplexTypeInfo* fCurrentTypeInfo; const XMLCh* fNormalizedValue;};// This is the mondo scanner class, which does the vast majority of the// work of parsing. It handles reading in input and spitting out events// to installed handlers.class XMLPARSER_EXPORT XMLScanner : public XMemory, public XMLBufferFullHandler{public : // ----------------------------------------------------------------------- // Public class types // // NOTE: These should really be private, but some of the compilers we // have to deal with are too stupid to understand this. // // DeclTypes // Used by scanXMLDecl() to know what type of decl it should scan. // Text decls have slightly different rules from XMLDecls. // // EntityExpRes // These are the values returned from the entity expansion method, // to indicate how it went. // // XMLTokens // These represent the possible types of input we can get while // scanning content. // // ValScheme // This indicates what the scanner should do in terms of validation. // 'Auto' means if there is any int/ext subset, then validate. Else, // don't. // ----------------------------------------------------------------------- enum DeclTypes { Decl_Text , Decl_XML }; enum EntityExpRes { EntityExp_Pushed , EntityExp_Returned , EntityExp_Failed }; enum XMLTokens { Token_CData , Token_CharData , Token_Comment , Token_EndTag , Token_EOF , Token_PI , Token_StartTag , Token_Unknown }; enum ValSchemes { Val_Never , Val_Always , Val_Auto };
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?