⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traverseschema.hpp

📁 基于属性证书的访问控制源代码,由c++编写,包括openssl,xercesc等
💻 HPP
📖 第 1 页 / 共 3 页
字号:
/* * The Apache Software License, Version 1.1 * * Copyright (c) 2001-2002 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: TraverseSchema.hpp,v 1.33 2004/01/29 11:52:31 cargilld Exp $ */#if !defined(TRAVERSESCHEMA_HPP)#define TRAVERSESCHEMA_HPP/**  * Instances of this class get delegated to Traverse the Schema and  * to populate the SchemaGrammar internal representation.  */// ---------------------------------------------------------------------------//  Includes// ---------------------------------------------------------------------------#include <xercesc/util/XMLUniDefs.hpp>#include <xercesc/dom/DOMElement.hpp>#include <xercesc/dom/DOMAttr.hpp>#include <xercesc/framework/XMLBuffer.hpp>#include <xercesc/framework/XMLErrorCodes.hpp>#include <xercesc/validators/schema/SchemaSymbols.hpp>#include <xercesc/util/ValueVectorOf.hpp>#include <xercesc/util/RefHash2KeysTableOf.hpp>#include <xercesc/validators/common/ContentSpecNode.hpp>#include <xercesc/validators/schema/SchemaGrammar.hpp>#include <xercesc/validators/schema/SchemaInfo.hpp>#include <xercesc/validators/schema/GeneralAttributeCheck.hpp>#include <xercesc/validators/schema/XSDErrorReporter.hpp>#include <xercesc/util/XMLResourceIdentifier.hpp>XERCES_CPP_NAMESPACE_BEGIN// ---------------------------------------------------------------------------//  Forward Declarations// ---------------------------------------------------------------------------class GrammarResolver;class XMLEntityHandler;class XMLScanner;class DatatypeValidator;class DatatypeValidatorFactory;class QName;class ComplexTypeInfo;class XMLAttDef;class NamespaceScope;class SchemaAttDef;class InputSource;class XercesGroupInfo;class XercesAttGroupInfo;class IdentityConstraint;class XSDLocator;class XSDDOMParser;class XMLErrorReporter;class VALIDATORS_EXPORT TraverseSchema : public XMemory{public:    // -----------------------------------------------------------------------    //  Public Constructors/Destructor    // -----------------------------------------------------------------------    TraverseSchema    (          DOMElement* const       schemaRoot        , XMLStringPool* const    uriStringPool        , SchemaGrammar* const    schemaGrammar        , GrammarResolver* const  grammarResolver        , XMLScanner* const       xmlScanner        , const XMLCh* const      schemaURL        , XMLEntityHandler* const entityHandler        , XMLErrorReporter* const errorReporter        , MemoryManager* const    manager = XMLPlatformUtils::fgMemoryManager    );    ~TraverseSchema();private:  	 // This enumeration is defined here for compatibility with the CodeWarrior  	 // compiler, which apparently doesn't like to accept default parameter  	 // arguments that it hasn't yet seen. The Not_All_Context argument is  	 // used in the declaration of checkMinMax, below.  	 //    // Flags indicate any special restrictions on minOccurs and maxOccurs    // relating to "all".    //    Not_All_Context    - not processing an <all>    //    All_Element        - processing an <element> in an <all>    //    Group_Ref_With_All - processing <group> reference that contained <all>    //    All_Group          - processing an <all> group itself    enum	{        Not_All_Context = 0        , All_Element = 1        , Group_Ref_With_All = 2        , All_Group = 4    };    // -----------------------------------------------------------------------    //  Unimplemented constructors and operators    // -----------------------------------------------------------------------    TraverseSchema(const TraverseSchema&);    TraverseSchema& operator=(const TraverseSchema&);    // -----------------------------------------------------------------------    //  Init/CleanUp methods    // -----------------------------------------------------------------------    void init();    void cleanUp();    // -----------------------------------------------------------------------    //  Traversal methods    // -----------------------------------------------------------------------    /**      * Traverse the Schema DOM tree      */    void                doTraverseSchema(const DOMElement* const schemaRoot);    void                preprocessSchema(DOMElement* const schemaRoot,                                         const XMLCh* const schemaURL);    void                traverseSchemaHeader(const DOMElement* const schemaRoot);    XSAnnotation*       traverseAnnotationDecl(const DOMElement* const childElem,                                               ValueVectorOf<DOMNode*>* const nonXSAttList,                                               const bool topLevel = false);    void                traverseInclude(const DOMElement* const childElem);    void                traverseImport(const DOMElement* const childElem);    void                traverseRedefine(const DOMElement* const childElem);    void                traverseAttributeDecl(const DOMElement* const childElem,                                              ComplexTypeInfo* const typeInfo,                                              const bool topLevel = false);    void                traverseSimpleContentDecl(const XMLCh* const typeName,                                                  const XMLCh* const qualifiedName,                                                  const DOMElement* const contentDecl,                                                  ComplexTypeInfo* const typeInfo,                                                  Janitor<XSAnnotation>* const janAnnot);    void                traverseComplexContentDecl(const XMLCh* const typeName,                                                  const DOMElement* const contentDecl,                                                  ComplexTypeInfo* const typeInfo,                                                  const bool isMixed,                                                  Janitor<XSAnnotation>* const janAnnot);    DatatypeValidator*  traverseSimpleTypeDecl(const DOMElement* const childElem,                                               const bool topLevel = true,                                               int baseRefContext = SchemaSymbols::XSD_EMPTYSET);    int                 traverseComplexTypeDecl(const DOMElement* const childElem,                                                const bool topLevel = true,                                                const XMLCh* const recursingTypeName = 0);    DatatypeValidator*  traverseByList(const DOMElement* const rootElem,                                       const DOMElement* const contentElem,                                       const XMLCh* const typeName,                                       const XMLCh* const qualifiedName,                                       const int finalSet,                                       Janitor<XSAnnotation>* const janAnnot);    DatatypeValidator*  traverseByRestriction(const DOMElement* const rootElem,                                              const DOMElement* const contentElem,                                              const XMLCh* const typeName,                                              const XMLCh* const qualifiedName,                                              const int finalSet,                                              Janitor<XSAnnotation>* const janAnnot);    DatatypeValidator*  traverseByUnion(const DOMElement* const rootElem,                                        const DOMElement* const contentElem,                                        const XMLCh* const typeName,                                        const XMLCh* const qualifiedName,                                        const int finalSet,                                        int baseRefContext,                                        Janitor<XSAnnotation>* const janAnnot);    SchemaElementDecl*    traverseElementDecl(const DOMElement* const childElem,                                            const bool topLevel = false);    const XMLCh*        traverseNotationDecl(const DOMElement* const childElem);    const XMLCh*        traverseNotationDecl(const DOMElement* const childElem,                                             const XMLCh* const name,                                             const XMLCh* const uriStr);    ContentSpecNode*    traverseChoiceSequence(const DOMElement* const elemDecl,                                               const int modelGroupType);    ContentSpecNode*    traverseAny(const DOMElement* const anyDecl);    ContentSpecNode*    traverseAll(const DOMElement* const allElem);    XercesGroupInfo*    traverseGroupDecl(const DOMElement* const childElem,                                          const bool topLevel = true);    XercesAttGroupInfo* traverseAttributeGroupDecl(const DOMElement* const elem,                                                   ComplexTypeInfo* const typeInfo,                                                   const bool topLevel = false);    XercesAttGroupInfo* traverseAttributeGroupDeclNS(const DOMElement* const elem,                                                     const XMLCh* const uriStr,                                                     const XMLCh* const name);    SchemaAttDef*       traverseAnyAttribute(const DOMElement* const elem);    void                traverseKey(const DOMElement* const icElem,                                    SchemaElementDecl* const elemDecl);    void                traverseUnique(const DOMElement* const icElem,                                       SchemaElementDecl* const elemDecl);    void                traverseKeyRef(const DOMElement* const icElem,                                       SchemaElementDecl* const elemDecl,                                       const unsigned int namespaceDepth);    bool                traverseIdentityConstraint(IdentityConstraint* const ic,                                                   const DOMElement* const icElem);    // -----------------------------------------------------------------------    //  Error Reporting methods    // -----------------------------------------------------------------------    void reportSchemaError(const XSDLocator* const aLocator,                           const XMLCh* const msgDomain,                           const int errorCode);    void reportSchemaError(const XSDLocator* const aLocator,                           const XMLCh* const msgDomain,                           const int errorCode,                           const XMLCh* const text1,                           const XMLCh* const text2 = 0,                           const XMLCh* const text3 = 0,                           const XMLCh* const text4 = 0);    void reportSchemaError(const DOMElement* const elem,                           const XMLCh* const msgDomain,                           const int errorCode);    void reportSchemaError(const DOMElement* const elem,                           const XMLCh* const msgDomain,                           const int errorCode,                           const XMLCh* const text1,                           const XMLCh* const text2 = 0,                           const XMLCh* const text3 = 0,                           const XMLCh* const text4 = 0);    // -----------------------------------------------------------------------    //  Private Helper methods    // -----------------------------------------------------------------------    /**      * Retrived the Namespace mapping from the schema element      */    void retrieveNamespaceMapping(const DOMElement* const schemaRoot);    /**      * Loop through the children, and traverse the corresponding schema type      * type declaration (simpleType, complexType, import, ....)      */    void processChildren(const DOMElement* const root);    void preprocessChildren(const DOMElement* const root);    void preprocessImport(const DOMElement* const elemNode);    void preprocessInclude(const DOMElement* const elemNode);    void preprocessRedefine(const DOMElement* const elemNode);    /**      * Parameters:      *   rootElem - top element for a given type declaration      *   contentElem - content must be annotation? or some other simple content      *   isEmpty: - true if (annotation?, smth_else), false if (annotation?)      *      * Check for Annotation if it is present, traverse it. If a sibling is      * found and it is not an annotation return it, otherwise return 0.      * Used by traverseSimpleTypeDecl.      */    DOMElement* checkContent(const DOMElement* const rootElem,                               DOMElement* const contentElem,                               const bool isEmpty);    /**      * Parameters:      *   contentElem - content element to check      *      * Check for identity constraints content.      */    const DOMElement* checkIdentityConstraintContent(const DOMElement* const contentElem);    DatatypeValidator* getDatatypeValidator(const XMLCh* const uriStr,                                            const XMLCh* const localPartStr);    /**      * Process simpleType content of a list|restriction|union      * Return a dataype validator if valid type, otherwise 0.      */    DatatypeValidator* checkForSimpleTypeValidator(const DOMElement* const content,                                                   int baseRefContext = SchemaSymbols::XSD_EMPTYSET);    /**      * Process complexType content of an element      * Return a ComplexTypeInfo if valid type, otherwise 0.      */    ComplexTypeInfo* checkForComplexTypeInfo(const DOMElement* const content);    /**      * Return DatatypeValidator available for the baseTypeStr.

⌨️ 快捷键说明

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