node-opcua-xml2json 2.179.0 → 2.181.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/source/definition_parser.d.ts +1 -1
- package/dist/source/fragment_cloner.d.ts +1 -1
- package/dist/source/fragment_cloner.js +6 -3
- package/dist/source/fragment_cloner.js.map +1 -1
- package/dist/source/fragment_cloner_parser.d.ts +1 -1
- package/dist/source/fragment_cloner_parser.js +2 -2
- package/dist/source/fragment_cloner_parser.js.map +1 -1
- package/dist/source/index.d.ts +5 -5
- package/dist/source/index.js +5 -5
- package/dist/source/index.js.map +1 -1
- package/dist/source/nodejs/xml2json_fs.d.ts +1 -1
- package/dist/source/nodejs/xml2json_fs.js +2 -2
- package/dist/source/nodejs/xml2json_fs.js.map +1 -1
- package/dist/source/thirdparties/parser/lts.d.ts +17 -1
- package/dist/source/thirdparties/parser/lts.js +103 -14
- package/dist/source/thirdparties/parser/lts.js.map +1 -1
- package/dist/source/xml2Json_pojo_tools.d.ts +1 -1
- package/dist/source/xml2Json_pojo_tools.js +2 -2
- package/dist/source/xml2Json_pojo_tools.js.map +1 -1
- package/dist/source/xml2json.d.ts +19 -35
- package/dist/source/xml2json.js +180 -79
- package/dist/source/xml2json.js.map +1 -1
- package/dist/source/xml2json_pojo.d.ts +2 -2
- package/dist/source/xml2json_pojo.js +4 -4
- package/dist/source/xml2json_pojo.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/source/definition_parser.ts +1 -1
- package/source/fragment_cloner.ts +3 -2
- package/source/fragment_cloner_parser.ts +2 -2
- package/source/index.ts +5 -5
- package/source/nodejs/xml2json_fs.ts +1 -1
- package/source/thirdparties/parser/lts.ts +117 -16
- package/source/xml2Json_pojo_tools.ts +1 -1
- package/source/xml2json.ts +199 -83
- package/source/xml2json_pojo.ts +2 -2
package/dist/source/xml2json.js
CHANGED
|
@@ -6,25 +6,38 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.Xml2Json = exports.ReaderState = exports.ReaderStateBase = void 0;
|
|
8
8
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
-
const
|
|
9
|
+
const lts_js_1 = require("./thirdparties/parser/lts.js");
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* the reader states of a definition, in a table of this engine's own. A definition is a plain
|
|
12
|
+
* object the caller may hand to any number of parsers (the shared Definition reader of the
|
|
13
|
+
* nodeset loader, for one), while a reader state carries the element being read: its parent, its
|
|
14
|
+
* attributes, its text so far. So the definition is never written to; each parser builds its
|
|
15
|
+
* states from it. A definition that refers to itself, directly or through a child, gets one state
|
|
16
|
+
* per engine for the cycle, the one being built when the cycle closes.
|
|
12
17
|
* @private
|
|
13
|
-
|
|
14
|
-
* @param parser {map<ReaderState|options>}
|
|
15
|
-
* @return {map}
|
|
16
18
|
*/
|
|
17
19
|
function _coerceParser(parser) {
|
|
20
|
+
// no prototype: an element name is looked up in this table for every element of the document,
|
|
21
|
+
// one hash probe that cannot find an Object member by mistake
|
|
22
|
+
const table = Object.create(null);
|
|
23
|
+
if (!parser) {
|
|
24
|
+
return table;
|
|
25
|
+
}
|
|
18
26
|
for (const name of Object.keys(parser)) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
delete parser[name];
|
|
23
|
-
parser[name] = new ReaderState(tmp);
|
|
27
|
+
const entry = parser[name];
|
|
28
|
+
if (!entry) {
|
|
29
|
+
continue;
|
|
24
30
|
}
|
|
31
|
+
table[name] = entry instanceof ReaderState ? entry : (statesUnderConstruction.get(entry) ?? new ReaderState(entry));
|
|
25
32
|
}
|
|
26
|
-
return
|
|
33
|
+
return table;
|
|
27
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* the states being built from a definition, for the duration of one root construction: the way a
|
|
37
|
+
* definition that closes a cycle finds the state already under way instead of recursing for ever
|
|
38
|
+
*/
|
|
39
|
+
let statesUnderConstruction = new WeakMap();
|
|
40
|
+
let constructionDepth = 0;
|
|
28
41
|
// biome-ignore lint/suspicious/noUnsafeDeclarationMerging: interface adds typed members/overloads for this class
|
|
29
42
|
class ReaderStateBase {
|
|
30
43
|
}
|
|
@@ -47,18 +60,38 @@ class ReaderState extends ReaderStateBase {
|
|
|
47
60
|
engine;
|
|
48
61
|
parent;
|
|
49
62
|
root;
|
|
50
|
-
|
|
63
|
+
_data;
|
|
64
|
+
/** scratch space for the reader, fresh for every element it reads, allocated on first use */
|
|
65
|
+
get data() {
|
|
66
|
+
if (!this._data) {
|
|
67
|
+
this._data = {};
|
|
68
|
+
}
|
|
69
|
+
return this._data;
|
|
70
|
+
}
|
|
71
|
+
set data(value) {
|
|
72
|
+
this._data = value;
|
|
73
|
+
}
|
|
51
74
|
constructor(options) {
|
|
52
75
|
super();
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
76
|
+
if (options instanceof ReaderStateBase) {
|
|
77
|
+
this.parser = options.parser;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this._init = options.init;
|
|
81
|
+
this._finish = options.finish;
|
|
82
|
+
this._startElement = options.startElement;
|
|
83
|
+
this._endElement = options.endElement;
|
|
84
|
+
if (constructionDepth === 0) {
|
|
85
|
+
statesUnderConstruction = new WeakMap();
|
|
86
|
+
}
|
|
87
|
+
constructionDepth += 1;
|
|
88
|
+
try {
|
|
89
|
+
statesUnderConstruction.set(options, this);
|
|
90
|
+
this.parser = _coerceParser(options.parser);
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
constructionDepth -= 1;
|
|
60
94
|
}
|
|
61
|
-
this.parser = _coerceParser(options.parser);
|
|
62
95
|
}
|
|
63
96
|
/**
|
|
64
97
|
* @protected
|
|
@@ -67,7 +100,7 @@ class ReaderState extends ReaderStateBase {
|
|
|
67
100
|
this.name = elementName;
|
|
68
101
|
this.parent = parent;
|
|
69
102
|
this.engine = engine;
|
|
70
|
-
this.
|
|
103
|
+
this._data = undefined;
|
|
71
104
|
this.level = level;
|
|
72
105
|
this.currentLevel = this.level;
|
|
73
106
|
this.attrs = attrs;
|
|
@@ -94,8 +127,9 @@ class ReaderState extends ReaderStateBase {
|
|
|
94
127
|
if (this._startElement) {
|
|
95
128
|
this._startElement(elementName, attrs);
|
|
96
129
|
}
|
|
97
|
-
|
|
98
|
-
|
|
130
|
+
const child = this.parser[elementName];
|
|
131
|
+
if (this.engine && child) {
|
|
132
|
+
this.engine._promote(child, level, elementName, attrs);
|
|
99
133
|
}
|
|
100
134
|
}
|
|
101
135
|
/**
|
|
@@ -124,7 +158,7 @@ class ReaderState extends ReaderStateBase {
|
|
|
124
158
|
this.chunks = [];
|
|
125
159
|
// this is the end
|
|
126
160
|
this._on_finish();
|
|
127
|
-
if (this.parent instanceof ReaderState &&
|
|
161
|
+
if (this.parent instanceof ReaderState && this.parent.parser[elementName]) {
|
|
128
162
|
this.engine?._demote(this, level, elementName);
|
|
129
163
|
}
|
|
130
164
|
}
|
|
@@ -144,15 +178,20 @@ class ReaderState extends ReaderStateBase {
|
|
|
144
178
|
}
|
|
145
179
|
exports.ReaderState = ReaderState;
|
|
146
180
|
const regexp = /(([^:]+):)?(.*)/;
|
|
181
|
+
// a document uses a few dozen distinct element names, each of them thousands of times
|
|
182
|
+
const resolvedNames = new Map();
|
|
147
183
|
function resolve_namespace(name) {
|
|
184
|
+
const known = resolvedNames.get(name);
|
|
185
|
+
if (known) {
|
|
186
|
+
return known;
|
|
187
|
+
}
|
|
148
188
|
const m = name.match(regexp);
|
|
149
189
|
if (!m) {
|
|
150
190
|
throw new Error("Invalid match");
|
|
151
191
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
};
|
|
192
|
+
const resolved = { ns: m[2], tag: m[3] };
|
|
193
|
+
resolvedNames.set(name, resolved);
|
|
194
|
+
return resolved;
|
|
156
195
|
}
|
|
157
196
|
/**
|
|
158
197
|
*
|
|
@@ -187,21 +226,120 @@ function resolve_namespace(name) {
|
|
|
187
226
|
* done();
|
|
188
227
|
* });
|
|
189
228
|
*/
|
|
229
|
+
/** how many times a reader state is active at once, kept on the state itself */
|
|
230
|
+
const activations = Symbol("activations");
|
|
190
231
|
class Xml2Json {
|
|
191
232
|
currentLevel = 0;
|
|
233
|
+
// two parallel stacks rather than one record per element: an element is pushed and popped
|
|
234
|
+
// for each of the hundreds of thousands a nodeset carries
|
|
192
235
|
state_stack = [];
|
|
236
|
+
backup_stack = [];
|
|
193
237
|
current_state = null;
|
|
194
|
-
|
|
238
|
+
sax = null;
|
|
239
|
+
decoder = null;
|
|
240
|
+
atStart = false;
|
|
195
241
|
constructor(options) {
|
|
196
242
|
const state = options instanceof ReaderStateBase ? options : new ReaderState(options);
|
|
197
243
|
state.root = this;
|
|
198
244
|
this.state_stack = [];
|
|
245
|
+
this.backup_stack = [];
|
|
199
246
|
this.current_state = null;
|
|
200
247
|
this._promote(state, 0);
|
|
201
248
|
}
|
|
202
249
|
parseString(xml_text) {
|
|
203
250
|
return this.__parseInternal(xml_text);
|
|
204
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* parse a document that arrives in pieces: text, or UTF-8 bytes decoded as they come (a
|
|
254
|
+
* multi-byte character or the byte-order mark may straddle two chunks)
|
|
255
|
+
*/
|
|
256
|
+
async parseStream(chunks) {
|
|
257
|
+
this.begin();
|
|
258
|
+
for await (const chunk of chunks) {
|
|
259
|
+
this.write(chunk);
|
|
260
|
+
}
|
|
261
|
+
return this.end();
|
|
262
|
+
}
|
|
263
|
+
/** start a document that {@link write} will feed and {@link end} will finish */
|
|
264
|
+
begin() {
|
|
265
|
+
this.currentLevel = 0;
|
|
266
|
+
this.atStart = true;
|
|
267
|
+
this.decoder = null;
|
|
268
|
+
// direct handlers rather than events, and the blank runs between tags dropped by the
|
|
269
|
+
// parser before they are unescaped: see SaxLtxHandlers
|
|
270
|
+
const sax = new lts_js_1.SaxLtx({
|
|
271
|
+
skipBlankText: true,
|
|
272
|
+
onStartElement: (name, attrs) => {
|
|
273
|
+
const tag_ns = resolve_namespace(name);
|
|
274
|
+
this.currentLevel += 1;
|
|
275
|
+
if (this.current_state) {
|
|
276
|
+
this.current_state._on_startElement(this.currentLevel, tag_ns.tag, attrs);
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
onEndElement: (name) => {
|
|
280
|
+
const tag_ns = resolve_namespace(name);
|
|
281
|
+
if (this.current_state) {
|
|
282
|
+
this.current_state._on_endElement(this.currentLevel, tag_ns.tag);
|
|
283
|
+
}
|
|
284
|
+
this.currentLevel -= 1;
|
|
285
|
+
if (this.currentLevel === 0) {
|
|
286
|
+
sax.emit("close");
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
onText: (text) => {
|
|
290
|
+
// the reader state trims what it receives; nothing blank reaches this point
|
|
291
|
+
if (this.current_state) {
|
|
292
|
+
this.current_state._on_text(text);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
this.sax = sax;
|
|
297
|
+
}
|
|
298
|
+
/** feed the next piece of the document started by {@link begin} */
|
|
299
|
+
write(chunk) {
|
|
300
|
+
const sax = this.sax;
|
|
301
|
+
if (!sax) {
|
|
302
|
+
throw new Error("Xml2Json#write: begin() must be called first");
|
|
303
|
+
}
|
|
304
|
+
let text;
|
|
305
|
+
if (typeof chunk === "string") {
|
|
306
|
+
text = chunk;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
this.decoder = this.decoder || new TextDecoder("utf-8");
|
|
310
|
+
text = this.decoder.decode(chunk, { stream: true });
|
|
311
|
+
}
|
|
312
|
+
if (text.length === 0) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (this.atStart) {
|
|
316
|
+
this.atStart = false;
|
|
317
|
+
if (text.charCodeAt(0) === 0xfeff) {
|
|
318
|
+
text = text.slice(1);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
sax.write(text);
|
|
322
|
+
}
|
|
323
|
+
/** finish the document started by {@link begin} and return what the reader states built */
|
|
324
|
+
end() {
|
|
325
|
+
const sax = this.sax;
|
|
326
|
+
if (!sax) {
|
|
327
|
+
throw new Error("Xml2Json#end: begin() must be called first");
|
|
328
|
+
}
|
|
329
|
+
if (this.decoder) {
|
|
330
|
+
const tail = this.decoder.decode();
|
|
331
|
+
this.decoder = null;
|
|
332
|
+
if (tail.length > 0) {
|
|
333
|
+
sax.write(tail);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
sax.end("");
|
|
337
|
+
this.sax = null;
|
|
338
|
+
if (!this.current_state) {
|
|
339
|
+
return {};
|
|
340
|
+
}
|
|
341
|
+
return this.current_state._pojo;
|
|
342
|
+
}
|
|
205
343
|
/**
|
|
206
344
|
* @private
|
|
207
345
|
* @internal
|
|
@@ -212,12 +350,11 @@ class Xml2Json {
|
|
|
212
350
|
// active at two levels at once. This happens when a data type refers to itself, directly or
|
|
213
351
|
// indirectly: the reader of the nested element is then the very same object as the outer one.
|
|
214
352
|
// In that case only, take a copy of the outer activation and restore it in _demote.
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
353
|
+
const counted = new_state;
|
|
354
|
+
const active = counted[activations] || 0;
|
|
355
|
+
counted[activations] = active + 1;
|
|
356
|
+
this.state_stack.push(this.current_state);
|
|
357
|
+
this.backup_stack.push(active > 0 ? { ...new_state } : null);
|
|
221
358
|
const parent = this.current_state;
|
|
222
359
|
this.current_state = new_state;
|
|
223
360
|
// parent is null only for the root element; every _on_init implementation in this codebase
|
|
@@ -232,22 +369,17 @@ class Xml2Json {
|
|
|
232
369
|
*/
|
|
233
370
|
_demote(cur_state, level, elementName) {
|
|
234
371
|
/// assert(this.current_state === cur_state);
|
|
235
|
-
|
|
236
|
-
if (!popped) {
|
|
372
|
+
if (this.state_stack.length === 0) {
|
|
237
373
|
throw new Error("_demote called without a matching _promote");
|
|
238
374
|
}
|
|
239
|
-
const
|
|
375
|
+
const state = this.state_stack.pop();
|
|
376
|
+
const backup = this.backup_stack.pop();
|
|
240
377
|
this.current_state = state;
|
|
241
378
|
if (this.current_state) {
|
|
242
379
|
this.current_state._on_endElement2(level, elementName);
|
|
243
380
|
}
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
this.activation_count.delete(cur_state);
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
this.activation_count.set(cur_state, count);
|
|
250
|
-
}
|
|
381
|
+
const counted = cur_state;
|
|
382
|
+
counted[activations] = (counted[activations] || 1) - 1;
|
|
251
383
|
if (backup) {
|
|
252
384
|
// cur_state was a nested activation of a state that is still active at an outer level:
|
|
253
385
|
// put the outer element back the way it was. The parent has already consumed the nested
|
|
@@ -264,40 +396,9 @@ class Xml2Json {
|
|
|
264
396
|
* @internal
|
|
265
397
|
*/
|
|
266
398
|
__parseInternal(data) {
|
|
267
|
-
|
|
268
|
-
this.
|
|
269
|
-
|
|
270
|
-
const tag_ns = resolve_namespace(name);
|
|
271
|
-
this.currentLevel += 1;
|
|
272
|
-
if (this.current_state) {
|
|
273
|
-
this.current_state._on_startElement(this.currentLevel, tag_ns.tag, attrs);
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
parser.on("endElement", (name) => {
|
|
277
|
-
const tag_ns = resolve_namespace(name);
|
|
278
|
-
if (this.current_state) {
|
|
279
|
-
this.current_state._on_endElement(this.currentLevel, tag_ns.tag);
|
|
280
|
-
}
|
|
281
|
-
this.currentLevel -= 1;
|
|
282
|
-
if (this.currentLevel === 0) {
|
|
283
|
-
parser.emit("close");
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
parser.on("text", (text) => {
|
|
287
|
-
text = text.trim();
|
|
288
|
-
if (text.length === 0) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
if (this.current_state) {
|
|
292
|
-
this.current_state._on_text(text);
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
parser.write(data);
|
|
296
|
-
parser.end("");
|
|
297
|
-
if (!this.current_state) {
|
|
298
|
-
return {};
|
|
299
|
-
}
|
|
300
|
-
return this.current_state._pojo;
|
|
399
|
+
this.begin();
|
|
400
|
+
this.write(data);
|
|
401
|
+
return this.end();
|
|
301
402
|
}
|
|
302
403
|
}
|
|
303
404
|
exports.Xml2Json = Xml2Json;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml2json.js","sourceRoot":"","sources":["../../source/xml2json.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"xml2json.js","sourceRoot":"","sources":["../../source/xml2json.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAA2C;AAC3C,yDAAsD;AAStD;;;;;;;;GAQG;AACH,SAAS,aAAa,CAAC,MAA8B;IACjD,8FAA8F;IAC9F,8DAA8D;IAC9D,MAAM,KAAK,GAAW,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,SAAS;QACb,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACxH,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,IAAI,uBAAuB,GAAG,IAAI,OAAO,EAAsC,CAAC;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C;QACzE,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;QAC3B,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,OAAO,GAAG,SAA8B,CAAC;QAC/C,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACvD,IAAI,MAAM,EAAE,CAAC;YACT,uFAAuF;YACvF,wFAAwF;YACxF,2DAA2D;YAC3D,MAAM,eAAe,GAAG,SAA+C,CAAC;YACxE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;gBAC7C,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;YAChC,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC3C,CAAC;IACL,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,IAAY;QAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;CACJ;AA1LD,4BA0LC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type withPojoLambda } from "./xml2Json_pojo_tools";
|
|
2
|
-
import { type ReaderState, type ReaderStateParser, Xml2Json, type XmlAttributes } from "./xml2json";
|
|
1
|
+
import { type withPojoLambda } from "./xml2Json_pojo_tools.js";
|
|
2
|
+
import { type ReaderState, type ReaderStateParser, Xml2Json, type XmlAttributes } from "./xml2json.js";
|
|
3
3
|
export declare const json_parser: ReaderStateParser;
|
|
4
4
|
export declare function startPojo(pThis: ReaderState, elementName: string, attrs: XmlAttributes, withPojo: withPojoLambda): void;
|
|
5
5
|
export declare class Xml2JsonPojo extends Xml2Json {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Xml2JsonPojo = exports.json_parser = void 0;
|
|
4
4
|
exports.startPojo = startPojo;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const json_extractor = new
|
|
5
|
+
const xml2Json_pojo_tools_js_1 = require("./xml2Json_pojo_tools.js");
|
|
6
|
+
const xml2json_js_1 = require("./xml2json.js");
|
|
7
|
+
const json_extractor = new xml2Json_pojo_tools_js_1.ReaderState2();
|
|
8
8
|
exports.json_parser = {
|
|
9
9
|
init(elementName, attrs, parent, engine) {
|
|
10
10
|
json_extractor._on_init(elementName, attrs, parent, 0, engine);
|
|
@@ -23,7 +23,7 @@ function startPojo(pThis, elementName, attrs, withPojo) {
|
|
|
23
23
|
pThis.engine?._demote(json_extractor, pThis.engine?.currentLevel, elementName);
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
class Xml2JsonPojo extends
|
|
26
|
+
class Xml2JsonPojo extends xml2json_js_1.Xml2Json {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(json_extractor);
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xml2json_pojo.js","sourceRoot":"","sources":["../../source/xml2json_pojo.ts"],"names":[],"mappings":";;;AAgBA,8BAMC;AAtBD,+
|
|
1
|
+
{"version":3,"file":"xml2json_pojo.js","sourceRoot":"","sources":["../../source/xml2json_pojo.ts"],"names":[],"mappings":";;;AAgBA,8BAMC;AAtBD,qEAA6E;AAC7E,+CAA0H;AAE1H,MAAM,cAAc,GAAiB,IAAI,qCAAY,EAAE,CAAC;AAC3C,QAAA,WAAW,GAAsB;IAC1C,IAAI,CAAqB,WAAmB,EAAE,KAAoB,EAAE,MAAoB,EAAE,MAAgB;QACtG,cAAc,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACnE,CAAC;IACD,+FAA+F;IAC/F,sFAAsF;IACtF,gEAAgE;IAChE,MAAM;QACF,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC;IAC7C,CAAC;CACJ,CAAC;AAEF,SAAgB,SAAS,CAAC,KAAkB,EAAE,WAAmB,EAAE,KAAoB,EAAE,QAAwB;IAC7G,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IACvF,cAAc,CAAC,SAAS,GAAG,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE;QACvD,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACrB,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IACnF,CAAC,CAAC;AACN,CAAC;AAED,MAAa,YAAa,SAAQ,sBAAQ;IACtC;QACI,KAAK,CAAC,cAAmC,CAAC,CAAC;IAC/C,CAAC;CACJ;AAJD,oCAIC"}
|