source: trunk/src/xmlmodel.h @ 163

Last change on this file since 163 was 163, checked in by cameron, 11 years ago

Restructuring: Document/Externalt? Entity Info into xmldecl.h

File size: 3.6 KB
Line 
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
33using namespace __gnu_cxx;
34using namespace std;
35
36#include "contentmodel.h"
37#include "symtab.h"
38
39
40/* Attribute Modeling */
41
42enum 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
46enum ATT_default_kind {REQUIRED_att, IMPLIED_att, FIXED_att, DEFAULT_att};
47/* Possible kinds of attribute default in ATTLIST declarations. */
48
49
50class ATT_info {
51public:
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
61class GEntity_info {
62public:
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
73class PEntity_info {
74public:
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
87class Notation_info {
88public:
89        char * systemLiteral;
90        char * pubidLiteral;   
91};
92
93
94class Model_Info {
95       
96public: 
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        /* Information computed from ATTLIST, ELEMENT, NOTATION and ENTITY declarations. */
105
106        hash_map<int, int > GlobalAttributeTable;
107        hash_map<int, int > GlobalElementTable;
108        hash_map<int, int > GlobalNotationTable;
109        hash_map<int, int > GlobalGEntityTable;
110        hash_map<int, int > GlobalPEntityTable;
111       
112       
113        int globalElementCount;
114        int globalAttributeCount;
115        int globalNotationCount;
116        int globalGEntityCount;
117        int globalPEntityCount;
118    /* For each element, we have an ElementAttributeModel */
119        vector<vector<ATT_info *> > ElementAttributeData;
120        int getOrInsertGlobalElement(int elem_nameID);
121        int getOrInsertGlobalAttName(int att_nameID);
122        // rootModel is a content model for the document root, consisting
123        // of a single occurrence of the element named in the DOCTYPE declaration.
124        CM_RegExp * rootModel;
125//      vector<ContentModel *> ContentModelData;
126        hash_map<int, ContentModel * > ContentModelData;
127       
128       
129        vector<GEntity_info *> GEntityData;
130        vector<PEntity_info *> PEntityData;
131        vector<Notation_info *> NotationData;
132       
133        void SimpleEntity(char * entity_Name, char * replText);
134};
135
136#endif /*XMLMODEL_H*/
Note: See TracBrowser for help on using the repository browser.