// --------------------------------------------------------------------------- // SchemaElementDecl: XMLElementDecl virtual interface implementation // --------------------------------------------------------------------------- XMLAttDef* SchemaElementDecl::findAttr(const XMLCh* const qName , const unsigned int uriId , const XMLCh* const baseName , const XMLCh* const prefix , const LookupOpts options , bool& wasAdded) const { if (fComplexTypeInfo) { return fComplexTypeInfo->findAttr(qName, uriId, baseName, prefix, options, wasAdded); } else { if (options == XMLElementDecl::AddIfNotFound) { SchemaAttDef* retVal = 0; // If no att list exist yet, then create one if (!fAttDefs) { // Use a hash modulus of 29 and tell it owns its elements ((SchemaElementDecl*)this)->fAttDefs = new (getMemoryManager()) RefHash2KeysTableOf<SchemaAttDef>(29, true, getMemoryManager()); } retVal = fAttDefs->get(baseName, uriId); // Fault it in if not found and ask to add it if (!retVal) { // And add a default attribute for this name retVal = new (getMemoryManager()) SchemaAttDef ( prefix , baseName , uriId , XMLAttDef::CData , XMLAttDef::Implied , getMemoryManager() ); retVal->setElemId(getId()); fAttDefs->put((void*)retVal->getAttName()->getLocalPart(), uriId, retVal); wasAdded = true; } else { wasAdded = false; } return retVal; } else { wasAdded = false; return 0; } } }
// --------------------------------------------------------------------------- // ComplexTypeInfo: Helper methods // --------------------------------------------------------------------------- XMLAttDef* ComplexTypeInfo::findAttr(const XMLCh* const , const unsigned int uriId , const XMLCh* const baseName , const XMLCh* const prefix , const XMLElementDecl::LookupOpts options , bool& wasAdded) const { SchemaAttDef* retVal = 0; // If no att list faulted in yet, then it cannot exist if (fAttDefs) retVal = fAttDefs->get(baseName, uriId); // Fault it in if not found and ask to add it if (!retVal && (options == XMLElementDecl::AddIfNotFound)) { // Fault in the list itself if not already if (!fAttDefs) faultInAttDefList(); // And add a default attribute for this name retVal = new (fMemoryManager) SchemaAttDef ( prefix , baseName , uriId , XMLAttDef::CData , XMLAttDef::Implied , fMemoryManager ); retVal->setElemId(getElementId()); fAttDefs->put((void*)retVal->getAttName()->getLocalPart(), uriId, retVal); // update and/or create fAttList if(!fAttList) ((ComplexTypeInfo*)this)->fAttList = new (fMemoryManager) SchemaAttDefList(fAttDefs,fMemoryManager); fAttList->addAttDef(retVal); wasAdded = true; } else { wasAdded = false; } return retVal; }