Exemplo n.º 1
0
DFNameMap *DFNameMapNew(void)
{
    DFNameMap *map = (DFNameMap *)xcalloc(1,sizeof(DFNameMap));
    map->namespacesByID = DFHashTableNew2(NULL,NULL,997);
    map->namespacesByURI = DFHashTableNew2(NULL,(DFFreeFunction)DFNamespaceInfoFree,997);
    map->tagsByID = DFHashTableNew2(NULL,(DFFreeFunction)DFTagInfoFree,997);
    map->nextNamespaceId = PREDEFINED_NAMESPACE_COUNT;
    map->nextTag = PREDEFINED_TAG_COUNT;
    map->localTagsByNameURI = DFNameHashTableNew();
    NameMap_staticInit();
    return map;
}
Exemplo n.º 2
0
static void NameMap_staticInit()
{
    if (defaultNamespacesByURI != NULL)
        return;
    defaultNamespacesByURI = DFHashTableNew2(NULL,NULL,997);
    defaultTagsByNameURI = DFNameHashTableNew();

    for (NamespaceID nsId = 1; nsId < PREDEFINED_NAMESPACE_COUNT; nsId++) {
        const NamespaceDecl *decl = &PredefinedNamespaces[nsId];

        const char *key = (const char *)decl->namespaceURI;
        assert(DFHashTableLookup(defaultNamespacesByURI,key) == NULL);
        DFNamespaceInfo *ns = DFNamespaceInfoNew(nsId,decl->namespaceURI,decl->prefix);
        DFHashTableAdd(defaultNamespacesByURI,key,ns);
    }
    for (Tag tag = MIN_ELEMENT_TAG; tag < PREDEFINED_TAG_COUNT; tag++) {
        const TagDecl *tagDecl = &PredefinedTags[tag];
        const NamespaceDecl *nsDecl = &PredefinedNamespaces[tagDecl->namespaceID];
        DFNameHashTableAdd(defaultTagsByNameURI,
                          tagDecl->localName,
                          nsDecl->namespaceURI,
                          tag,
                          tagDecl->namespaceID);
    }
}
Exemplo n.º 3
0
DFDocument *DFDocumentNew(void)
{
    DFDocument *doc = (DFDocument *)xcalloc(1,sizeof(DFDocument));
    doc->retainCount = 1;
    doc->allocator = DFAllocatorNew();
    doc->map = DFNameMapNew();
    doc->nodesByIdAttr = DFHashTableNew2(NULL,NULL,997);

    doc->nodesCount = 0;
    doc->nodesAlloc = 1;
    doc->nodes = (DFNode **)xmalloc(doc->nodesAlloc*sizeof(DFNode *));
    doc->docNode = DocumentCreateNode(doc,DOM_DOCUMENT);

    return doc;
}