29 TypesTable::TypesTable()
33 typesArray =
new XSDType *[nSize = 10];
66 TypesTable::~TypesTable()
77 std::map<std::string,int>::const_iterator it =
79 it != basicTypes.end();
91 for (map < string, int >::iterator it = Id.begin(); it != Id.end();
93 delete getTypePtr(it->second);
110 if (type_name.empty())
114 ostringstream tmp_name_str;
115 tmp_name_str <<
"type" << numTypes;
116 type_name = tmp_name_str.str();
125 if ((i = Id[type_name]) != 0)
137 Id[type_name] = currentId;
139 typesArray[numTypes] = type;
143 return currentId - 1;
151 int TypesTable::getTypeId(
const Qname & name,
bool create)
175 if (typeId == 0 && create)
182 typesArray[numTypes] = 0;
185 typeId = currentId - 1;
196 TypesTable::addExternalTypeId(
const Qname & type,
const XSDType * pType)
198 for (
unsigned int i = 0; i < extRefs_.size(); i++)
199 if (extRefs_[i].qname == type)
200 return extRefs_[i].localTypeId;
203 er.qname = (pType)?pType->
getQname():type;
204 er.localTypeId = currentId;
205 extRefs_.push_back(er);
207 typesArray[numTypes] =
const_cast<XSDType*
>(pType);
215 int TypesTable::addExtType(
XSDType * type,
int localId)
218 if (index >= numTypes)
220 typesArray[index] = type;
225 void TypesTable::ensureCapacity()
227 if (numTypes >= nSize)
230 for (
int ind = 0; ind < nSize; ind++)
231 tempArray[ind] = typesArray[ind];
233 typesArray = tempArray;
234 nSize = numTypes + 5;
250 int TypesTable::getCompleteXpath(
int elemId,
string & childName,
251 int *xPath,
int limits,
int &offset)
253 int childId = 0, type = 0, i = 0, childIndex;
255 if (xPath == 0 || limits == 0)
257 XSDType *pType = getTypePtr(elemId);
260 if (pType->isSimple())
262 ComplexType *ct = (ComplexType *) pType;
263 for (i = 0; i < ct->getNumChildren(); i++)
264 if (ct->getChildName(i) == childName)
266 childId = ct->getChildType(i);
276 for (
int i = 0; i < ct->getNumChildren() && !childId; i++)
279 getCompleteXpath(ct->getChildType(i), childName, xPath + 1,
280 limits - 1, ++offset))
290 xPath[0] = childIndex;
299 TypesTable::detectUndefinedTypes(
void)
301 for (
int i = 0; i < numTypes; i++)
302 if (typesArray[i] == 0)
309 TypesTable::resolveForwardElementRefs(
const string & name,
Element & e)
311 for (
int i = 0; i < numTypes; i++)
312 if (typesArray[i] != 0)
314 if (!typesArray[i]->isSimple())
324 TypesTable::resolveForwardAttributeRefs(
const string & name,
Attribute & a)
326 for (
int i = 0; i < numTypes; i++)
327 if (typesArray[i] != 0)
329 if (!typesArray[i]->isSimple())
339 TypesTable::printUndefinedTypes(ostream & out)
341 for (map < string, int >::iterator it = Id.begin(); it != Id.end();
344 if (getTypePtr(it->second) == 0)
345 out <<
"Could not find {"<<m_tnsUri <<
"}:" << it->first << std::endl;
350 TypesTable::getTypePtr(
int id)
const
std::string getLocalName(void) const
std::string getNamespace(void) const
void matchAttributeRef(const std::string &name, Attribute &a)
void matchElementRef(const std::string &name, Element &e)
virtual void setAnonymous(bool)
virtual void setTypeId(int)
virtual void setName(std::string)
const std::string SchemaUri