source: trunk/src/xmlmodel.h @ 1625

Last change on this file since 1625 was 267, checked in by ksherdy, 10 years ago

Construct and pass string literals as read only (const char *) types.

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        const 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
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(const char * entity_Name, const char * replText);
135};
136
137#endif /*XMLMODEL_H*/
Note: See TracBrowser for help on using the repository browser.