domnormalizer.hpp

来自「IBM的解析xml的工具Xerces的源代码」· HPP 代码 · 共 167 行

HPP
167
字号
#ifndef DOMNormalizer_HEADER_GUARD_#define DOMNormalizer_HEADER_GUARD_/* * Copyright 2001-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. */////  This file is part of the internal implementation of the C++ XML DOM.//  It should NOT be included or used directly by application programs.////  Applications should include the file <xercesc/dom/DOM.hpp> for the entire//  DOM API, or xercesc/dom/DOM*.hpp for individual DOM classes, where the class//  name is substituded for the *.//#include <xercesc/util/XercesDefs.hpp>#include <xercesc/util/RefHashTableOf.hpp>#include <xercesc/util/RefVectorOf.hpp>#include <xercesc/framework/XMLErrorCodes.hpp>XERCES_CPP_NAMESPACE_BEGINclass DOMConfigurationImpl;class DOMDocumentImpl;class DOMNode;class DOMElementImpl;class DOMAttr;class DOMNamedNodeMap;class DOMNormalizer : public XMemory {    //the following are the data structures maintain the stack of namespace information     class InScopeNamespaces : public XMemory {        class Scope : public XMemory {        public:            Scope(Scope *baseScopeWithBindings);            ~Scope();            void addOrChangeBinding(const XMLCh *prefix, const XMLCh *uri,                                    MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);            const XMLCh* getUri(const XMLCh *prefix) const;            const XMLCh* getPrefix(const XMLCh* uri) const;            Scope *fBaseScopeWithBindings;        private:            RefHashTableOf<XMLCh> *fPrefixHash;            RefHashTableOf<XMLCh> *fUriHash;            // unimplemented            Scope ( const Scope& toCopy);            Scope& operator= (const Scope& other);        };    public:            InScopeNamespaces(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);        ~InScopeNamespaces();        void addOrChangeBinding(const XMLCh *prefix, const XMLCh *uri,                                MemoryManager* const manager  = XMLPlatformUtils::fgMemoryManager);        void addScope(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);        void removeScope();        bool isValidBinding(const XMLCh* prefix, const XMLCh* uri) const;        const XMLCh* getOrDeclarePrefix(const XMLCh* uri);        const XMLCh* getPrefix(const XMLCh* uri) const;        const XMLCh* getUri(const XMLCh* prefix) const;        int size();    private:        RefVectorOf<Scope> *fScopes;        Scope *lastScopeWithBindings;        // unimplemented        InScopeNamespaces ( const InScopeNamespaces& toCopy);        InScopeNamespaces& operator= (const InScopeNamespaces& other);    };public:    DOMNormalizer(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);    ~DOMNormalizer();    /**     * Main entry method to normalize a document     */    void normalizeDocument(DOMDocumentImpl *doc);    // -----------------------------------------------------------------------    //  Notification that lazy data has been deleted    // -----------------------------------------------------------------------	static void reinitNormalizerMutex();	static void reinitMsgLoader();private:    // unimplemented    DOMNormalizer ( const DOMNormalizer& toCopy);    DOMNormalizer& operator= (const DOMNormalizer& other);    /**     * Recursively normalizes a node     */    DOMNode * normalizeNode(DOMNode *node) const;    /**     * Helper method that fixes up the namespace declarations according to the     * DOM Level 3 psydocode     */    void namespaceFixUp(DOMElementImpl *ele) const;    /**     * Converts an integer to an XMLCh - max 15 digits long.      */    const XMLCh * integerToXMLCh(unsigned int i) const;    /**     * Adds a namespace attribute or replaces the value of existing namespace     * attribute with the given prefix and value for URI.     * In case prefix is empty will add/update default namespace declaration.     */    void addOrChangeNamespaceDecl(const XMLCh* prefix, const XMLCh* uri, DOMElementImpl *element) const;        /**     * Adds a custom namespace in the form "NSx" where x is an integer that      * has not yet used in the document     */    const XMLCh* addCustomNamespaceDecl(const XMLCh* uri, DOMElementImpl *element) const;    /**     * Report an error      */    void error(const XMLErrs::Codes code, const DOMNode *node) const;    //    // fDocument - the document we are operating on    //    // fDOMConfiguration - the configuration from the document    //    // fErrorHandler - the errorhandler to be used when reporting errors during normalization    //    // fNSScope - the data stucture that holds the prefix-uri information    //    // fNewNamespaceCount - the number of custom namespace declarations we have created    //    DOMDocumentImpl *fDocument;    DOMConfigurationImpl *fConfiguration;    DOMErrorHandler *fErrorHandler;    InScopeNamespaces *fNSScope;    unsigned int fNewNamespaceCount;    MemoryManager* fMemoryManager;};XERCES_CPP_NAMESPACE_END#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?