/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to parse/parabix.20090211/src/xmlmodel.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-16 09:27:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090216092717-wipyvaaw2srxhgns
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  xmlmodel.c - XML Model Processor
 
2
    Copyright (c) 2007, 2008 Robert D. Cameron
 
3
    Licensed to the public under the Open Software License 3.0.
 
4
    Licensed to International Characters, Inc., under the Academic
 
5
    Free License 3.0.
 
6
*/
 
7
 
 
8
 
 
9
#include "multiliteral.h"
 
10
#include "xmlmodel.h"
 
11
 
 
12
void Model_Info::SimpleEntity(char * entity_Name, char * replText) {
 
13
                
 
14
                int entity_NameID = symbol_table->Insert_Name(entity_Name, strlen(entity_Name));
 
15
                int entityID = GlobalGEntityTable[entity_NameID];
 
16
                if(entityID==0){        
 
17
                        GEntity_info * this_info = new GEntity_info;
 
18
                        GlobalGEntityTable[entity_NameID]=++(globalGEntityCount);
 
19
                        entityID = globalGEntityCount;
 
20
                
 
21
                        this_info->globalGEntity_id = entityID;
 
22
                        this_info->is_external = false;
 
23
                        this_info->ReplacementText = replText;
 
24
                        this_info->systemLiteral = NULL;
 
25
                        this_info->pubidLiteral = NULL; 
 
26
                        this_info->NDataName = NULL;
 
27
                        this_info->is_simple = true;
 
28
                        
 
29
                        GEntityData.push_back(this_info);
 
30
                }
 
31
}
 
32
Model_Info::Model_Info() {
 
33
        ElementAttributeData.push_back(vector<ATT_info *>());
 
34
        globalElementCount = 0;
 
35
        globalAttributeCount = 0;
 
36
        symbol_table = new Symbol_Table();
 
37
        SimpleEntity("lt", "<"); 
 
38
        SimpleEntity("gt", ">"); 
 
39
        SimpleEntity("amp", "&"); 
 
40
        SimpleEntity("quot", "\""); 
 
41
        SimpleEntity("apos", "'");      
 
42
}
 
43
 
 
44
 
 
45
Model_Info::~Model_Info() {
 
46
}
 
47
 
 
48
int Model_Info::getOrInsertGlobalElement(int elem_nameID) {
 
49
        int elemID =  GlobalElementTable[elem_nameID];
 
50
        if(elemID==0){  
 
51
                GlobalElementTable[elem_nameID]=++(globalElementCount);
 
52
                elemID = globalElementCount;
 
53
                
 
54
                ElementAttributeData.push_back(vector<ATT_info *>());
 
55
        }
 
56
        return elemID;
 
57
}
 
58
 
 
59
int Model_Info::getOrInsertGlobalAttName(int att_nameID){
 
60
                
 
61
        int attID = GlobalAttributeTable[att_nameID];
 
62
        if(attID==0){   
 
63
                GlobalAttributeTable[att_nameID]=++(globalAttributeCount);
 
64
                attID = globalAttributeCount;
 
65
        }
 
66
        return attID;
 
67
}