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

📄 traverseschema.hpp

📁 开源xml解析库,非常有名
💻 HPP
📖 第 1 页 / 共 3 页
字号:
      * This method also takes actions to find and, if necessary, modify      * the names of elements in <redefine>'s in the schema that's being      * redefined.      */    void renameRedefinedComponents(const DOMElement* const redefineElem,                                   SchemaInfo* const redefiningSchemaInfo,                                   SchemaInfo* const redefinedSchemaInfo);    /**      * This method returns true if the redefine component is valid, and if      * it was possible to revise it correctly.      */    bool validateRedefineNameChange(const DOMElement* const redefineChildElem,                                    const XMLCh* const redefineChildElemName,                                    const XMLCh* const redefineChildDeclName,                                    const int redefineNameCounter,                                    SchemaInfo* const redefiningSchemaInfo);	/**      * This function looks among the children of 'redefineChildElem' for a      * component of type 'redefineChildComponentName'. If it finds one, it      * evaluates whether its ref attribute contains a reference to      * 'refChildTypeName'. If it does, it returns 1 + the value returned by      * calls to itself on all other children.  In all other cases it returns      * 0 plus the sum of the values returned by calls to itself on      * redefineChildElem's children. It also resets the value of ref so that      * it will refer to the renamed type from the schema being redefined.      */    int changeRedefineGroup(const DOMElement* const redefineChildElem,                            const XMLCh* const redefineChildComponentName,                            const XMLCh* const redefineChildTypeName,                            const int redefineNameCounter);    /** This simple function looks for the first occurrence of a      * 'redefineChildTypeName' item in the redefined schema and appropriately      * changes the value of its name. If it turns out that what we're looking      * for is in a <redefine> though, then we just rename it--and it's      * reference--to be the same.      */    void fixRedefinedSchema(const DOMElement* const elem,                            SchemaInfo* const redefinedSchemaInfo,                            const XMLCh* const redefineChildComponentName,                            const XMLCh* const redefineChildTypeName,                            const int redefineNameCounter);    void getRedefineNewTypeName(const XMLCh* const oldTypeName,                                const int redefineCounter,                                XMLBuffer& newTypeName);    /**      * This purpose of this method is threefold:      * 1. To extract the schema information of included/redefined schema.      * 2. Rename redefined components.      * 3. Process components of included/redefined schemas      */    void preprocessRedefineInclude(SchemaInfo* const currSchemaInfo);    /**      * Update the list of valid substitution groups in the case of circular      * import.      */    void updateCircularSubstitutionList(SchemaInfo* const aSchemaInfo);    void processKeyRefFor(SchemaInfo* const aSchemaInfo,                          ValueVectorOf<SchemaInfo*>* const infoList);    void processAttValue(const XMLCh* const attVal, XMLBuffer& aBuf);    // routine to generate synthetic annotations    XSAnnotation* generateSyntheticAnnotation(const DOMElement* const elem                                             , ValueVectorOf<DOMNode*>* nonXSAttList);    // routine to validate annotations    void validateAnnotations();    // -----------------------------------------------------------------------    //  Private constants    // -----------------------------------------------------------------------    enum    {        ES_Block        , C_Block        , S_Final        , EC_Final        , ECS_Final    };    enum ExceptionCodes    {        NoException = 0,        InvalidComplexTypeInfo = 1,        RecursingElement = 2    };    enum    {        Elem_Def_Qualified = 1,        Attr_Def_Qualified = 2    };    // -----------------------------------------------------------------------    //  Private data members    // -----------------------------------------------------------------------    bool                                           fFullConstraintChecking;    int                                            fTargetNSURI;    int                                            fEmptyNamespaceURI;    int                                            fCurrentScope;    int                                            fScopeCount;    unsigned int                                   fAnonXSTypeCount;    unsigned int                                   fCircularCheckIndex;    const XMLCh*                                   fTargetNSURIString;    DatatypeValidatorFactory*                      fDatatypeRegistry;    GrammarResolver*                               fGrammarResolver;    SchemaGrammar*                                 fSchemaGrammar;    XMLEntityHandler*                              fEntityHandler;    XMLErrorReporter*                              fErrorReporter;    XMLStringPool*                                 fURIStringPool;    XMLStringPool*                                 fStringPool;    XMLBuffer                                      fBuffer;    XMLScanner*                                    fScanner;    NamespaceScope*                                fNamespaceScope;    RefHashTableOf<XMLAttDef>*                     fAttributeDeclRegistry;    RefHashTableOf<ComplexTypeInfo>*               fComplexTypeRegistry;    RefHashTableOf<XercesGroupInfo>*               fGroupRegistry;    RefHashTableOf<XercesAttGroupInfo>*            fAttGroupRegistry;    RefHashTableOf<ElemVector>*                    fIC_ElementsNS;    RefHashTableOf<SchemaInfo>*                    fPreprocessedNodes;    SchemaInfo*                                    fSchemaInfo;    XercesGroupInfo*                               fCurrentGroupInfo;    XercesAttGroupInfo*                            fCurrentAttGroupInfo;    ComplexTypeInfo*                               fCurrentComplexType;    ValueVectorOf<unsigned int>*                   fCurrentTypeNameStack;    ValueVectorOf<unsigned int>*                   fCurrentGroupStack;    ValueVectorOf<unsigned int>*                   fIC_NamespaceDepth;    ValueVectorOf<SchemaElementDecl*>*             fIC_Elements;    ValueVectorOf<const DOMElement*>*              fDeclStack;    ValueVectorOf<unsigned int>**                  fGlobalDeclarations;    ValueVectorOf<DOMNode*>*                       fNonXSAttList;    RefHashTableOf<ValueVectorOf<DOMElement*> >*   fIC_NodeListNS;    RefHashTableOf<ValueVectorOf<unsigned int> >*  fIC_NamespaceDepthNS;    RefHash2KeysTableOf<XMLCh>*                    fNotationRegistry;    RefHash2KeysTableOf<XMLCh>*                    fRedefineComponents;    RefHash2KeysTableOf<IdentityConstraint>*       fIdentityConstraintNames;    RefHash2KeysTableOf<ElemVector>*               fValidSubstitutionGroups;    RefHash2KeysTableOf<SchemaInfo>*               fSchemaInfoList;    XSDDOMParser*                                  fParser;    XSDErrorReporter                               fXSDErrorReporter;    XSDLocator*                                    fLocator;    MemoryManager*                                 fMemoryManager;    MemoryManager*                                 fGrammarPoolMemoryManager;    XSAnnotation*                                  fAnnotation;    GeneralAttributeCheck                          fAttributeCheck;    friend class GeneralAttributeCheck;};// ---------------------------------------------------------------------------//  TraverseSchema: Helper methods// ---------------------------------------------------------------------------inline const XMLCh* TraverseSchema::getPrefix(const XMLCh* const rawName) {    int colonIndex = XMLString::indexOf(rawName, chColon);    if (colonIndex == -1 || colonIndex == 0) {        return XMLUni::fgZeroLenString;    }    fBuffer.set(rawName, colonIndex);    return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer()));}inline const XMLCh* TraverseSchema::getLocalPart(const XMLCh* const rawName) {    int    colonIndex = XMLString::indexOf(rawName, chColon);    int    rawNameLen = XMLString::stringLen(rawName);    if (colonIndex + 1 == rawNameLen) {        return XMLUni::fgZeroLenString;    }    if (colonIndex == -1) {        fBuffer.set(rawName, rawNameLen);    }    else {        fBuffer.set(rawName + colonIndex + 1, rawNameLen - colonIndex - 1);    }    return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer()));}inlineconst XMLCh* TraverseSchema::getElementAttValue(const DOMElement* const elem,                                                const XMLCh* const attName,                                                const bool toTrim) {    DOMAttr* attNode = elem->getAttributeNode(attName);    if (attNode == 0) {        return 0;    }    const XMLCh* attValue = attNode->getValue();    if (toTrim) {        fBuffer.set(attValue);        XMLCh* bufValue = fBuffer.getRawBuffer();        XMLString::trim(bufValue);        if (!bufValue || !*bufValue) {            return XMLUni::fgZeroLenString;        }        return fStringPool->getValueForId(fStringPool->addOrFind(bufValue));    }    return attValue;}inline voidTraverseSchema::checkForEmptyTargetNamespace(const DOMElement* const elem) {    const XMLCh* targetNS = getElementAttValue(elem, SchemaSymbols::fgATT_TARGETNAMESPACE);    if (targetNS && !*targetNS) {        reportSchemaError(elem, XMLUni::fgXMLErrDomain, XMLErrs::InvalidTargetNSValue);    }}inline bool TraverseSchema::isBaseFromAnotherSchema(const XMLCh* const baseURI){    if (!XMLString::equals(baseURI,fTargetNSURIString)        && !XMLString::equals(baseURI, SchemaSymbols::fgURI_SCHEMAFORSCHEMA)        && (baseURI && *baseURI)) {        //REVISIT, !!!! a hack: for schema that has no        //target namespace, e.g. personal-schema.xml        return true;    }    return false;}inline bool TraverseSchema::isAttrOrAttrGroup(const DOMElement* const elem) {    const XMLCh* elementName = elem->getLocalName();    if (XMLString::equals(elementName, SchemaSymbols::fgELT_ATTRIBUTE) ||        XMLString::equals(elementName, SchemaSymbols::fgELT_ATTRIBUTEGROUP) ||        XMLString::equals(elementName, SchemaSymbols::fgELT_ANYATTRIBUTE)) {        return true;    }    return false;}inline const XMLCh* TraverseSchema::genAnonTypeName(const XMLCh* const prefix) {    XMLCh anonCountStr[16]; // a count of 15 digits should be enough    XMLString::binToText(fAnonXSTypeCount++, anonCountStr, 15, 10, fMemoryManager);    fBuffer.set(prefix);    fBuffer.append(anonCountStr);    return fStringPool->getValueForId(fStringPool->addOrFind(fBuffer.getRawBuffer()));}inline void TraverseSchema::popCurrentTypeNameStack() {    unsigned int stackSize = fCurrentTypeNameStack->size();    if (stackSize != 0) {        fCurrentTypeNameStack->removeElementAt(stackSize - 1);    }}inline voidTraverseSchema::copyWildCardData(const SchemaAttDef* const srcWildCard,                                 SchemaAttDef* const destWildCard) {    destWildCard->getAttName()->setURI(srcWildCard->getAttName()->getURI());    destWildCard->setType(srcWildCard->getType());    destWildCard->setDefaultType(srcWildCard->getDefaultType());}inline void TraverseSchema::getRedefineNewTypeName(const XMLCh* const oldTypeName,                                                   const int redefineCounter,                                                   XMLBuffer& newTypeName) {    newTypeName.set(oldTypeName);    for (int i=0; i < redefineCounter; i++) {        newTypeName.append(SchemaSymbols::fgRedefIdentifier);    }}XERCES_CPP_NAMESPACE_END#endif/**  * End of file TraverseSchema.hpp  */

⌨️ 快捷键说明

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