/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.h

  • Committer: Suren A. Chilingaryan
  • Date: 2009-09-23 17:13:04 UTC
  • Revision ID: csa@dside.dyndns.org-20090923171304-osvtr4zqb29h11kd
Intel, Tango, Phobos, and RapidXML parsers; Memory benchmark scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  xmlmodel.h - 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
 
    The XML Model Processor gathers information that guides
8
 
    interpretation of an XML document as it is processed.
9
 
    This information arises from a variety of sources,
10
 
    including:
11
 
      (a) the document prolog, including
12
 
          (a1) the encoding signature,
13
 
          (a2) the XML declaration (or text declaration for
14
 
               external entities), and
15
 
          (a3) the Document Type Definition (internal and
16
 
               external subsets).
17
 
      FUTURE:
18
 
      (b) XML Schema documents (and/or Relax NG, Schematron)
19
 
      (c) XPath sets specifying information to retrieve.
20
 
*/
21
 
 
22
 
#ifndef XMLMODEL_H
23
 
#define XMLMODEL_H
24
 
 
25
 
//  Encoding signature, XML declaration processing included in xmldecl.h
26
 
#include "xmldecl.h"
27
 
 
28
 
#include <vector>
29
 
#include <iostream>
30
 
#include <string>
31
 
#include <ext/hash_map>
32
 
 
33
 
using namespace __gnu_cxx;
34
 
using namespace std;
35
 
 
36
 
#include "contentmodel.h"
37
 
#include "symtab.h"
38
 
 
39
 
 
40
 
/* Attribute Modeling */
41
 
 
42
 
enum ATT_type {CDATA_att, ID_att, IDREF_att, IDREFS_att, ENTITY_att, ENTITIES_att, 
43
 
               NMTOKEN_att, NMTOKENS_att, NOTATION_att, enumeration_att};
44
 
/* Possible attribute types as specified in ATTLIST declarations. */
45
 
 
46
 
enum ATT_default_kind {REQUIRED_att, IMPLIED_att, FIXED_att, DEFAULT_att};
47
 
/* Possible kinds of attribute default in ATTLIST declarations. */
48
 
 
49
 
 
50
 
class ATT_info {
51
 
public:
52
 
        int globalATT_id;
53
 
        ATT_type attType;
54
 
        hash_map<int, int > enumValues; /* For NOTATION_att or enumeration_att.*/
55
 
        ATT_default_kind defaultKind;
56
 
        unsigned char * defaultValue;
57
 
        int defaultValueLgth;
58
 
};
59
 
 
60
 
 
61
 
class GEntity_info {
62
 
public:
63
 
        int globalGEntity_id;
64
 
        bool is_external;
65
 
        char * ReplacementText;
66
 
        char * systemLiteral;
67
 
        char * pubidLiteral;    
68
 
        char * NDataName;
69
 
        bool is_simple;
70
 
        
71
 
};
72
 
 
73
 
class PEntity_info {
74
 
public:
75
 
        int globalPEntity_id;
76
 
        bool is_external;
77
 
        char * ReplacementText;
78
 
        char * systemLiteral;
79
 
        char * pubidLiteral;    
80
 
};
81
 
 
82
 
/* The complete Attribute model for a given element is a vector of ATT_info
83
 
   specifications for particular attribute names. */
84
 
//typedef vector<ATT_info> ElementAttributeModel;
85
 
 
86
 
 
87
 
class Notation_info {
88
 
public:
89
 
        char * systemLiteral;
90
 
        char * pubidLiteral;    
91
 
};
92
 
 
93
 
 
94
 
class Model_Info {
95
 
        
96
 
public: 
97
 
        Model_Info();
98
 
        ~Model_Info();
99
 
        bool has_external_DTD;
100
 
        char * external_DTD_systemLiteral;
101
 
        char * external_DTD_pubidLiteral;       
102
 
        Symbol_Table * symbol_table;
103
 
        
104
 
   
105
 
        /* Information computed from ATTLIST, ELEMENT, NOTATION and ENTITY declarations. */
106
 
 
107
 
        hash_map<int, int > GlobalAttributeTable;
108
 
        hash_map<int, int > GlobalElementTable;
109
 
        hash_map<int, int > GlobalNotationTable;
110
 
        hash_map<int, int > GlobalGEntityTable;
111
 
        hash_map<int, int > GlobalPEntityTable;
112
 
        
113
 
        
114
 
        int globalElementCount;
115
 
        int globalAttributeCount;
116
 
        int globalNotationCount;
117
 
        int globalGEntityCount;
118
 
        int globalPEntityCount;
119
 
    /* For each element, we have an ElementAttributeModel */
120
 
        vector<vector<ATT_info *> > ElementAttributeData;
121
 
        int getOrInsertGlobalElement(int elem_nameID);
122
 
        int getOrInsertGlobalAttName(int att_nameID);
123
 
        // rootModel is a content model for the document root, consisting
124
 
        // of a single occurrence of the element named in the DOCTYPE declaration.
125
 
        CM_RegExp * rootModel;
126
 
//      vector<ContentModel *> ContentModelData;
127
 
        hash_map<int, ContentModel * > ContentModelData;
128
 
        
129
 
        
130
 
        vector<GEntity_info *> GEntityData;
131
 
        vector<PEntity_info *> PEntityData;
132
 
        vector<Notation_info *> NotationData;
133
 
        
134
 
        void SimpleEntity(char * entity_Name, char * replText);
135
 
};
136
 
 
137
 
#endif /*XMLMODEL_H*/