xsmodel.cpp
来自「IBM的解析xml的工具Xerces的源代码」· C++ 代码 · 共 881 行 · 第 1/3 页
CPP
881 行
// Loop through top-level attribute group definitions in the grammar... RefHashTableOf<XercesAttGroupInfo>* attGroupInfoRegistry = namespaceItem->fGrammar->getAttGroupInfoRegistry(); if(attGroupInfoRegistry) { RefHashTableOfEnumerator<XercesAttGroupInfo> attrGroupEnum = RefHashTableOfEnumerator<XercesAttGroupInfo> (attGroupInfoRegistry, false, fMemoryManager); while (attrGroupEnum.hasMoreElements()) { addComponentToNamespace ( namespaceItem , fObjFactory->createXSAttGroupDefinition ( &(attrGroupEnum.nextElement()), this ) , XSConstants::ATTRIBUTE_GROUP_DEFINITION - 1 ); } // end of attribute group loop } // Loop through top-level model group definitions in the grammar... RefHashTableOf<XercesGroupInfo>* groupInfoRegistry = namespaceItem->fGrammar->getGroupInfoRegistry(); if(groupInfoRegistry) { RefHashTableOfEnumerator<XercesGroupInfo> modelGroupEnum = RefHashTableOfEnumerator<XercesGroupInfo> (groupInfoRegistry, false, fMemoryManager); while (modelGroupEnum.hasMoreElements()) { addComponentToNamespace ( namespaceItem , fObjFactory->createXSModelGroupDefinition ( &(modelGroupEnum.nextElement()), this ) , XSConstants::MODEL_GROUP_DEFINITION - 1 ); } // end of model group loop } // Loop through notations in the grammar... NameIdPoolEnumerator<XMLNotationDecl> notationEnum = namespaceItem->fGrammar->getNotationEnumerator(); while (notationEnum.hasMoreElements()) { addComponentToNamespace ( namespaceItem , fObjFactory->addOrFind(&(notationEnum.nextElement()), this) , XSConstants::NOTATION_DECLARATION - 1 ); } // end of notation loop // Loop through annotations in the grammar... // As annotations are already created as XSAnnotations no need to create them // or store them in the XercesToXSMap. XSAnnotation* annot = namespaceItem->fGrammar->getAnnotation(); while (annot) { fXSAnnotationList->addElement(annot); namespaceItem->fXSAnnotationList->addElement(annot); addComponentToIdVector(annot, XSConstants::ANNOTATION -1); annot = annot->getNext(); } // end of annotation loop}// ---------------------------------------------------------------------------// XSModel: Access methods// ---------------------------------------------------------------------------/** * [schema components]: a list of top-level components, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>, * <code>TYPE_DEFINITION</code> and any other component type that * may be a property of a schema component. * @return A list of top-level definition of the specified type in * <code>objectType</code> or <code>null</code>. */XSNamedMap <XSObject> *XSModel::getComponents(XSConstants::COMPONENT_TYPE objectType){ return fComponentMap[objectType -1];}/** * Convenience method. Returns a list of top-level component declarations * that are defined within the specified namespace, i.e. element * declarations, attribute declarations, etc. * @param objectType The type of the declaration, i.e. * <code>ELEMENT_DECLARATION</code>. * @param compNamespace The namespace to which declaration belong or * <code>null</code> (for components with no target namespace). * @return A list of top-level definitions of the specified type in * <code>objectType</code> and defined in the specified * <code>namespace</code> or <code>null</code>. */XSNamedMap <XSObject> *XSModel::getComponentsByNamespace(XSConstants::COMPONENT_TYPE objectType, const XMLCh *compNamespace){ XSNamespaceItem* namespaceItem; if (compNamespace) namespaceItem = getNamespaceItem(compNamespace); else namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString); if (namespaceItem) return namespaceItem->getComponents(objectType); return 0;}/** * [annotations]: a set of annotations. */XSAnnotationList *XSModel::getAnnotations(){ return fXSAnnotationList;}/** * Convenience method. Returns a top-level element declaration. * @param name The name of the declaration. * @param compNamespace The namespace of the declaration, null if absent. * @return A top-level element declaration or <code>null</code> if such * declaration does not exist. */XSElementDeclaration *XSModel::getElementDeclaration(const XMLCh *name , const XMLCh *compNamespace){ XSNamespaceItem* namespaceItem; if (compNamespace) namespaceItem = getNamespaceItem(compNamespace); else namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString); if (namespaceItem) return namespaceItem->getElementDeclaration(name); return 0;}/** * Convenience method. Returns a top-level attribute declaration. * @param name The name of the declaration. * @param compNamespace The namespace of the declaration, null if absent. * @return A top-level attribute declaration or <code>null</code> if such * declaration does not exist. */XSAttributeDeclaration *XSModel::getAttributeDeclaration(const XMLCh *name , const XMLCh *compNamespace){ XSNamespaceItem* namespaceItem; if (compNamespace) namespaceItem = getNamespaceItem(compNamespace); else namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString); if (namespaceItem) return namespaceItem->getAttributeDeclaration(name); return 0;}/** * Convenience method. Returns a top-level simple or complex type * definition. * @param name The name of the definition. * @param compNamespace The namespace of the declaration, null if absent. * @return An <code>XSTypeDefinition</code> or <code>null</code> if such * definition does not exist. */XSTypeDefinition *XSModel::getTypeDefinition(const XMLCh *name , const XMLCh *compNamespace){ XSNamespaceItem* namespaceItem; if (compNamespace) namespaceItem = getNamespaceItem(compNamespace); else namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString); if (namespaceItem) return namespaceItem->getTypeDefinition(name); return 0;}/** * Convenience method. Returns a top-level attribute group definition. * @param name The name of the definition. * @param compNamespace The namespace of the declaration, null if absent. * @return A top-level attribute group definition or <code>null</code> if * such definition does not exist. */XSAttributeGroupDefinition *XSModel::getAttributeGroup(const XMLCh *name , const XMLCh *compNamespace){ XSNamespaceItem* namespaceItem; if (compNamespace) namespaceItem = getNamespaceItem(compNamespace); else namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString); if (namespaceItem) return namespaceItem->getAttributeGroup(name); return 0;}/** * Convenience method. Returns a top-level model group definition. * @param name The name of the definition. * @param compNamespace The namespace of the declaration, null if absent. * @return A top-level model group definition definition or * <code>null</code> if such definition does not exist. */XSModelGroupDefinition *XSModel::getModelGroupDefinition(const XMLCh *name , const XMLCh *compNamespace){ XSNamespaceItem* namespaceItem; if (compNamespace) namespaceItem = getNamespaceItem(compNamespace); else namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString); if (namespaceItem) return namespaceItem->getModelGroupDefinition(name); return 0;}/** * Convenience method. Returns a top-level notation declaration. * @param name The name of the declaration. * @param compNamespace The namespace of the declaration, null if absent. * @return A top-level notation declaration or <code>null</code> if such * declaration does not exist. */XSNotationDeclaration *XSModel::getNotationDeclaration(const XMLCh *name , const XMLCh *compNamespace){ XSNamespaceItem* namespaceItem; if (compNamespace) namespaceItem = getNamespaceItem(compNamespace); else namespaceItem = getNamespaceItem(XMLUni::fgZeroLenString); if (namespaceItem) return namespaceItem->getNotationDeclaration(name); return 0;}/** * Optional. Return a component given a component type and a unique Id. * May not be supported for all component types. * @param compId unique Id of the component within its type * @param compType type of the component * @return the component of the given type with the given Id, or 0 * if no such component exists or this is unsupported for * this type of component. */XSObject *XSModel::getXSObjectById(unsigned int compId , XSConstants::COMPONENT_TYPE compType){ if (compId < fIdVector[compType -1]->size()) return fIdVector[compType -1]->elementAt(compId); return 0;}XSNamespaceItem* XSModel::getNamespaceItem(const XMLCh* const key){ XSNamespaceItem* xsName = fHashNamespace->get(key); if (xsName) return xsName; if (fParent) return fParent->getNamespaceItem(key); return 0;}XSObject* XSModel::getXSObject(void* key){ XSObject* xsObj = fObjFactory->getObjectFromMap(key); if (!xsObj && fParent) xsObj = fParent->getXSObject(key); return xsObj;}XERCES_CPP_NAMESPACE_END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?