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