1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2004-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
%%
%% %CopyrightEnd%
%%
%% Contributor(s):
%% <[email protected]>: suggested #xmlDocument{}
%%
%%----------------------------------------------------------------------
%% #0. BASIC INFORMATION
%%----------------------------------------------------------------------
%% File: xmerl.hrl
%% Author : Ulf Wiger <[email protected]>
%% Date : 00-09-22
%% Description : Record and macro definitions for xmerl
%%----------------------------------------------------------------------
%% records generated by the scanner
%% --------------------------------
%% XML declaration
-record(xmlDecl,{
vsn, % string() XML version
encoding, % string() Character encoding
standalone, % (yes | no)
attributes % [#xmlAttribute()] Other attributes than above
}).
%% Attribute
-record(xmlAttribute,{
name, % atom()
expanded_name=[],% atom() | {string(),atom()}
nsinfo = [], % {Prefix, Local} | []
namespace = [], % inherits the element's namespace
parents = [], % [{atom(),integer()}]
pos, % integer()
language = [], % inherits the element's language
value, % IOlist() | atom() | integer()
normalized % atom() one of (true | false)
}).
%% namespace record
-record(xmlNamespace,{
default = [],
nodes = []
}).
%% namespace node - i.e. a {Prefix, URI} pair
-record(xmlNsNode,{
parents = [], % [{atom(),integer()}]
pos, % integer()
prefix, % string()
uri = [] % [] | atom()
}).
%% XML Element
%% content = [#xmlElement()|#xmlText()|#xmlPI()|#xmlComment()|#xmlDecl()]
-record(xmlElement,{
name, % atom()
expanded_name = [], % string() | {URI,Local} | {"xmlns",Local}
nsinfo = [], % {Prefix, Local} | []
namespace=#xmlNamespace{},
parents = [], % [{atom(),integer()}]
pos, % integer()
attributes = [], % [#xmlAttribute()]
content = [],
language = "", % string()
xmlbase="", % string() XML Base path, for relative URI:s
elementdef=undeclared % atom(), one of [undeclared | prolog | external | element]
}).
%% plain text
%% IOlist = [char() | binary () | IOlist]
-record(xmlText,{
parents = [], % [{atom(),integer()}]
pos, % integer()
language = [],% inherits the element's language
value, % IOlist()
type = text % atom() one of (text|cdata)
}).
%% plain text
-record(xmlComment,{
parents = [], % [{atom(),integer()}]
pos, % integer()
language = [], % inherits the element's language
value % IOlist()
}).
%% processing instruction
-record(xmlPI,{
name, % atom()
parents = [], % [{atom(),integer()}]
pos, % integer()
value % IOlist()
}).
-record(xmlDocument,{
content
}).
%% XPATH (xmerl_xpath, xmerl_pred_funcs) records
-record(xmlContext, {
axis_type = forward,
context_node,
context_position = 1,
nodeset = [],
bindings = [],
functions = [],
namespace = [],
whole_document
}).
-record(xmlNode, {
type = element,
node,
parents = [],
pos = 1
}).
-record(xmlObj, {
type,
value
}).
-record(xmerl_fun_states, {event,
hook,
rules,
fetch,
cont}).
%% scanner state record
-record(xmerl_scanner,{
encoding=undefined, % undefined | string() Character set used, default is UTF-8
standalone = no,
% prolog =continue,
environment = prolog, % atom(), (prolog | element)
declarations = [], % [{Name, Attrs}]
doctype_name,
doctype_DTD = internal, % internal | DTDId
comments = true,
document = false,
default_attrs = false,
rules,
keep_rules = false, % delete (ets) tab if false
namespace_conformant = false, % true | false
xmlbase, % string() Current Base path, for relative URI:s
xmlbase_cache, % string() Cached Base path
fetch_path=[], % [string()] List with additional, user
% defined, paths
filename=file_name_unknown,
validation = off, %% off (default) | dtd | schema (true, false are obsolete)
schemaLocation = [],
space = preserve,
event_fun,
hook_fun,
acc_fun,
fetch_fun,
close_fun,
continuation_fun,
rules_read_fun,
rules_write_fun,
rules_delete_fun,
user_state,
fun_states = #xmerl_fun_states{},
entity_references=[],
text_decl=false,
quiet=false, % bool() Set to true will print no error messages
col = 1,
line = 1,
common_data = []
}).
%% scanner events
%% event : start | end
-record(xmerl_event, {
event,
line,
col,
pos,
data
}).
%% useful scanner macros
%% ---------------------
-define(space, 32).
-define(cr, 13).
-define(lf, 10).
-define(tab, 9).
%% whitespace consists of 'space', 'carriage return', 'line feed' or 'tab'
-define(whitespace(H), H==?space ; H==?cr ; H==?lf ; H==?tab).
%% non-caharacters according to Unicode: 16#ffff and 16#fffe
-define(non_character(H1,H2), H1==16#ff,H2==16#fe;H1==16#ff,H2==16#ff).
-define(non_ascii(H), list(H),hd(H)>=128;integer(H),H>=128).
-define(strip1, {_, T1, S1} = strip(T, S)).
-define(strip2, {_, T2, S2} = strip(T1, S1)).
-define(strip3, {_, T3, S3} = strip(T2, S2)).
-define(strip4, {_, T4, S4} = strip(T3, S3)).
-define(strip5, {_, T5, S5} = strip(T4, S4)).
-define(strip6, {_, T6, S6} = strip(T5, S5)).
-define(strip7, {_, T7, S7} = strip(T6, S6)).
-define(strip8, {_, T8, S8} = strip(T7, S7)).
-define(strip9, {_, T9, S9} = strip(T8, S8)).
-define(strip10, {_, T10, S10} = strip(T9, S9)).
-define(condstrip1, {_, T1, S1} = condstrip(T, S, false)).
-define(condstrip2, {_, T2, S2} = condstrip(T1,S1,false)).
-define(condstrip3, {_, T3, S3} = condstrip(T2,S2,false)).
-define(condstrip4, {_, T4, S4} = condstrip(T3,S3,false)).
-define(bump_col(N),
?dbg("bump_col(~p), US = ~p~n", [N, S0#xmerl_scanner.user_state]),
S = S0#xmerl_scanner{col = S0#xmerl_scanner.col + N}).
|