Ejemplo n.º 1
0
int TypesTable::typeId(const QualifiedName &name, bool create)
{
    int typeId;

    if(name.nameSpace() == SchemaUri)      // this is one of the basic types
    {
        typeId = mBasicTypes[ name.localName() ];
        if(typeId == 0)    // if this is a basic type which is not mapped, treat as string
            typeId = XSDType::STRING;
    }
    else if(name.nameSpace() == mNameSpace)
        typeId = mUserTypes[ name.localName() ];
    else   // the type does not belong to this schema
    {
        return 0;
    }

    if(typeId == 0 && create)
    {
        // handle forward reference
        // create an id and return its value
        mUserTypes[name.localName()] = mCurrentId;
        mTypes.append(0);
        mCurrentId++;
        typeId = mCurrentId - 1;
    }

    return typeId;
}