📄 traverseschema.hpp
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */#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); void reportSchemaError(const DOMElement* const elem, const XMLException& except); // ----------------------------------------------------------------------- // 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?) * processAnnot - default is true, false if reprocessing a complex type * since we have already processed the 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, bool processAnnot = true); /** * 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. */ DatatypeValidator* findDTValidator(const DOMElement* const elem, const XMLCh* const derivedTypeName, const XMLCh* const baseTypeName, const int baseRefContext); const XMLCh* resolvePrefixToURI(const DOMElement* const elem, const XMLCh* const prefix); const XMLCh* resolvePrefixToURI(const DOMElement* const elem, const XMLCh* const prefix, const unsigned int namespaceDepth); /** * Return the prefix for a given rawname string * * Function allocated, caller managed (facm) - pointer to be deleted by * caller. */ const XMLCh* getPrefix(const XMLCh* const rawName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -