📄 abstractdomparser.hpp
字号:
/* * The Apache Software License, Version 1.1 * * Copyright (c) 2002, 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) 2001, International * Business Machines, Inc., http://www.ibm.com . For more information * on the Apache Software Foundation, please see * <http://www.apache.org/>. *//* * $Id: AbstractDOMParser.hpp,v 1.27 2004/01/29 11:46:32 cargilld Exp $ * */#if !defined(ABSTRACTDOMPARSER_HPP)#define ABSTRACTDOMPARSER_HPP#include <xercesc/dom/DOMDocument.hpp>#include <xercesc/framework/XMLDocumentHandler.hpp>#include <xercesc/framework/XMLErrorReporter.hpp>#include <xercesc/framework/XMLEntityHandler.hpp>#include <xercesc/util/SecurityManager.hpp>#include <xercesc/util/ValueStackOf.hpp>#include <xercesc/validators/DTD/DocTypeHandler.hpp>#include <xercesc/dom/DOMDocumentType.hpp>#include <xercesc/validators/DTD/DTDElementDecl.hpp>#include <xercesc/framework/XMLBufferMgr.hpp>XERCES_CPP_NAMESPACE_BEGINclass XMLPScanToken;class XMLScanner;class XMLValidator;class DOMDocumentImpl;class DOMDocumentTypeImpl;class DOMElement;class GrammarResolver;class XMLGrammarPool;class PSVIHandler;/** * This class implements the Document Object Model (DOM) interface. * It is used as a base for DOM parsers (i.e. XercesDOMParser, DOMBuilder). */class PARSERS_EXPORT AbstractDOMParser : public XMemory , public XMLDocumentHandler , public XMLErrorReporter , public XMLEntityHandler , public DocTypeHandler{public : // ----------------------------------------------------------------------- // Class types // ----------------------------------------------------------------------- /** @name Public constants */ //@{ /** 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 Detructor // ----------------------------------------------------------------------- /** @name Destructor */ //@{ /** * Destructor */ virtual ~AbstractDOMParser(); //@} // ----------------------------------------------------------------------- // Utility methods // ----------------------------------------------------------------------- /** @name Utility methods */ //@{ /** Reset the parser * * This method resets the state of the DOM driver and makes * it ready for a fresh parse run. */ void reset(); /** Adopt the DOM document * * This method returns the DOMDocument object representing the * root of the document tree. * * The caller will adopt the DOMDocument and thus is responsible to * call DOMDocument::release() to release the associated memory. * The parser will not delete it. The ownership is transferred * from the parser to the caller. * * @return The adopted DOMDocument object which represents the entire * XML document. */ DOMDocument* adoptDocument(); //@} // ----------------------------------------------------------------------- // Getter methods // ----------------------------------------------------------------------- /** @name Getter methods */ //@{ /** Get the DOM document * * This method returns the DOMDocument object representing the * root of the document tree. This object provides the primary * access to the document's data. * * The returned DOMDocument object is owned by the parser. * * @return The DOMDocument object which represents the entire * XML document. */ DOMDocument* getDocument(); /** Get a const reference to the validator * * This method returns a reference to the parser's installed * validator. * * @return A const reference to the installed validator object. */ const XMLValidator& getValidator() const; /** * This method returns an enumerated value that indicates the current * validation scheme set on this parser. * * @return The ValSchemes value current set on this parser. * @see #setValidationScheme */ ValSchemes getValidationScheme() const; /** Get the 'do schema' flag * * This method returns the state of the parser's schema processing * flag. * * @return true, if the parser is currently configured to * understand schema, false otherwise. * * @see #setDoSchema */ bool getDoSchema() const; /** Get the 'full schema constraint checking' flag * * This method returns the state of the parser's full schema constraint * checking flag. * * @return true, if the parser is currently configured to * have full schema constraint checking, false otherwise. * * @see #setValidationSchemaFullChecking */ bool getValidationSchemaFullChecking() const; /** Get error count from the last parse operation. * * This method returns the error count from the last parse * operation. Note that this count is actually stored in the * scanner, so this method simply returns what the * scanner reports. * * @return number of errors encountered during the latest * parse operation. * */ int getErrorCount() const; /** Get the 'do namespaces' flag * * This method returns the state of the parser's namespace processing * flag. * * @return true, if the parser is currently configured to * understand namespaces, false otherwise. * * @see #setDoNamespaces */ bool getDoNamespaces() const; /** Get the 'exit on first error' flag * * This method returns the state of the parser's * exit-on-First-Fatal-Error flag. If this flag is true, then the * parse will exit the first time it sees any non-wellformed XML or * any validity error. The default state is true. * * @return true, if the parser is currently configured to * exit on the first fatal error, false otherwise. * * @see #setExitOnFirstFatalError */ bool getExitOnFirstFatalError() const; /** * This method returns the state of the parser's * validation-constraint-fatal flag. * * @return true, if the parser is currently configured to * set validation constraint errors as fatal, false * otherwise. * * @see #setValidationContraintFatal */ bool getValidationConstraintFatal() const; /** Get the 'include entity references' flag * * This method returns the flag that specifies whether the parser is * creating entity reference nodes in the DOM tree being produced. * * @return The state of the create entity reference node * flag. * @see #setCreateEntityReferenceNodes */ bool getCreateEntityReferenceNodes()const; /** Get the 'include ignorable whitespace' flag. * * This method returns the state of the parser's include ignorable * whitespace flag. * * @return 'true' if the include ignorable whitespace flag is set on * the parser, 'false' otherwise. * * @see #setIncludeIgnorableWhitespace */ bool getIncludeIgnorableWhitespace() const; /** Get the set of Namespace/SchemaLocation that is specified externaly. * * This method returns the list of Namespace/SchemaLocation that was * specified using setExternalSchemaLocation. * * The parser owns the returned string, and the memory allocated for * the returned string will be destroyed when the parser is deleted. * * To ensure assessiblity of the returned information after the parser * is deleted, callers need to copy and store the returned information * somewhere else. * * @return a pointer to the list of Namespace/SchemaLocation that was * specified externally. The pointer spans the same life-time as * the parser. A null pointer is returned if nothing * was specified externally. * * @see #setExternalSchemaLocation(const XMLCh* const) */ XMLCh* getExternalSchemaLocation() const; /** Get the noNamespace SchemaLocation that is specified externaly. * * This method returns the no target namespace XML Schema Location * that was specified using setExternalNoNamespaceSchemaLocation. * * The parser owns the returned string, and the memory allocated for * the returned string will be destroyed when the parser is deleted. * * To ensure assessiblity of the returned information after the parser * is deleted, callers need to copy and store the returned information * somewhere else. * * @return a pointer to the no target namespace Schema Location that was * specified externally. The pointer spans the same life-time as * the parser. A null pointer is returned if nothing * was specified externally. * * @see #setExternalNoNamespaceSchemaLocation(const XMLCh* const)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -