XSAttributeGroupDefinition* XSObjectFactory::createXSAttGroupDefinition(XercesAttGroupInfo* const attGroupInfo, XSModel* const xsModel) { XSAttributeUseList* xsAttList = 0; XSWildcard* xsWildcard = 0; XMLSize_t attCount = attGroupInfo->attributeCount(); if (attCount) { xsAttList = new (fMemoryManager) RefVectorOf<XSAttributeUse>(attCount, false, fMemoryManager); for (XMLSize_t i=0; i < attCount; i++) { SchemaAttDef* attDef = attGroupInfo->attributeAt(i); XSAttributeDeclaration* xsAttDecl = 0; if (attDef->getBaseAttDecl()) xsAttDecl = addOrFind(attDef->getBaseAttDecl(), xsModel); else xsAttDecl = addOrFind(attDef, xsModel); if (xsAttDecl && (attDef->getDefaultType() != XMLAttDef::Prohibited)) // just for sanity { XSAttributeUse* attUse = createXSAttributeUse(xsAttDecl, xsModel); xsAttList->addElement(attUse); processAttUse(attDef, attUse); } } } if (attGroupInfo->getCompleteWildCard()) xsWildcard = createXSWildcard(attGroupInfo->getCompleteWildCard(), xsModel); XSAttributeGroupDefinition* xsObj = new (fMemoryManager) XSAttributeGroupDefinition ( attGroupInfo , xsAttList , xsWildcard , getAnnotationFromModel(xsModel, attGroupInfo) , xsModel , fMemoryManager ); fDeleteVector->addElement(xsObj); return xsObj; }
XSParticle* XSObjectFactory::createWildcardParticle(const ContentSpecNode* const rootNode, XSModel* const xsModel) { XSWildcard* xsWildcard = createXSWildcard(rootNode, xsModel); if (xsWildcard) { XSParticle* particle = new (fMemoryManager) XSParticle ( XSParticle::TERM_WILDCARD , xsModel , xsWildcard , rootNode->getMinOccurs() , rootNode->getMaxOccurs() , fMemoryManager ); return particle; } return 0; }
XSComplexTypeDefinition* XSObjectFactory::addOrFind(ComplexTypeInfo* const typeInfo, XSModel* const xsModel) { XSComplexTypeDefinition* xsObj = (XSComplexTypeDefinition*) xsModel->getXSObject(typeInfo); if (!xsObj) { XSWildcard* xsWildcard = 0; XSSimpleTypeDefinition* xsSimpleType = 0; XSAttributeUseList* xsAttList = 0; XSTypeDefinition* xsBaseType = 0; XSParticle* xsParticle = 0; if (typeInfo->getAttWildCard()) xsWildcard = createXSWildcard(typeInfo->getAttWildCard(), xsModel); if ((typeInfo->getContentType() == SchemaElementDecl::Simple) && (typeInfo->getDatatypeValidator())) xsSimpleType = addOrFind(typeInfo->getDatatypeValidator(), xsModel); XMLSize_t attCount=0; if (typeInfo->hasAttDefs()) { SchemaAttDefList& attDefList = (SchemaAttDefList&) typeInfo->getAttDefList(); attCount = attDefList.getAttDefCount(); xsAttList = new (fMemoryManager) RefVectorOf<XSAttributeUse>(attCount, false, fMemoryManager); // create list now put fill it in after we put complextype into map // otherwise we may encounter an infinite loop: complextype needs to // addorfind attdef, which does an addorfind on the enclosingCTdefintion. } // compute fBase bool isAnyType = false; if (typeInfo->getBaseComplexTypeInfo() == typeInfo) // case of anyType isAnyType = true; else if (typeInfo->getBaseComplexTypeInfo()) xsBaseType = addOrFind(typeInfo->getBaseComplexTypeInfo(), xsModel); else if (typeInfo->getBaseDatatypeValidator()) xsBaseType = addOrFind(typeInfo->getBaseDatatypeValidator(), xsModel); else // base is anyType xsBaseType = xsModel->getTypeDefinition(SchemaSymbols::fgATTVAL_ANYTYPE, SchemaSymbols::fgURI_SCHEMAFORSCHEMA); // compute particle ContentSpecNode* contentSpec = typeInfo->getContentSpec(); if (contentSpec) xsParticle = createModelGroupParticle(contentSpec, xsModel); xsObj = new (fMemoryManager) XSComplexTypeDefinition ( typeInfo , xsWildcard , xsSimpleType , xsAttList , xsBaseType , xsParticle , getAnnotationFromModel(xsModel, typeInfo) , xsModel , fMemoryManager ); putObjectInMap(typeInfo, xsObj); if (isAnyType) xsObj->setBaseType(xsObj); if (typeInfo->hasAttDefs()) { // now create the xsattributedeclarations... SchemaAttDefList& attDefList = (SchemaAttDefList&) typeInfo->getAttDefList(); for(unsigned int i=0; i<attCount; i++) { XSAttributeDeclaration* xsAttDecl = 0; SchemaAttDef& attDef = (SchemaAttDef&) attDefList.getAttDef(i); if (attDef.getBaseAttDecl()) { xsAttDecl = addOrFind(attDef.getBaseAttDecl(), xsModel); fXercesToXSMap->put(&attDef, xsAttDecl); } else xsAttDecl = addOrFind(&attDef, xsModel, xsObj); if (attDef.getDefaultType() != XMLAttDef::Prohibited) { XSAttributeUse* attUse = createXSAttributeUse(xsAttDecl, xsModel); xsAttList->addElement(attUse); processAttUse(&attDef, attUse); } } } // process local elements XMLSize_t elemCount = typeInfo->elementCount(); for (XMLSize_t j=0; j<elemCount; j++) { SchemaElementDecl* elemDecl = typeInfo->elementAt(j); if (elemDecl->getEnclosingScope() == typeInfo->getScopeDefined() && elemDecl->getPSVIScope() == PSVIDefs::SCP_LOCAL) addOrFind(elemDecl, xsModel, xsObj); } } return xsObj; }