convert-buddy-js 0.2.0 → 0.3.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/README.md +1 -1
- package/dist/{chunk-B44HYXEP.js → chunk-27H3T556.js} +11 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -2
- package/package.json +1 -1
- package/dist/chunk-VUNV25KB.js +0 -16
- package/dist/fxp-TCYZYIHZ.js +0 -1701
- package/dist/papaparse-4KNMW7KX.js +0 -1324
- package/dist/src-YEKAFGYK.js +0 -3001
- package/dist/sync-FQGEFK5M.js +0 -1492
package/dist/fxp-TCYZYIHZ.js
DELETED
|
@@ -1,1701 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__commonJS
|
|
3
|
-
} from "./chunk-VUNV25KB.js";
|
|
4
|
-
|
|
5
|
-
// ../../node_modules/fast-xml-parser/src/util.js
|
|
6
|
-
var require_util = __commonJS({
|
|
7
|
-
"../../node_modules/fast-xml-parser/src/util.js"(exports) {
|
|
8
|
-
"use strict";
|
|
9
|
-
var nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
10
|
-
var nameChar = nameStartChar + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
11
|
-
var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
|
|
12
|
-
var regexName = new RegExp("^" + nameRegexp + "$");
|
|
13
|
-
var getAllMatches = function(string, regex) {
|
|
14
|
-
const matches = [];
|
|
15
|
-
let match = regex.exec(string);
|
|
16
|
-
while (match) {
|
|
17
|
-
const allmatches = [];
|
|
18
|
-
allmatches.startIndex = regex.lastIndex - match[0].length;
|
|
19
|
-
const len = match.length;
|
|
20
|
-
for (let index = 0; index < len; index++) {
|
|
21
|
-
allmatches.push(match[index]);
|
|
22
|
-
}
|
|
23
|
-
matches.push(allmatches);
|
|
24
|
-
match = regex.exec(string);
|
|
25
|
-
}
|
|
26
|
-
return matches;
|
|
27
|
-
};
|
|
28
|
-
var isName = function(string) {
|
|
29
|
-
const match = regexName.exec(string);
|
|
30
|
-
return !(match === null || typeof match === "undefined");
|
|
31
|
-
};
|
|
32
|
-
exports.isExist = function(v) {
|
|
33
|
-
return typeof v !== "undefined";
|
|
34
|
-
};
|
|
35
|
-
exports.isEmptyObject = function(obj) {
|
|
36
|
-
return Object.keys(obj).length === 0;
|
|
37
|
-
};
|
|
38
|
-
exports.merge = function(target, a, arrayMode) {
|
|
39
|
-
if (a) {
|
|
40
|
-
const keys = Object.keys(a);
|
|
41
|
-
const len = keys.length;
|
|
42
|
-
for (let i = 0; i < len; i++) {
|
|
43
|
-
if (arrayMode === "strict") {
|
|
44
|
-
target[keys[i]] = [a[keys[i]]];
|
|
45
|
-
} else {
|
|
46
|
-
target[keys[i]] = a[keys[i]];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.getValue = function(v) {
|
|
52
|
-
if (exports.isExist(v)) {
|
|
53
|
-
return v;
|
|
54
|
-
} else {
|
|
55
|
-
return "";
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
exports.isName = isName;
|
|
59
|
-
exports.getAllMatches = getAllMatches;
|
|
60
|
-
exports.nameRegexp = nameRegexp;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// ../../node_modules/fast-xml-parser/src/validator.js
|
|
65
|
-
var require_validator = __commonJS({
|
|
66
|
-
"../../node_modules/fast-xml-parser/src/validator.js"(exports) {
|
|
67
|
-
"use strict";
|
|
68
|
-
var util = require_util();
|
|
69
|
-
var defaultOptions = {
|
|
70
|
-
allowBooleanAttributes: false,
|
|
71
|
-
//A tag can have attributes without any value
|
|
72
|
-
unpairedTags: []
|
|
73
|
-
};
|
|
74
|
-
exports.validate = function(xmlData, options) {
|
|
75
|
-
options = Object.assign({}, defaultOptions, options);
|
|
76
|
-
const tags = [];
|
|
77
|
-
let tagFound = false;
|
|
78
|
-
let reachedRoot = false;
|
|
79
|
-
if (xmlData[0] === "\uFEFF") {
|
|
80
|
-
xmlData = xmlData.substr(1);
|
|
81
|
-
}
|
|
82
|
-
for (let i = 0; i < xmlData.length; i++) {
|
|
83
|
-
if (xmlData[i] === "<" && xmlData[i + 1] === "?") {
|
|
84
|
-
i += 2;
|
|
85
|
-
i = readPI(xmlData, i);
|
|
86
|
-
if (i.err) return i;
|
|
87
|
-
} else if (xmlData[i] === "<") {
|
|
88
|
-
let tagStartPos = i;
|
|
89
|
-
i++;
|
|
90
|
-
if (xmlData[i] === "!") {
|
|
91
|
-
i = readCommentAndCDATA(xmlData, i);
|
|
92
|
-
continue;
|
|
93
|
-
} else {
|
|
94
|
-
let closingTag = false;
|
|
95
|
-
if (xmlData[i] === "/") {
|
|
96
|
-
closingTag = true;
|
|
97
|
-
i++;
|
|
98
|
-
}
|
|
99
|
-
let tagName = "";
|
|
100
|
-
for (; i < xmlData.length && xmlData[i] !== ">" && xmlData[i] !== " " && xmlData[i] !== " " && xmlData[i] !== "\n" && xmlData[i] !== "\r"; i++) {
|
|
101
|
-
tagName += xmlData[i];
|
|
102
|
-
}
|
|
103
|
-
tagName = tagName.trim();
|
|
104
|
-
if (tagName[tagName.length - 1] === "/") {
|
|
105
|
-
tagName = tagName.substring(0, tagName.length - 1);
|
|
106
|
-
i--;
|
|
107
|
-
}
|
|
108
|
-
if (!validateTagName(tagName)) {
|
|
109
|
-
let msg;
|
|
110
|
-
if (tagName.trim().length === 0) {
|
|
111
|
-
msg = "Invalid space after '<'.";
|
|
112
|
-
} else {
|
|
113
|
-
msg = "Tag '" + tagName + "' is an invalid name.";
|
|
114
|
-
}
|
|
115
|
-
return getErrorObject("InvalidTag", msg, getLineNumberForPosition(xmlData, i));
|
|
116
|
-
}
|
|
117
|
-
const result = readAttributeStr(xmlData, i);
|
|
118
|
-
if (result === false) {
|
|
119
|
-
return getErrorObject("InvalidAttr", "Attributes for '" + tagName + "' have open quote.", getLineNumberForPosition(xmlData, i));
|
|
120
|
-
}
|
|
121
|
-
let attrStr = result.value;
|
|
122
|
-
i = result.index;
|
|
123
|
-
if (attrStr[attrStr.length - 1] === "/") {
|
|
124
|
-
const attrStrStart = i - attrStr.length;
|
|
125
|
-
attrStr = attrStr.substring(0, attrStr.length - 1);
|
|
126
|
-
const isValid = validateAttributeString(attrStr, options);
|
|
127
|
-
if (isValid === true) {
|
|
128
|
-
tagFound = true;
|
|
129
|
-
} else {
|
|
130
|
-
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));
|
|
131
|
-
}
|
|
132
|
-
} else if (closingTag) {
|
|
133
|
-
if (!result.tagClosed) {
|
|
134
|
-
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' doesn't have proper closing.", getLineNumberForPosition(xmlData, i));
|
|
135
|
-
} else if (attrStr.trim().length > 0) {
|
|
136
|
-
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' can't have attributes or invalid starting.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
137
|
-
} else if (tags.length === 0) {
|
|
138
|
-
return getErrorObject("InvalidTag", "Closing tag '" + tagName + "' has not been opened.", getLineNumberForPosition(xmlData, tagStartPos));
|
|
139
|
-
} else {
|
|
140
|
-
const otg = tags.pop();
|
|
141
|
-
if (tagName !== otg.tagName) {
|
|
142
|
-
let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);
|
|
143
|
-
return getErrorObject(
|
|
144
|
-
"InvalidTag",
|
|
145
|
-
"Expected closing tag '" + otg.tagName + "' (opened in line " + openPos.line + ", col " + openPos.col + ") instead of closing tag '" + tagName + "'.",
|
|
146
|
-
getLineNumberForPosition(xmlData, tagStartPos)
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
if (tags.length == 0) {
|
|
150
|
-
reachedRoot = true;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
} else {
|
|
154
|
-
const isValid = validateAttributeString(attrStr, options);
|
|
155
|
-
if (isValid !== true) {
|
|
156
|
-
return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));
|
|
157
|
-
}
|
|
158
|
-
if (reachedRoot === true) {
|
|
159
|
-
return getErrorObject("InvalidXml", "Multiple possible root nodes found.", getLineNumberForPosition(xmlData, i));
|
|
160
|
-
} else if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
161
|
-
} else {
|
|
162
|
-
tags.push({ tagName, tagStartPos });
|
|
163
|
-
}
|
|
164
|
-
tagFound = true;
|
|
165
|
-
}
|
|
166
|
-
for (i++; i < xmlData.length; i++) {
|
|
167
|
-
if (xmlData[i] === "<") {
|
|
168
|
-
if (xmlData[i + 1] === "!") {
|
|
169
|
-
i++;
|
|
170
|
-
i = readCommentAndCDATA(xmlData, i);
|
|
171
|
-
continue;
|
|
172
|
-
} else if (xmlData[i + 1] === "?") {
|
|
173
|
-
i = readPI(xmlData, ++i);
|
|
174
|
-
if (i.err) return i;
|
|
175
|
-
} else {
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
} else if (xmlData[i] === "&") {
|
|
179
|
-
const afterAmp = validateAmpersand(xmlData, i);
|
|
180
|
-
if (afterAmp == -1)
|
|
181
|
-
return getErrorObject("InvalidChar", "char '&' is not expected.", getLineNumberForPosition(xmlData, i));
|
|
182
|
-
i = afterAmp;
|
|
183
|
-
} else {
|
|
184
|
-
if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {
|
|
185
|
-
return getErrorObject("InvalidXml", "Extra text at the end", getLineNumberForPosition(xmlData, i));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (xmlData[i] === "<") {
|
|
190
|
-
i--;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
if (isWhiteSpace(xmlData[i])) {
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
return getErrorObject("InvalidChar", "char '" + xmlData[i] + "' is not expected.", getLineNumberForPosition(xmlData, i));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (!tagFound) {
|
|
201
|
-
return getErrorObject("InvalidXml", "Start tag expected.", 1);
|
|
202
|
-
} else if (tags.length == 1) {
|
|
203
|
-
return getErrorObject("InvalidTag", "Unclosed tag '" + tags[0].tagName + "'.", getLineNumberForPosition(xmlData, tags[0].tagStartPos));
|
|
204
|
-
} else if (tags.length > 0) {
|
|
205
|
-
return getErrorObject("InvalidXml", "Invalid '" + JSON.stringify(tags.map((t) => t.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
206
|
-
}
|
|
207
|
-
return true;
|
|
208
|
-
};
|
|
209
|
-
function isWhiteSpace(char) {
|
|
210
|
-
return char === " " || char === " " || char === "\n" || char === "\r";
|
|
211
|
-
}
|
|
212
|
-
function readPI(xmlData, i) {
|
|
213
|
-
const start = i;
|
|
214
|
-
for (; i < xmlData.length; i++) {
|
|
215
|
-
if (xmlData[i] == "?" || xmlData[i] == " ") {
|
|
216
|
-
const tagname = xmlData.substr(start, i - start);
|
|
217
|
-
if (i > 5 && tagname === "xml") {
|
|
218
|
-
return getErrorObject("InvalidXml", "XML declaration allowed only at the start of the document.", getLineNumberForPosition(xmlData, i));
|
|
219
|
-
} else if (xmlData[i] == "?" && xmlData[i + 1] == ">") {
|
|
220
|
-
i++;
|
|
221
|
-
break;
|
|
222
|
-
} else {
|
|
223
|
-
continue;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return i;
|
|
228
|
-
}
|
|
229
|
-
function readCommentAndCDATA(xmlData, i) {
|
|
230
|
-
if (xmlData.length > i + 5 && xmlData[i + 1] === "-" && xmlData[i + 2] === "-") {
|
|
231
|
-
for (i += 3; i < xmlData.length; i++) {
|
|
232
|
-
if (xmlData[i] === "-" && xmlData[i + 1] === "-" && xmlData[i + 2] === ">") {
|
|
233
|
-
i += 2;
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
} else if (xmlData.length > i + 8 && xmlData[i + 1] === "D" && xmlData[i + 2] === "O" && xmlData[i + 3] === "C" && xmlData[i + 4] === "T" && xmlData[i + 5] === "Y" && xmlData[i + 6] === "P" && xmlData[i + 7] === "E") {
|
|
238
|
-
let angleBracketsCount = 1;
|
|
239
|
-
for (i += 8; i < xmlData.length; i++) {
|
|
240
|
-
if (xmlData[i] === "<") {
|
|
241
|
-
angleBracketsCount++;
|
|
242
|
-
} else if (xmlData[i] === ">") {
|
|
243
|
-
angleBracketsCount--;
|
|
244
|
-
if (angleBracketsCount === 0) {
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
} else if (xmlData.length > i + 9 && xmlData[i + 1] === "[" && xmlData[i + 2] === "C" && xmlData[i + 3] === "D" && xmlData[i + 4] === "A" && xmlData[i + 5] === "T" && xmlData[i + 6] === "A" && xmlData[i + 7] === "[") {
|
|
250
|
-
for (i += 8; i < xmlData.length; i++) {
|
|
251
|
-
if (xmlData[i] === "]" && xmlData[i + 1] === "]" && xmlData[i + 2] === ">") {
|
|
252
|
-
i += 2;
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return i;
|
|
258
|
-
}
|
|
259
|
-
var doubleQuote = '"';
|
|
260
|
-
var singleQuote = "'";
|
|
261
|
-
function readAttributeStr(xmlData, i) {
|
|
262
|
-
let attrStr = "";
|
|
263
|
-
let startChar = "";
|
|
264
|
-
let tagClosed = false;
|
|
265
|
-
for (; i < xmlData.length; i++) {
|
|
266
|
-
if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {
|
|
267
|
-
if (startChar === "") {
|
|
268
|
-
startChar = xmlData[i];
|
|
269
|
-
} else if (startChar !== xmlData[i]) {
|
|
270
|
-
} else {
|
|
271
|
-
startChar = "";
|
|
272
|
-
}
|
|
273
|
-
} else if (xmlData[i] === ">") {
|
|
274
|
-
if (startChar === "") {
|
|
275
|
-
tagClosed = true;
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
attrStr += xmlData[i];
|
|
280
|
-
}
|
|
281
|
-
if (startChar !== "") {
|
|
282
|
-
return false;
|
|
283
|
-
}
|
|
284
|
-
return {
|
|
285
|
-
value: attrStr,
|
|
286
|
-
index: i,
|
|
287
|
-
tagClosed
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
var validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
291
|
-
function validateAttributeString(attrStr, options) {
|
|
292
|
-
const matches = util.getAllMatches(attrStr, validAttrStrRegxp);
|
|
293
|
-
const attrNames = {};
|
|
294
|
-
for (let i = 0; i < matches.length; i++) {
|
|
295
|
-
if (matches[i][1].length === 0) {
|
|
296
|
-
return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
|
|
297
|
-
} else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
|
|
298
|
-
return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
|
|
299
|
-
} else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
|
|
300
|
-
return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
|
|
301
|
-
}
|
|
302
|
-
const attrName = matches[i][2];
|
|
303
|
-
if (!validateAttrName(attrName)) {
|
|
304
|
-
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
|
|
305
|
-
}
|
|
306
|
-
if (!attrNames.hasOwnProperty(attrName)) {
|
|
307
|
-
attrNames[attrName] = 1;
|
|
308
|
-
} else {
|
|
309
|
-
return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
function validateNumberAmpersand(xmlData, i) {
|
|
315
|
-
let re = /\d/;
|
|
316
|
-
if (xmlData[i] === "x") {
|
|
317
|
-
i++;
|
|
318
|
-
re = /[\da-fA-F]/;
|
|
319
|
-
}
|
|
320
|
-
for (; i < xmlData.length; i++) {
|
|
321
|
-
if (xmlData[i] === ";")
|
|
322
|
-
return i;
|
|
323
|
-
if (!xmlData[i].match(re))
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
return -1;
|
|
327
|
-
}
|
|
328
|
-
function validateAmpersand(xmlData, i) {
|
|
329
|
-
i++;
|
|
330
|
-
if (xmlData[i] === ";")
|
|
331
|
-
return -1;
|
|
332
|
-
if (xmlData[i] === "#") {
|
|
333
|
-
i++;
|
|
334
|
-
return validateNumberAmpersand(xmlData, i);
|
|
335
|
-
}
|
|
336
|
-
let count = 0;
|
|
337
|
-
for (; i < xmlData.length; i++, count++) {
|
|
338
|
-
if (xmlData[i].match(/\w/) && count < 20)
|
|
339
|
-
continue;
|
|
340
|
-
if (xmlData[i] === ";")
|
|
341
|
-
break;
|
|
342
|
-
return -1;
|
|
343
|
-
}
|
|
344
|
-
return i;
|
|
345
|
-
}
|
|
346
|
-
function getErrorObject(code, message, lineNumber) {
|
|
347
|
-
return {
|
|
348
|
-
err: {
|
|
349
|
-
code,
|
|
350
|
-
msg: message,
|
|
351
|
-
line: lineNumber.line || lineNumber,
|
|
352
|
-
col: lineNumber.col
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
function validateAttrName(attrName) {
|
|
357
|
-
return util.isName(attrName);
|
|
358
|
-
}
|
|
359
|
-
function validateTagName(tagname) {
|
|
360
|
-
return util.isName(tagname);
|
|
361
|
-
}
|
|
362
|
-
function getLineNumberForPosition(xmlData, index) {
|
|
363
|
-
const lines = xmlData.substring(0, index).split(/\r?\n/);
|
|
364
|
-
return {
|
|
365
|
-
line: lines.length,
|
|
366
|
-
// column number is last line's length + 1, because column numbering starts at 1:
|
|
367
|
-
col: lines[lines.length - 1].length + 1
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
function getPositionFromMatch(match) {
|
|
371
|
-
return match.startIndex + match[1].length;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
// ../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js
|
|
377
|
-
var require_OptionsBuilder = __commonJS({
|
|
378
|
-
"../../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js"(exports) {
|
|
379
|
-
"use strict";
|
|
380
|
-
var defaultOptions = {
|
|
381
|
-
preserveOrder: false,
|
|
382
|
-
attributeNamePrefix: "@_",
|
|
383
|
-
attributesGroupName: false,
|
|
384
|
-
textNodeName: "#text",
|
|
385
|
-
ignoreAttributes: true,
|
|
386
|
-
removeNSPrefix: false,
|
|
387
|
-
// remove NS from tag name or attribute name if true
|
|
388
|
-
allowBooleanAttributes: false,
|
|
389
|
-
//a tag can have attributes without any value
|
|
390
|
-
//ignoreRootElement : false,
|
|
391
|
-
parseTagValue: true,
|
|
392
|
-
parseAttributeValue: false,
|
|
393
|
-
trimValues: true,
|
|
394
|
-
//Trim string values of tag and attributes
|
|
395
|
-
cdataPropName: false,
|
|
396
|
-
numberParseOptions: {
|
|
397
|
-
hex: true,
|
|
398
|
-
leadingZeros: true,
|
|
399
|
-
eNotation: true
|
|
400
|
-
},
|
|
401
|
-
tagValueProcessor: function(tagName, val) {
|
|
402
|
-
return val;
|
|
403
|
-
},
|
|
404
|
-
attributeValueProcessor: function(attrName, val) {
|
|
405
|
-
return val;
|
|
406
|
-
},
|
|
407
|
-
stopNodes: [],
|
|
408
|
-
//nested tags will not be parsed even for errors
|
|
409
|
-
alwaysCreateTextNode: false,
|
|
410
|
-
isArray: () => false,
|
|
411
|
-
commentPropName: false,
|
|
412
|
-
unpairedTags: [],
|
|
413
|
-
processEntities: true,
|
|
414
|
-
htmlEntities: false,
|
|
415
|
-
ignoreDeclaration: false,
|
|
416
|
-
ignorePiTags: false,
|
|
417
|
-
transformTagName: false,
|
|
418
|
-
transformAttributeName: false,
|
|
419
|
-
updateTag: function(tagName, jPath, attrs) {
|
|
420
|
-
return tagName;
|
|
421
|
-
}
|
|
422
|
-
// skipEmptyListItem: false
|
|
423
|
-
};
|
|
424
|
-
var buildOptions = function(options) {
|
|
425
|
-
return Object.assign({}, defaultOptions, options);
|
|
426
|
-
};
|
|
427
|
-
exports.buildOptions = buildOptions;
|
|
428
|
-
exports.defaultOptions = defaultOptions;
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
// ../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js
|
|
433
|
-
var require_xmlNode = __commonJS({
|
|
434
|
-
"../../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js"(exports, module) {
|
|
435
|
-
"use strict";
|
|
436
|
-
var XmlNode = class {
|
|
437
|
-
constructor(tagname) {
|
|
438
|
-
this.tagname = tagname;
|
|
439
|
-
this.child = [];
|
|
440
|
-
this[":@"] = {};
|
|
441
|
-
}
|
|
442
|
-
add(key, val) {
|
|
443
|
-
if (key === "__proto__") key = "#__proto__";
|
|
444
|
-
this.child.push({ [key]: val });
|
|
445
|
-
}
|
|
446
|
-
addChild(node) {
|
|
447
|
-
if (node.tagname === "__proto__") node.tagname = "#__proto__";
|
|
448
|
-
if (node[":@"] && Object.keys(node[":@"]).length > 0) {
|
|
449
|
-
this.child.push({ [node.tagname]: node.child, [":@"]: node[":@"] });
|
|
450
|
-
} else {
|
|
451
|
-
this.child.push({ [node.tagname]: node.child });
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
module.exports = XmlNode;
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
// ../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js
|
|
460
|
-
var require_DocTypeReader = __commonJS({
|
|
461
|
-
"../../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js"(exports, module) {
|
|
462
|
-
"use strict";
|
|
463
|
-
var util = require_util();
|
|
464
|
-
function readDocType(xmlData, i) {
|
|
465
|
-
const entities = {};
|
|
466
|
-
if (xmlData[i + 3] === "O" && xmlData[i + 4] === "C" && xmlData[i + 5] === "T" && xmlData[i + 6] === "Y" && xmlData[i + 7] === "P" && xmlData[i + 8] === "E") {
|
|
467
|
-
i = i + 9;
|
|
468
|
-
let angleBracketsCount = 1;
|
|
469
|
-
let hasBody = false, comment = false;
|
|
470
|
-
let exp = "";
|
|
471
|
-
for (; i < xmlData.length; i++) {
|
|
472
|
-
if (xmlData[i] === "<" && !comment) {
|
|
473
|
-
if (hasBody && isEntity(xmlData, i)) {
|
|
474
|
-
i += 7;
|
|
475
|
-
let entityName, val;
|
|
476
|
-
[entityName, val, i] = readEntityExp(xmlData, i + 1);
|
|
477
|
-
if (val.indexOf("&") === -1)
|
|
478
|
-
entities[validateEntityName(entityName)] = {
|
|
479
|
-
regx: RegExp(`&${entityName};`, "g"),
|
|
480
|
-
val
|
|
481
|
-
};
|
|
482
|
-
} else if (hasBody && isElement(xmlData, i)) i += 8;
|
|
483
|
-
else if (hasBody && isAttlist(xmlData, i)) i += 8;
|
|
484
|
-
else if (hasBody && isNotation(xmlData, i)) i += 9;
|
|
485
|
-
else if (isComment) comment = true;
|
|
486
|
-
else throw new Error("Invalid DOCTYPE");
|
|
487
|
-
angleBracketsCount++;
|
|
488
|
-
exp = "";
|
|
489
|
-
} else if (xmlData[i] === ">") {
|
|
490
|
-
if (comment) {
|
|
491
|
-
if (xmlData[i - 1] === "-" && xmlData[i - 2] === "-") {
|
|
492
|
-
comment = false;
|
|
493
|
-
angleBracketsCount--;
|
|
494
|
-
}
|
|
495
|
-
} else {
|
|
496
|
-
angleBracketsCount--;
|
|
497
|
-
}
|
|
498
|
-
if (angleBracketsCount === 0) {
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
} else if (xmlData[i] === "[") {
|
|
502
|
-
hasBody = true;
|
|
503
|
-
} else {
|
|
504
|
-
exp += xmlData[i];
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
if (angleBracketsCount !== 0) {
|
|
508
|
-
throw new Error(`Unclosed DOCTYPE`);
|
|
509
|
-
}
|
|
510
|
-
} else {
|
|
511
|
-
throw new Error(`Invalid Tag instead of DOCTYPE`);
|
|
512
|
-
}
|
|
513
|
-
return { entities, i };
|
|
514
|
-
}
|
|
515
|
-
function readEntityExp(xmlData, i) {
|
|
516
|
-
let entityName = "";
|
|
517
|
-
for (; i < xmlData.length && (xmlData[i] !== "'" && xmlData[i] !== '"'); i++) {
|
|
518
|
-
entityName += xmlData[i];
|
|
519
|
-
}
|
|
520
|
-
entityName = entityName.trim();
|
|
521
|
-
if (entityName.indexOf(" ") !== -1) throw new Error("External entites are not supported");
|
|
522
|
-
const startChar = xmlData[i++];
|
|
523
|
-
let val = "";
|
|
524
|
-
for (; i < xmlData.length && xmlData[i] !== startChar; i++) {
|
|
525
|
-
val += xmlData[i];
|
|
526
|
-
}
|
|
527
|
-
return [entityName, val, i];
|
|
528
|
-
}
|
|
529
|
-
function isComment(xmlData, i) {
|
|
530
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "-" && xmlData[i + 3] === "-") return true;
|
|
531
|
-
return false;
|
|
532
|
-
}
|
|
533
|
-
function isEntity(xmlData, i) {
|
|
534
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "N" && xmlData[i + 4] === "T" && xmlData[i + 5] === "I" && xmlData[i + 6] === "T" && xmlData[i + 7] === "Y") return true;
|
|
535
|
-
return false;
|
|
536
|
-
}
|
|
537
|
-
function isElement(xmlData, i) {
|
|
538
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "E" && xmlData[i + 3] === "L" && xmlData[i + 4] === "E" && xmlData[i + 5] === "M" && xmlData[i + 6] === "E" && xmlData[i + 7] === "N" && xmlData[i + 8] === "T") return true;
|
|
539
|
-
return false;
|
|
540
|
-
}
|
|
541
|
-
function isAttlist(xmlData, i) {
|
|
542
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "A" && xmlData[i + 3] === "T" && xmlData[i + 4] === "T" && xmlData[i + 5] === "L" && xmlData[i + 6] === "I" && xmlData[i + 7] === "S" && xmlData[i + 8] === "T") return true;
|
|
543
|
-
return false;
|
|
544
|
-
}
|
|
545
|
-
function isNotation(xmlData, i) {
|
|
546
|
-
if (xmlData[i + 1] === "!" && xmlData[i + 2] === "N" && xmlData[i + 3] === "O" && xmlData[i + 4] === "T" && xmlData[i + 5] === "A" && xmlData[i + 6] === "T" && xmlData[i + 7] === "I" && xmlData[i + 8] === "O" && xmlData[i + 9] === "N") return true;
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
function validateEntityName(name) {
|
|
550
|
-
if (util.isName(name))
|
|
551
|
-
return name;
|
|
552
|
-
else
|
|
553
|
-
throw new Error(`Invalid entity name ${name}`);
|
|
554
|
-
}
|
|
555
|
-
module.exports = readDocType;
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
// ../../node_modules/strnum/strnum.js
|
|
560
|
-
var require_strnum = __commonJS({
|
|
561
|
-
"../../node_modules/strnum/strnum.js"(exports, module) {
|
|
562
|
-
"use strict";
|
|
563
|
-
var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;
|
|
564
|
-
var numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/;
|
|
565
|
-
var consider = {
|
|
566
|
-
hex: true,
|
|
567
|
-
// oct: false,
|
|
568
|
-
leadingZeros: true,
|
|
569
|
-
decimalPoint: ".",
|
|
570
|
-
eNotation: true
|
|
571
|
-
//skipLike: /regex/
|
|
572
|
-
};
|
|
573
|
-
function toNumber(str, options = {}) {
|
|
574
|
-
options = Object.assign({}, consider, options);
|
|
575
|
-
if (!str || typeof str !== "string") return str;
|
|
576
|
-
let trimmedStr = str.trim();
|
|
577
|
-
if (options.skipLike !== void 0 && options.skipLike.test(trimmedStr)) return str;
|
|
578
|
-
else if (str === "0") return 0;
|
|
579
|
-
else if (options.hex && hexRegex.test(trimmedStr)) {
|
|
580
|
-
return parse_int(trimmedStr, 16);
|
|
581
|
-
} else if (trimmedStr.search(/[eE]/) !== -1) {
|
|
582
|
-
const notation = trimmedStr.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);
|
|
583
|
-
if (notation) {
|
|
584
|
-
if (options.leadingZeros) {
|
|
585
|
-
trimmedStr = (notation[1] || "") + notation[3];
|
|
586
|
-
} else {
|
|
587
|
-
if (notation[2] === "0" && notation[3][0] === ".") {
|
|
588
|
-
} else {
|
|
589
|
-
return str;
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
return options.eNotation ? Number(trimmedStr) : str;
|
|
593
|
-
} else {
|
|
594
|
-
return str;
|
|
595
|
-
}
|
|
596
|
-
} else {
|
|
597
|
-
const match = numRegex.exec(trimmedStr);
|
|
598
|
-
if (match) {
|
|
599
|
-
const sign = match[1];
|
|
600
|
-
const leadingZeros = match[2];
|
|
601
|
-
let numTrimmedByZeros = trimZeros(match[3]);
|
|
602
|
-
if (!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== ".") return str;
|
|
603
|
-
else if (!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== ".") return str;
|
|
604
|
-
else if (options.leadingZeros && leadingZeros === str) return 0;
|
|
605
|
-
else {
|
|
606
|
-
const num = Number(trimmedStr);
|
|
607
|
-
const numStr = "" + num;
|
|
608
|
-
if (numStr.search(/[eE]/) !== -1) {
|
|
609
|
-
if (options.eNotation) return num;
|
|
610
|
-
else return str;
|
|
611
|
-
} else if (trimmedStr.indexOf(".") !== -1) {
|
|
612
|
-
if (numStr === "0" && numTrimmedByZeros === "") return num;
|
|
613
|
-
else if (numStr === numTrimmedByZeros) return num;
|
|
614
|
-
else if (sign && numStr === "-" + numTrimmedByZeros) return num;
|
|
615
|
-
else return str;
|
|
616
|
-
}
|
|
617
|
-
if (leadingZeros) {
|
|
618
|
-
return numTrimmedByZeros === numStr || sign + numTrimmedByZeros === numStr ? num : str;
|
|
619
|
-
} else {
|
|
620
|
-
return trimmedStr === numStr || trimmedStr === sign + numStr ? num : str;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
} else {
|
|
624
|
-
return str;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
function trimZeros(numStr) {
|
|
629
|
-
if (numStr && numStr.indexOf(".") !== -1) {
|
|
630
|
-
numStr = numStr.replace(/0+$/, "");
|
|
631
|
-
if (numStr === ".") numStr = "0";
|
|
632
|
-
else if (numStr[0] === ".") numStr = "0" + numStr;
|
|
633
|
-
else if (numStr[numStr.length - 1] === ".") numStr = numStr.substr(0, numStr.length - 1);
|
|
634
|
-
return numStr;
|
|
635
|
-
}
|
|
636
|
-
return numStr;
|
|
637
|
-
}
|
|
638
|
-
function parse_int(numStr, base) {
|
|
639
|
-
if (parseInt) return parseInt(numStr, base);
|
|
640
|
-
else if (Number.parseInt) return Number.parseInt(numStr, base);
|
|
641
|
-
else if (window && window.parseInt) return window.parseInt(numStr, base);
|
|
642
|
-
else throw new Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
643
|
-
}
|
|
644
|
-
module.exports = toNumber;
|
|
645
|
-
}
|
|
646
|
-
});
|
|
647
|
-
|
|
648
|
-
// ../../node_modules/fast-xml-parser/src/ignoreAttributes.js
|
|
649
|
-
var require_ignoreAttributes = __commonJS({
|
|
650
|
-
"../../node_modules/fast-xml-parser/src/ignoreAttributes.js"(exports, module) {
|
|
651
|
-
"use strict";
|
|
652
|
-
function getIgnoreAttributesFn(ignoreAttributes) {
|
|
653
|
-
if (typeof ignoreAttributes === "function") {
|
|
654
|
-
return ignoreAttributes;
|
|
655
|
-
}
|
|
656
|
-
if (Array.isArray(ignoreAttributes)) {
|
|
657
|
-
return (attrName) => {
|
|
658
|
-
for (const pattern of ignoreAttributes) {
|
|
659
|
-
if (typeof pattern === "string" && attrName === pattern) {
|
|
660
|
-
return true;
|
|
661
|
-
}
|
|
662
|
-
if (pattern instanceof RegExp && pattern.test(attrName)) {
|
|
663
|
-
return true;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
}
|
|
668
|
-
return () => false;
|
|
669
|
-
}
|
|
670
|
-
module.exports = getIgnoreAttributesFn;
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
// ../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js
|
|
675
|
-
var require_OrderedObjParser = __commonJS({
|
|
676
|
-
"../../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js"(exports, module) {
|
|
677
|
-
"use strict";
|
|
678
|
-
var util = require_util();
|
|
679
|
-
var xmlNode = require_xmlNode();
|
|
680
|
-
var readDocType = require_DocTypeReader();
|
|
681
|
-
var toNumber = require_strnum();
|
|
682
|
-
var getIgnoreAttributesFn = require_ignoreAttributes();
|
|
683
|
-
var OrderedObjParser = class {
|
|
684
|
-
constructor(options) {
|
|
685
|
-
this.options = options;
|
|
686
|
-
this.currentNode = null;
|
|
687
|
-
this.tagsNodeStack = [];
|
|
688
|
-
this.docTypeEntities = {};
|
|
689
|
-
this.lastEntities = {
|
|
690
|
-
"apos": { regex: /&(apos|#39|#x27);/g, val: "'" },
|
|
691
|
-
"gt": { regex: /&(gt|#62|#x3E);/g, val: ">" },
|
|
692
|
-
"lt": { regex: /&(lt|#60|#x3C);/g, val: "<" },
|
|
693
|
-
"quot": { regex: /&(quot|#34|#x22);/g, val: '"' }
|
|
694
|
-
};
|
|
695
|
-
this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" };
|
|
696
|
-
this.htmlEntities = {
|
|
697
|
-
"space": { regex: /&(nbsp|#160);/g, val: " " },
|
|
698
|
-
// "lt" : { regex: /&(lt|#60);/g, val: "<" },
|
|
699
|
-
// "gt" : { regex: /&(gt|#62);/g, val: ">" },
|
|
700
|
-
// "amp" : { regex: /&(amp|#38);/g, val: "&" },
|
|
701
|
-
// "quot" : { regex: /&(quot|#34);/g, val: "\"" },
|
|
702
|
-
// "apos" : { regex: /&(apos|#39);/g, val: "'" },
|
|
703
|
-
"cent": { regex: /&(cent|#162);/g, val: "\xA2" },
|
|
704
|
-
"pound": { regex: /&(pound|#163);/g, val: "\xA3" },
|
|
705
|
-
"yen": { regex: /&(yen|#165);/g, val: "\xA5" },
|
|
706
|
-
"euro": { regex: /&(euro|#8364);/g, val: "\u20AC" },
|
|
707
|
-
"copyright": { regex: /&(copy|#169);/g, val: "\xA9" },
|
|
708
|
-
"reg": { regex: /&(reg|#174);/g, val: "\xAE" },
|
|
709
|
-
"inr": { regex: /&(inr|#8377);/g, val: "\u20B9" },
|
|
710
|
-
"num_dec": { regex: /&#([0-9]{1,7});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },
|
|
711
|
-
"num_hex": { regex: /&#x([0-9a-fA-F]{1,6});/g, val: (_, str) => String.fromCharCode(Number.parseInt(str, 16)) }
|
|
712
|
-
};
|
|
713
|
-
this.addExternalEntities = addExternalEntities;
|
|
714
|
-
this.parseXml = parseXml;
|
|
715
|
-
this.parseTextData = parseTextData;
|
|
716
|
-
this.resolveNameSpace = resolveNameSpace;
|
|
717
|
-
this.buildAttributesMap = buildAttributesMap;
|
|
718
|
-
this.isItStopNode = isItStopNode;
|
|
719
|
-
this.replaceEntitiesValue = replaceEntitiesValue;
|
|
720
|
-
this.readStopNodeData = readStopNodeData;
|
|
721
|
-
this.saveTextToParentTag = saveTextToParentTag;
|
|
722
|
-
this.addChild = addChild;
|
|
723
|
-
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
function addExternalEntities(externalEntities) {
|
|
727
|
-
const entKeys = Object.keys(externalEntities);
|
|
728
|
-
for (let i = 0; i < entKeys.length; i++) {
|
|
729
|
-
const ent = entKeys[i];
|
|
730
|
-
this.lastEntities[ent] = {
|
|
731
|
-
regex: new RegExp("&" + ent + ";", "g"),
|
|
732
|
-
val: externalEntities[ent]
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
function parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {
|
|
737
|
-
if (val !== void 0) {
|
|
738
|
-
if (this.options.trimValues && !dontTrim) {
|
|
739
|
-
val = val.trim();
|
|
740
|
-
}
|
|
741
|
-
if (val.length > 0) {
|
|
742
|
-
if (!escapeEntities) val = this.replaceEntitiesValue(val);
|
|
743
|
-
const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);
|
|
744
|
-
if (newval === null || newval === void 0) {
|
|
745
|
-
return val;
|
|
746
|
-
} else if (typeof newval !== typeof val || newval !== val) {
|
|
747
|
-
return newval;
|
|
748
|
-
} else if (this.options.trimValues) {
|
|
749
|
-
return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
|
|
750
|
-
} else {
|
|
751
|
-
const trimmedVal = val.trim();
|
|
752
|
-
if (trimmedVal === val) {
|
|
753
|
-
return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);
|
|
754
|
-
} else {
|
|
755
|
-
return val;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
function resolveNameSpace(tagname) {
|
|
762
|
-
if (this.options.removeNSPrefix) {
|
|
763
|
-
const tags = tagname.split(":");
|
|
764
|
-
const prefix = tagname.charAt(0) === "/" ? "/" : "";
|
|
765
|
-
if (tags[0] === "xmlns") {
|
|
766
|
-
return "";
|
|
767
|
-
}
|
|
768
|
-
if (tags.length === 2) {
|
|
769
|
-
tagname = prefix + tags[1];
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
return tagname;
|
|
773
|
-
}
|
|
774
|
-
var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
775
|
-
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
776
|
-
if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
777
|
-
const matches = util.getAllMatches(attrStr, attrsRegx);
|
|
778
|
-
const len = matches.length;
|
|
779
|
-
const attrs = {};
|
|
780
|
-
for (let i = 0; i < len; i++) {
|
|
781
|
-
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
782
|
-
if (this.ignoreAttributesFn(attrName, jPath)) {
|
|
783
|
-
continue;
|
|
784
|
-
}
|
|
785
|
-
let oldVal = matches[i][4];
|
|
786
|
-
let aName = this.options.attributeNamePrefix + attrName;
|
|
787
|
-
if (attrName.length) {
|
|
788
|
-
if (this.options.transformAttributeName) {
|
|
789
|
-
aName = this.options.transformAttributeName(aName);
|
|
790
|
-
}
|
|
791
|
-
if (aName === "__proto__") aName = "#__proto__";
|
|
792
|
-
if (oldVal !== void 0) {
|
|
793
|
-
if (this.options.trimValues) {
|
|
794
|
-
oldVal = oldVal.trim();
|
|
795
|
-
}
|
|
796
|
-
oldVal = this.replaceEntitiesValue(oldVal);
|
|
797
|
-
const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);
|
|
798
|
-
if (newVal === null || newVal === void 0) {
|
|
799
|
-
attrs[aName] = oldVal;
|
|
800
|
-
} else if (typeof newVal !== typeof oldVal || newVal !== oldVal) {
|
|
801
|
-
attrs[aName] = newVal;
|
|
802
|
-
} else {
|
|
803
|
-
attrs[aName] = parseValue(
|
|
804
|
-
oldVal,
|
|
805
|
-
this.options.parseAttributeValue,
|
|
806
|
-
this.options.numberParseOptions
|
|
807
|
-
);
|
|
808
|
-
}
|
|
809
|
-
} else if (this.options.allowBooleanAttributes) {
|
|
810
|
-
attrs[aName] = true;
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
if (!Object.keys(attrs).length) {
|
|
815
|
-
return;
|
|
816
|
-
}
|
|
817
|
-
if (this.options.attributesGroupName) {
|
|
818
|
-
const attrCollection = {};
|
|
819
|
-
attrCollection[this.options.attributesGroupName] = attrs;
|
|
820
|
-
return attrCollection;
|
|
821
|
-
}
|
|
822
|
-
return attrs;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
var parseXml = function(xmlData) {
|
|
826
|
-
xmlData = xmlData.replace(/\r\n?/g, "\n");
|
|
827
|
-
const xmlObj = new xmlNode("!xml");
|
|
828
|
-
let currentNode = xmlObj;
|
|
829
|
-
let textData = "";
|
|
830
|
-
let jPath = "";
|
|
831
|
-
for (let i = 0; i < xmlData.length; i++) {
|
|
832
|
-
const ch = xmlData[i];
|
|
833
|
-
if (ch === "<") {
|
|
834
|
-
if (xmlData[i + 1] === "/") {
|
|
835
|
-
const closeIndex = findClosingIndex(xmlData, ">", i, "Closing Tag is not closed.");
|
|
836
|
-
let tagName = xmlData.substring(i + 2, closeIndex).trim();
|
|
837
|
-
if (this.options.removeNSPrefix) {
|
|
838
|
-
const colonIndex = tagName.indexOf(":");
|
|
839
|
-
if (colonIndex !== -1) {
|
|
840
|
-
tagName = tagName.substr(colonIndex + 1);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
if (this.options.transformTagName) {
|
|
844
|
-
tagName = this.options.transformTagName(tagName);
|
|
845
|
-
}
|
|
846
|
-
if (currentNode) {
|
|
847
|
-
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
848
|
-
}
|
|
849
|
-
const lastTagName = jPath.substring(jPath.lastIndexOf(".") + 1);
|
|
850
|
-
if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
851
|
-
throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
|
|
852
|
-
}
|
|
853
|
-
let propIndex = 0;
|
|
854
|
-
if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
|
|
855
|
-
propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
|
|
856
|
-
this.tagsNodeStack.pop();
|
|
857
|
-
} else {
|
|
858
|
-
propIndex = jPath.lastIndexOf(".");
|
|
859
|
-
}
|
|
860
|
-
jPath = jPath.substring(0, propIndex);
|
|
861
|
-
currentNode = this.tagsNodeStack.pop();
|
|
862
|
-
textData = "";
|
|
863
|
-
i = closeIndex;
|
|
864
|
-
} else if (xmlData[i + 1] === "?") {
|
|
865
|
-
let tagData = readTagExp(xmlData, i, false, "?>");
|
|
866
|
-
if (!tagData) throw new Error("Pi Tag is not closed.");
|
|
867
|
-
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
868
|
-
if (this.options.ignoreDeclaration && tagData.tagName === "?xml" || this.options.ignorePiTags) {
|
|
869
|
-
} else {
|
|
870
|
-
const childNode = new xmlNode(tagData.tagName);
|
|
871
|
-
childNode.add(this.options.textNodeName, "");
|
|
872
|
-
if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
|
|
873
|
-
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
|
|
874
|
-
}
|
|
875
|
-
this.addChild(currentNode, childNode, jPath);
|
|
876
|
-
}
|
|
877
|
-
i = tagData.closeIndex + 1;
|
|
878
|
-
} else if (xmlData.substr(i + 1, 3) === "!--") {
|
|
879
|
-
const endIndex = findClosingIndex(xmlData, "-->", i + 4, "Comment is not closed.");
|
|
880
|
-
if (this.options.commentPropName) {
|
|
881
|
-
const comment = xmlData.substring(i + 4, endIndex - 2);
|
|
882
|
-
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
883
|
-
currentNode.add(this.options.commentPropName, [{ [this.options.textNodeName]: comment }]);
|
|
884
|
-
}
|
|
885
|
-
i = endIndex;
|
|
886
|
-
} else if (xmlData.substr(i + 1, 2) === "!D") {
|
|
887
|
-
const result = readDocType(xmlData, i);
|
|
888
|
-
this.docTypeEntities = result.entities;
|
|
889
|
-
i = result.i;
|
|
890
|
-
} else if (xmlData.substr(i + 1, 2) === "![") {
|
|
891
|
-
const closeIndex = findClosingIndex(xmlData, "]]>", i, "CDATA is not closed.") - 2;
|
|
892
|
-
const tagExp = xmlData.substring(i + 9, closeIndex);
|
|
893
|
-
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
894
|
-
let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);
|
|
895
|
-
if (val == void 0) val = "";
|
|
896
|
-
if (this.options.cdataPropName) {
|
|
897
|
-
currentNode.add(this.options.cdataPropName, [{ [this.options.textNodeName]: tagExp }]);
|
|
898
|
-
} else {
|
|
899
|
-
currentNode.add(this.options.textNodeName, val);
|
|
900
|
-
}
|
|
901
|
-
i = closeIndex + 2;
|
|
902
|
-
} else {
|
|
903
|
-
let result = readTagExp(xmlData, i, this.options.removeNSPrefix);
|
|
904
|
-
let tagName = result.tagName;
|
|
905
|
-
const rawTagName = result.rawTagName;
|
|
906
|
-
let tagExp = result.tagExp;
|
|
907
|
-
let attrExpPresent = result.attrExpPresent;
|
|
908
|
-
let closeIndex = result.closeIndex;
|
|
909
|
-
if (this.options.transformTagName) {
|
|
910
|
-
tagName = this.options.transformTagName(tagName);
|
|
911
|
-
}
|
|
912
|
-
if (currentNode && textData) {
|
|
913
|
-
if (currentNode.tagname !== "!xml") {
|
|
914
|
-
textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
const lastTag = currentNode;
|
|
918
|
-
if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
|
|
919
|
-
currentNode = this.tagsNodeStack.pop();
|
|
920
|
-
jPath = jPath.substring(0, jPath.lastIndexOf("."));
|
|
921
|
-
}
|
|
922
|
-
if (tagName !== xmlObj.tagname) {
|
|
923
|
-
jPath += jPath ? "." + tagName : tagName;
|
|
924
|
-
}
|
|
925
|
-
if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
|
|
926
|
-
let tagContent = "";
|
|
927
|
-
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
928
|
-
if (tagName[tagName.length - 1] === "/") {
|
|
929
|
-
tagName = tagName.substr(0, tagName.length - 1);
|
|
930
|
-
jPath = jPath.substr(0, jPath.length - 1);
|
|
931
|
-
tagExp = tagName;
|
|
932
|
-
} else {
|
|
933
|
-
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
934
|
-
}
|
|
935
|
-
i = result.closeIndex;
|
|
936
|
-
} else if (this.options.unpairedTags.indexOf(tagName) !== -1) {
|
|
937
|
-
i = result.closeIndex;
|
|
938
|
-
} else {
|
|
939
|
-
const result2 = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);
|
|
940
|
-
if (!result2) throw new Error(`Unexpected end of ${rawTagName}`);
|
|
941
|
-
i = result2.i;
|
|
942
|
-
tagContent = result2.tagContent;
|
|
943
|
-
}
|
|
944
|
-
const childNode = new xmlNode(tagName);
|
|
945
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
946
|
-
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
947
|
-
}
|
|
948
|
-
if (tagContent) {
|
|
949
|
-
tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
|
|
950
|
-
}
|
|
951
|
-
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
952
|
-
childNode.add(this.options.textNodeName, tagContent);
|
|
953
|
-
this.addChild(currentNode, childNode, jPath);
|
|
954
|
-
} else {
|
|
955
|
-
if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
|
|
956
|
-
if (tagName[tagName.length - 1] === "/") {
|
|
957
|
-
tagName = tagName.substr(0, tagName.length - 1);
|
|
958
|
-
jPath = jPath.substr(0, jPath.length - 1);
|
|
959
|
-
tagExp = tagName;
|
|
960
|
-
} else {
|
|
961
|
-
tagExp = tagExp.substr(0, tagExp.length - 1);
|
|
962
|
-
}
|
|
963
|
-
if (this.options.transformTagName) {
|
|
964
|
-
tagName = this.options.transformTagName(tagName);
|
|
965
|
-
}
|
|
966
|
-
const childNode = new xmlNode(tagName);
|
|
967
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
968
|
-
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
969
|
-
}
|
|
970
|
-
this.addChild(currentNode, childNode, jPath);
|
|
971
|
-
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
972
|
-
} else {
|
|
973
|
-
const childNode = new xmlNode(tagName);
|
|
974
|
-
this.tagsNodeStack.push(currentNode);
|
|
975
|
-
if (tagName !== tagExp && attrExpPresent) {
|
|
976
|
-
childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
|
|
977
|
-
}
|
|
978
|
-
this.addChild(currentNode, childNode, jPath);
|
|
979
|
-
currentNode = childNode;
|
|
980
|
-
}
|
|
981
|
-
textData = "";
|
|
982
|
-
i = closeIndex;
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
} else {
|
|
986
|
-
textData += xmlData[i];
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
return xmlObj.child;
|
|
990
|
-
};
|
|
991
|
-
function addChild(currentNode, childNode, jPath) {
|
|
992
|
-
const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
|
|
993
|
-
if (result === false) {
|
|
994
|
-
} else if (typeof result === "string") {
|
|
995
|
-
childNode.tagname = result;
|
|
996
|
-
currentNode.addChild(childNode);
|
|
997
|
-
} else {
|
|
998
|
-
currentNode.addChild(childNode);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
var replaceEntitiesValue = function(val) {
|
|
1002
|
-
if (this.options.processEntities) {
|
|
1003
|
-
for (let entityName in this.docTypeEntities) {
|
|
1004
|
-
const entity = this.docTypeEntities[entityName];
|
|
1005
|
-
val = val.replace(entity.regx, entity.val);
|
|
1006
|
-
}
|
|
1007
|
-
for (let entityName in this.lastEntities) {
|
|
1008
|
-
const entity = this.lastEntities[entityName];
|
|
1009
|
-
val = val.replace(entity.regex, entity.val);
|
|
1010
|
-
}
|
|
1011
|
-
if (this.options.htmlEntities) {
|
|
1012
|
-
for (let entityName in this.htmlEntities) {
|
|
1013
|
-
const entity = this.htmlEntities[entityName];
|
|
1014
|
-
val = val.replace(entity.regex, entity.val);
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
val = val.replace(this.ampEntity.regex, this.ampEntity.val);
|
|
1018
|
-
}
|
|
1019
|
-
return val;
|
|
1020
|
-
};
|
|
1021
|
-
function saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {
|
|
1022
|
-
if (textData) {
|
|
1023
|
-
if (isLeafNode === void 0) isLeafNode = currentNode.child.length === 0;
|
|
1024
|
-
textData = this.parseTextData(
|
|
1025
|
-
textData,
|
|
1026
|
-
currentNode.tagname,
|
|
1027
|
-
jPath,
|
|
1028
|
-
false,
|
|
1029
|
-
currentNode[":@"] ? Object.keys(currentNode[":@"]).length !== 0 : false,
|
|
1030
|
-
isLeafNode
|
|
1031
|
-
);
|
|
1032
|
-
if (textData !== void 0 && textData !== "")
|
|
1033
|
-
currentNode.add(this.options.textNodeName, textData);
|
|
1034
|
-
textData = "";
|
|
1035
|
-
}
|
|
1036
|
-
return textData;
|
|
1037
|
-
}
|
|
1038
|
-
function isItStopNode(stopNodes, jPath, currentTagName) {
|
|
1039
|
-
const allNodesExp = "*." + currentTagName;
|
|
1040
|
-
for (const stopNodePath in stopNodes) {
|
|
1041
|
-
const stopNodeExp = stopNodes[stopNodePath];
|
|
1042
|
-
if (allNodesExp === stopNodeExp || jPath === stopNodeExp) return true;
|
|
1043
|
-
}
|
|
1044
|
-
return false;
|
|
1045
|
-
}
|
|
1046
|
-
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
|
|
1047
|
-
let attrBoundary;
|
|
1048
|
-
let tagExp = "";
|
|
1049
|
-
for (let index = i; index < xmlData.length; index++) {
|
|
1050
|
-
let ch = xmlData[index];
|
|
1051
|
-
if (attrBoundary) {
|
|
1052
|
-
if (ch === attrBoundary) attrBoundary = "";
|
|
1053
|
-
} else if (ch === '"' || ch === "'") {
|
|
1054
|
-
attrBoundary = ch;
|
|
1055
|
-
} else if (ch === closingChar[0]) {
|
|
1056
|
-
if (closingChar[1]) {
|
|
1057
|
-
if (xmlData[index + 1] === closingChar[1]) {
|
|
1058
|
-
return {
|
|
1059
|
-
data: tagExp,
|
|
1060
|
-
index
|
|
1061
|
-
};
|
|
1062
|
-
}
|
|
1063
|
-
} else {
|
|
1064
|
-
return {
|
|
1065
|
-
data: tagExp,
|
|
1066
|
-
index
|
|
1067
|
-
};
|
|
1068
|
-
}
|
|
1069
|
-
} else if (ch === " ") {
|
|
1070
|
-
ch = " ";
|
|
1071
|
-
}
|
|
1072
|
-
tagExp += ch;
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
function findClosingIndex(xmlData, str, i, errMsg) {
|
|
1076
|
-
const closingIndex = xmlData.indexOf(str, i);
|
|
1077
|
-
if (closingIndex === -1) {
|
|
1078
|
-
throw new Error(errMsg);
|
|
1079
|
-
} else {
|
|
1080
|
-
return closingIndex + str.length - 1;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
function readTagExp(xmlData, i, removeNSPrefix, closingChar = ">") {
|
|
1084
|
-
const result = tagExpWithClosingIndex(xmlData, i + 1, closingChar);
|
|
1085
|
-
if (!result) return;
|
|
1086
|
-
let tagExp = result.data;
|
|
1087
|
-
const closeIndex = result.index;
|
|
1088
|
-
const separatorIndex = tagExp.search(/\s/);
|
|
1089
|
-
let tagName = tagExp;
|
|
1090
|
-
let attrExpPresent = true;
|
|
1091
|
-
if (separatorIndex !== -1) {
|
|
1092
|
-
tagName = tagExp.substring(0, separatorIndex);
|
|
1093
|
-
tagExp = tagExp.substring(separatorIndex + 1).trimStart();
|
|
1094
|
-
}
|
|
1095
|
-
const rawTagName = tagName;
|
|
1096
|
-
if (removeNSPrefix) {
|
|
1097
|
-
const colonIndex = tagName.indexOf(":");
|
|
1098
|
-
if (colonIndex !== -1) {
|
|
1099
|
-
tagName = tagName.substr(colonIndex + 1);
|
|
1100
|
-
attrExpPresent = tagName !== result.data.substr(colonIndex + 1);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
return {
|
|
1104
|
-
tagName,
|
|
1105
|
-
tagExp,
|
|
1106
|
-
closeIndex,
|
|
1107
|
-
attrExpPresent,
|
|
1108
|
-
rawTagName
|
|
1109
|
-
};
|
|
1110
|
-
}
|
|
1111
|
-
function readStopNodeData(xmlData, tagName, i) {
|
|
1112
|
-
const startIndex = i;
|
|
1113
|
-
let openTagCount = 1;
|
|
1114
|
-
for (; i < xmlData.length; i++) {
|
|
1115
|
-
if (xmlData[i] === "<") {
|
|
1116
|
-
if (xmlData[i + 1] === "/") {
|
|
1117
|
-
const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);
|
|
1118
|
-
let closeTagName = xmlData.substring(i + 2, closeIndex).trim();
|
|
1119
|
-
if (closeTagName === tagName) {
|
|
1120
|
-
openTagCount--;
|
|
1121
|
-
if (openTagCount === 0) {
|
|
1122
|
-
return {
|
|
1123
|
-
tagContent: xmlData.substring(startIndex, i),
|
|
1124
|
-
i: closeIndex
|
|
1125
|
-
};
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
i = closeIndex;
|
|
1129
|
-
} else if (xmlData[i + 1] === "?") {
|
|
1130
|
-
const closeIndex = findClosingIndex(xmlData, "?>", i + 1, "StopNode is not closed.");
|
|
1131
|
-
i = closeIndex;
|
|
1132
|
-
} else if (xmlData.substr(i + 1, 3) === "!--") {
|
|
1133
|
-
const closeIndex = findClosingIndex(xmlData, "-->", i + 3, "StopNode is not closed.");
|
|
1134
|
-
i = closeIndex;
|
|
1135
|
-
} else if (xmlData.substr(i + 1, 2) === "![") {
|
|
1136
|
-
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
|
|
1137
|
-
i = closeIndex;
|
|
1138
|
-
} else {
|
|
1139
|
-
const tagData = readTagExp(xmlData, i, ">");
|
|
1140
|
-
if (tagData) {
|
|
1141
|
-
const openTagName = tagData && tagData.tagName;
|
|
1142
|
-
if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length - 1] !== "/") {
|
|
1143
|
-
openTagCount++;
|
|
1144
|
-
}
|
|
1145
|
-
i = tagData.closeIndex;
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
function parseValue(val, shouldParse, options) {
|
|
1152
|
-
if (shouldParse && typeof val === "string") {
|
|
1153
|
-
const newval = val.trim();
|
|
1154
|
-
if (newval === "true") return true;
|
|
1155
|
-
else if (newval === "false") return false;
|
|
1156
|
-
else return toNumber(val, options);
|
|
1157
|
-
} else {
|
|
1158
|
-
if (util.isExist(val)) {
|
|
1159
|
-
return val;
|
|
1160
|
-
} else {
|
|
1161
|
-
return "";
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
module.exports = OrderedObjParser;
|
|
1166
|
-
}
|
|
1167
|
-
});
|
|
1168
|
-
|
|
1169
|
-
// ../../node_modules/fast-xml-parser/src/xmlparser/node2json.js
|
|
1170
|
-
var require_node2json = __commonJS({
|
|
1171
|
-
"../../node_modules/fast-xml-parser/src/xmlparser/node2json.js"(exports) {
|
|
1172
|
-
"use strict";
|
|
1173
|
-
function prettify(node, options) {
|
|
1174
|
-
return compress(node, options);
|
|
1175
|
-
}
|
|
1176
|
-
function compress(arr, options, jPath) {
|
|
1177
|
-
let text;
|
|
1178
|
-
const compressedObj = {};
|
|
1179
|
-
for (let i = 0; i < arr.length; i++) {
|
|
1180
|
-
const tagObj = arr[i];
|
|
1181
|
-
const property = propName(tagObj);
|
|
1182
|
-
let newJpath = "";
|
|
1183
|
-
if (jPath === void 0) newJpath = property;
|
|
1184
|
-
else newJpath = jPath + "." + property;
|
|
1185
|
-
if (property === options.textNodeName) {
|
|
1186
|
-
if (text === void 0) text = tagObj[property];
|
|
1187
|
-
else text += "" + tagObj[property];
|
|
1188
|
-
} else if (property === void 0) {
|
|
1189
|
-
continue;
|
|
1190
|
-
} else if (tagObj[property]) {
|
|
1191
|
-
let val = compress(tagObj[property], options, newJpath);
|
|
1192
|
-
const isLeaf = isLeafTag(val, options);
|
|
1193
|
-
if (tagObj[":@"]) {
|
|
1194
|
-
assignAttributes(val, tagObj[":@"], newJpath, options);
|
|
1195
|
-
} else if (Object.keys(val).length === 1 && val[options.textNodeName] !== void 0 && !options.alwaysCreateTextNode) {
|
|
1196
|
-
val = val[options.textNodeName];
|
|
1197
|
-
} else if (Object.keys(val).length === 0) {
|
|
1198
|
-
if (options.alwaysCreateTextNode) val[options.textNodeName] = "";
|
|
1199
|
-
else val = "";
|
|
1200
|
-
}
|
|
1201
|
-
if (compressedObj[property] !== void 0 && compressedObj.hasOwnProperty(property)) {
|
|
1202
|
-
if (!Array.isArray(compressedObj[property])) {
|
|
1203
|
-
compressedObj[property] = [compressedObj[property]];
|
|
1204
|
-
}
|
|
1205
|
-
compressedObj[property].push(val);
|
|
1206
|
-
} else {
|
|
1207
|
-
if (options.isArray(property, newJpath, isLeaf)) {
|
|
1208
|
-
compressedObj[property] = [val];
|
|
1209
|
-
} else {
|
|
1210
|
-
compressedObj[property] = val;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
if (typeof text === "string") {
|
|
1216
|
-
if (text.length > 0) compressedObj[options.textNodeName] = text;
|
|
1217
|
-
} else if (text !== void 0) compressedObj[options.textNodeName] = text;
|
|
1218
|
-
return compressedObj;
|
|
1219
|
-
}
|
|
1220
|
-
function propName(obj) {
|
|
1221
|
-
const keys = Object.keys(obj);
|
|
1222
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1223
|
-
const key = keys[i];
|
|
1224
|
-
if (key !== ":@") return key;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
function assignAttributes(obj, attrMap, jpath, options) {
|
|
1228
|
-
if (attrMap) {
|
|
1229
|
-
const keys = Object.keys(attrMap);
|
|
1230
|
-
const len = keys.length;
|
|
1231
|
-
for (let i = 0; i < len; i++) {
|
|
1232
|
-
const atrrName = keys[i];
|
|
1233
|
-
if (options.isArray(atrrName, jpath + "." + atrrName, true, true)) {
|
|
1234
|
-
obj[atrrName] = [attrMap[atrrName]];
|
|
1235
|
-
} else {
|
|
1236
|
-
obj[atrrName] = attrMap[atrrName];
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
function isLeafTag(obj, options) {
|
|
1242
|
-
const { textNodeName } = options;
|
|
1243
|
-
const propCount = Object.keys(obj).length;
|
|
1244
|
-
if (propCount === 0) {
|
|
1245
|
-
return true;
|
|
1246
|
-
}
|
|
1247
|
-
if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
|
|
1248
|
-
return true;
|
|
1249
|
-
}
|
|
1250
|
-
return false;
|
|
1251
|
-
}
|
|
1252
|
-
exports.prettify = prettify;
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
|
|
1256
|
-
// ../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js
|
|
1257
|
-
var require_XMLParser = __commonJS({
|
|
1258
|
-
"../../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js"(exports, module) {
|
|
1259
|
-
"use strict";
|
|
1260
|
-
var { buildOptions } = require_OptionsBuilder();
|
|
1261
|
-
var OrderedObjParser = require_OrderedObjParser();
|
|
1262
|
-
var { prettify } = require_node2json();
|
|
1263
|
-
var validator = require_validator();
|
|
1264
|
-
var XMLParser = class {
|
|
1265
|
-
constructor(options) {
|
|
1266
|
-
this.externalEntities = {};
|
|
1267
|
-
this.options = buildOptions(options);
|
|
1268
|
-
}
|
|
1269
|
-
/**
|
|
1270
|
-
* Parse XML dats to JS object
|
|
1271
|
-
* @param {string|Buffer} xmlData
|
|
1272
|
-
* @param {boolean|Object} validationOption
|
|
1273
|
-
*/
|
|
1274
|
-
parse(xmlData, validationOption) {
|
|
1275
|
-
if (typeof xmlData === "string") {
|
|
1276
|
-
} else if (xmlData.toString) {
|
|
1277
|
-
xmlData = xmlData.toString();
|
|
1278
|
-
} else {
|
|
1279
|
-
throw new Error("XML data is accepted in String or Bytes[] form.");
|
|
1280
|
-
}
|
|
1281
|
-
if (validationOption) {
|
|
1282
|
-
if (validationOption === true) validationOption = {};
|
|
1283
|
-
const result = validator.validate(xmlData, validationOption);
|
|
1284
|
-
if (result !== true) {
|
|
1285
|
-
throw Error(`${result.err.msg}:${result.err.line}:${result.err.col}`);
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
const orderedObjParser = new OrderedObjParser(this.options);
|
|
1289
|
-
orderedObjParser.addExternalEntities(this.externalEntities);
|
|
1290
|
-
const orderedResult = orderedObjParser.parseXml(xmlData);
|
|
1291
|
-
if (this.options.preserveOrder || orderedResult === void 0) return orderedResult;
|
|
1292
|
-
else return prettify(orderedResult, this.options);
|
|
1293
|
-
}
|
|
1294
|
-
/**
|
|
1295
|
-
* Add Entity which is not by default supported by this library
|
|
1296
|
-
* @param {string} key
|
|
1297
|
-
* @param {string} value
|
|
1298
|
-
*/
|
|
1299
|
-
addEntity(key, value) {
|
|
1300
|
-
if (value.indexOf("&") !== -1) {
|
|
1301
|
-
throw new Error("Entity value can't have '&'");
|
|
1302
|
-
} else if (key.indexOf("&") !== -1 || key.indexOf(";") !== -1) {
|
|
1303
|
-
throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");
|
|
1304
|
-
} else if (value === "&") {
|
|
1305
|
-
throw new Error("An entity with value '&' is not permitted");
|
|
1306
|
-
} else {
|
|
1307
|
-
this.externalEntities[key] = value;
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
};
|
|
1311
|
-
module.exports = XMLParser;
|
|
1312
|
-
}
|
|
1313
|
-
});
|
|
1314
|
-
|
|
1315
|
-
// ../../node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js
|
|
1316
|
-
var require_orderedJs2Xml = __commonJS({
|
|
1317
|
-
"../../node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js"(exports, module) {
|
|
1318
|
-
"use strict";
|
|
1319
|
-
var EOL = "\n";
|
|
1320
|
-
function toXml(jArray, options) {
|
|
1321
|
-
let indentation = "";
|
|
1322
|
-
if (options.format && options.indentBy.length > 0) {
|
|
1323
|
-
indentation = EOL;
|
|
1324
|
-
}
|
|
1325
|
-
return arrToStr(jArray, options, "", indentation);
|
|
1326
|
-
}
|
|
1327
|
-
function arrToStr(arr, options, jPath, indentation) {
|
|
1328
|
-
let xmlStr = "";
|
|
1329
|
-
let isPreviousElementTag = false;
|
|
1330
|
-
for (let i = 0; i < arr.length; i++) {
|
|
1331
|
-
const tagObj = arr[i];
|
|
1332
|
-
const tagName = propName(tagObj);
|
|
1333
|
-
if (tagName === void 0) continue;
|
|
1334
|
-
let newJPath = "";
|
|
1335
|
-
if (jPath.length === 0) newJPath = tagName;
|
|
1336
|
-
else newJPath = `${jPath}.${tagName}`;
|
|
1337
|
-
if (tagName === options.textNodeName) {
|
|
1338
|
-
let tagText = tagObj[tagName];
|
|
1339
|
-
if (!isStopNode(newJPath, options)) {
|
|
1340
|
-
tagText = options.tagValueProcessor(tagName, tagText);
|
|
1341
|
-
tagText = replaceEntitiesValue(tagText, options);
|
|
1342
|
-
}
|
|
1343
|
-
if (isPreviousElementTag) {
|
|
1344
|
-
xmlStr += indentation;
|
|
1345
|
-
}
|
|
1346
|
-
xmlStr += tagText;
|
|
1347
|
-
isPreviousElementTag = false;
|
|
1348
|
-
continue;
|
|
1349
|
-
} else if (tagName === options.cdataPropName) {
|
|
1350
|
-
if (isPreviousElementTag) {
|
|
1351
|
-
xmlStr += indentation;
|
|
1352
|
-
}
|
|
1353
|
-
xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;
|
|
1354
|
-
isPreviousElementTag = false;
|
|
1355
|
-
continue;
|
|
1356
|
-
} else if (tagName === options.commentPropName) {
|
|
1357
|
-
xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;
|
|
1358
|
-
isPreviousElementTag = true;
|
|
1359
|
-
continue;
|
|
1360
|
-
} else if (tagName[0] === "?") {
|
|
1361
|
-
const attStr2 = attr_to_str(tagObj[":@"], options);
|
|
1362
|
-
const tempInd = tagName === "?xml" ? "" : indentation;
|
|
1363
|
-
let piTextNodeName = tagObj[tagName][0][options.textNodeName];
|
|
1364
|
-
piTextNodeName = piTextNodeName.length !== 0 ? " " + piTextNodeName : "";
|
|
1365
|
-
xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr2}?>`;
|
|
1366
|
-
isPreviousElementTag = true;
|
|
1367
|
-
continue;
|
|
1368
|
-
}
|
|
1369
|
-
let newIdentation = indentation;
|
|
1370
|
-
if (newIdentation !== "") {
|
|
1371
|
-
newIdentation += options.indentBy;
|
|
1372
|
-
}
|
|
1373
|
-
const attStr = attr_to_str(tagObj[":@"], options);
|
|
1374
|
-
const tagStart = indentation + `<${tagName}${attStr}`;
|
|
1375
|
-
const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);
|
|
1376
|
-
if (options.unpairedTags.indexOf(tagName) !== -1) {
|
|
1377
|
-
if (options.suppressUnpairedNode) xmlStr += tagStart + ">";
|
|
1378
|
-
else xmlStr += tagStart + "/>";
|
|
1379
|
-
} else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {
|
|
1380
|
-
xmlStr += tagStart + "/>";
|
|
1381
|
-
} else if (tagValue && tagValue.endsWith(">")) {
|
|
1382
|
-
xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;
|
|
1383
|
-
} else {
|
|
1384
|
-
xmlStr += tagStart + ">";
|
|
1385
|
-
if (tagValue && indentation !== "" && (tagValue.includes("/>") || tagValue.includes("</"))) {
|
|
1386
|
-
xmlStr += indentation + options.indentBy + tagValue + indentation;
|
|
1387
|
-
} else {
|
|
1388
|
-
xmlStr += tagValue;
|
|
1389
|
-
}
|
|
1390
|
-
xmlStr += `</${tagName}>`;
|
|
1391
|
-
}
|
|
1392
|
-
isPreviousElementTag = true;
|
|
1393
|
-
}
|
|
1394
|
-
return xmlStr;
|
|
1395
|
-
}
|
|
1396
|
-
function propName(obj) {
|
|
1397
|
-
const keys = Object.keys(obj);
|
|
1398
|
-
for (let i = 0; i < keys.length; i++) {
|
|
1399
|
-
const key = keys[i];
|
|
1400
|
-
if (!obj.hasOwnProperty(key)) continue;
|
|
1401
|
-
if (key !== ":@") return key;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
function attr_to_str(attrMap, options) {
|
|
1405
|
-
let attrStr = "";
|
|
1406
|
-
if (attrMap && !options.ignoreAttributes) {
|
|
1407
|
-
for (let attr in attrMap) {
|
|
1408
|
-
if (!attrMap.hasOwnProperty(attr)) continue;
|
|
1409
|
-
let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);
|
|
1410
|
-
attrVal = replaceEntitiesValue(attrVal, options);
|
|
1411
|
-
if (attrVal === true && options.suppressBooleanAttributes) {
|
|
1412
|
-
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;
|
|
1413
|
-
} else {
|
|
1414
|
-
attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}="${attrVal}"`;
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
}
|
|
1418
|
-
return attrStr;
|
|
1419
|
-
}
|
|
1420
|
-
function isStopNode(jPath, options) {
|
|
1421
|
-
jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);
|
|
1422
|
-
let tagName = jPath.substr(jPath.lastIndexOf(".") + 1);
|
|
1423
|
-
for (let index in options.stopNodes) {
|
|
1424
|
-
if (options.stopNodes[index] === jPath || options.stopNodes[index] === "*." + tagName) return true;
|
|
1425
|
-
}
|
|
1426
|
-
return false;
|
|
1427
|
-
}
|
|
1428
|
-
function replaceEntitiesValue(textValue, options) {
|
|
1429
|
-
if (textValue && textValue.length > 0 && options.processEntities) {
|
|
1430
|
-
for (let i = 0; i < options.entities.length; i++) {
|
|
1431
|
-
const entity = options.entities[i];
|
|
1432
|
-
textValue = textValue.replace(entity.regex, entity.val);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
return textValue;
|
|
1436
|
-
}
|
|
1437
|
-
module.exports = toXml;
|
|
1438
|
-
}
|
|
1439
|
-
});
|
|
1440
|
-
|
|
1441
|
-
// ../../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js
|
|
1442
|
-
var require_json2xml = __commonJS({
|
|
1443
|
-
"../../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js"(exports, module) {
|
|
1444
|
-
"use strict";
|
|
1445
|
-
var buildFromOrderedJs = require_orderedJs2Xml();
|
|
1446
|
-
var getIgnoreAttributesFn = require_ignoreAttributes();
|
|
1447
|
-
var defaultOptions = {
|
|
1448
|
-
attributeNamePrefix: "@_",
|
|
1449
|
-
attributesGroupName: false,
|
|
1450
|
-
textNodeName: "#text",
|
|
1451
|
-
ignoreAttributes: true,
|
|
1452
|
-
cdataPropName: false,
|
|
1453
|
-
format: false,
|
|
1454
|
-
indentBy: " ",
|
|
1455
|
-
suppressEmptyNode: false,
|
|
1456
|
-
suppressUnpairedNode: true,
|
|
1457
|
-
suppressBooleanAttributes: true,
|
|
1458
|
-
tagValueProcessor: function(key, a) {
|
|
1459
|
-
return a;
|
|
1460
|
-
},
|
|
1461
|
-
attributeValueProcessor: function(attrName, a) {
|
|
1462
|
-
return a;
|
|
1463
|
-
},
|
|
1464
|
-
preserveOrder: false,
|
|
1465
|
-
commentPropName: false,
|
|
1466
|
-
unpairedTags: [],
|
|
1467
|
-
entities: [
|
|
1468
|
-
{ regex: new RegExp("&", "g"), val: "&" },
|
|
1469
|
-
//it must be on top
|
|
1470
|
-
{ regex: new RegExp(">", "g"), val: ">" },
|
|
1471
|
-
{ regex: new RegExp("<", "g"), val: "<" },
|
|
1472
|
-
{ regex: new RegExp("'", "g"), val: "'" },
|
|
1473
|
-
{ regex: new RegExp('"', "g"), val: """ }
|
|
1474
|
-
],
|
|
1475
|
-
processEntities: true,
|
|
1476
|
-
stopNodes: [],
|
|
1477
|
-
// transformTagName: false,
|
|
1478
|
-
// transformAttributeName: false,
|
|
1479
|
-
oneListGroup: false
|
|
1480
|
-
};
|
|
1481
|
-
function Builder(options) {
|
|
1482
|
-
this.options = Object.assign({}, defaultOptions, options);
|
|
1483
|
-
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
|
|
1484
|
-
this.isAttribute = function() {
|
|
1485
|
-
return false;
|
|
1486
|
-
};
|
|
1487
|
-
} else {
|
|
1488
|
-
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
|
|
1489
|
-
this.attrPrefixLen = this.options.attributeNamePrefix.length;
|
|
1490
|
-
this.isAttribute = isAttribute;
|
|
1491
|
-
}
|
|
1492
|
-
this.processTextOrObjNode = processTextOrObjNode;
|
|
1493
|
-
if (this.options.format) {
|
|
1494
|
-
this.indentate = indentate;
|
|
1495
|
-
this.tagEndChar = ">\n";
|
|
1496
|
-
this.newLine = "\n";
|
|
1497
|
-
} else {
|
|
1498
|
-
this.indentate = function() {
|
|
1499
|
-
return "";
|
|
1500
|
-
};
|
|
1501
|
-
this.tagEndChar = ">";
|
|
1502
|
-
this.newLine = "";
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
Builder.prototype.build = function(jObj) {
|
|
1506
|
-
if (this.options.preserveOrder) {
|
|
1507
|
-
return buildFromOrderedJs(jObj, this.options);
|
|
1508
|
-
} else {
|
|
1509
|
-
if (Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1) {
|
|
1510
|
-
jObj = {
|
|
1511
|
-
[this.options.arrayNodeName]: jObj
|
|
1512
|
-
};
|
|
1513
|
-
}
|
|
1514
|
-
return this.j2x(jObj, 0, []).val;
|
|
1515
|
-
}
|
|
1516
|
-
};
|
|
1517
|
-
Builder.prototype.j2x = function(jObj, level, ajPath) {
|
|
1518
|
-
let attrStr = "";
|
|
1519
|
-
let val = "";
|
|
1520
|
-
const jPath = ajPath.join(".");
|
|
1521
|
-
for (let key in jObj) {
|
|
1522
|
-
if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
|
|
1523
|
-
if (typeof jObj[key] === "undefined") {
|
|
1524
|
-
if (this.isAttribute(key)) {
|
|
1525
|
-
val += "";
|
|
1526
|
-
}
|
|
1527
|
-
} else if (jObj[key] === null) {
|
|
1528
|
-
if (this.isAttribute(key)) {
|
|
1529
|
-
val += "";
|
|
1530
|
-
} else if (key === this.options.cdataPropName) {
|
|
1531
|
-
val += "";
|
|
1532
|
-
} else if (key[0] === "?") {
|
|
1533
|
-
val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
|
|
1534
|
-
} else {
|
|
1535
|
-
val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
1536
|
-
}
|
|
1537
|
-
} else if (jObj[key] instanceof Date) {
|
|
1538
|
-
val += this.buildTextValNode(jObj[key], key, "", level);
|
|
1539
|
-
} else if (typeof jObj[key] !== "object") {
|
|
1540
|
-
const attr = this.isAttribute(key);
|
|
1541
|
-
if (attr && !this.ignoreAttributesFn(attr, jPath)) {
|
|
1542
|
-
attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
|
|
1543
|
-
} else if (!attr) {
|
|
1544
|
-
if (key === this.options.textNodeName) {
|
|
1545
|
-
let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
|
|
1546
|
-
val += this.replaceEntitiesValue(newval);
|
|
1547
|
-
} else {
|
|
1548
|
-
val += this.buildTextValNode(jObj[key], key, "", level);
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
} else if (Array.isArray(jObj[key])) {
|
|
1552
|
-
const arrLen = jObj[key].length;
|
|
1553
|
-
let listTagVal = "";
|
|
1554
|
-
let listTagAttr = "";
|
|
1555
|
-
for (let j = 0; j < arrLen; j++) {
|
|
1556
|
-
const item = jObj[key][j];
|
|
1557
|
-
if (typeof item === "undefined") {
|
|
1558
|
-
} else if (item === null) {
|
|
1559
|
-
if (key[0] === "?") val += this.indentate(level) + "<" + key + "?" + this.tagEndChar;
|
|
1560
|
-
else val += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
1561
|
-
} else if (typeof item === "object") {
|
|
1562
|
-
if (this.options.oneListGroup) {
|
|
1563
|
-
const result = this.j2x(item, level + 1, ajPath.concat(key));
|
|
1564
|
-
listTagVal += result.val;
|
|
1565
|
-
if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
|
|
1566
|
-
listTagAttr += result.attrStr;
|
|
1567
|
-
}
|
|
1568
|
-
} else {
|
|
1569
|
-
listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
|
|
1570
|
-
}
|
|
1571
|
-
} else {
|
|
1572
|
-
if (this.options.oneListGroup) {
|
|
1573
|
-
let textValue = this.options.tagValueProcessor(key, item);
|
|
1574
|
-
textValue = this.replaceEntitiesValue(textValue);
|
|
1575
|
-
listTagVal += textValue;
|
|
1576
|
-
} else {
|
|
1577
|
-
listTagVal += this.buildTextValNode(item, key, "", level);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
if (this.options.oneListGroup) {
|
|
1582
|
-
listTagVal = this.buildObjectNode(listTagVal, key, listTagAttr, level);
|
|
1583
|
-
}
|
|
1584
|
-
val += listTagVal;
|
|
1585
|
-
} else {
|
|
1586
|
-
if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
|
|
1587
|
-
const Ks = Object.keys(jObj[key]);
|
|
1588
|
-
const L = Ks.length;
|
|
1589
|
-
for (let j = 0; j < L; j++) {
|
|
1590
|
-
attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
|
|
1591
|
-
}
|
|
1592
|
-
} else {
|
|
1593
|
-
val += this.processTextOrObjNode(jObj[key], key, level, ajPath);
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
return { attrStr, val };
|
|
1598
|
-
};
|
|
1599
|
-
Builder.prototype.buildAttrPairStr = function(attrName, val) {
|
|
1600
|
-
val = this.options.attributeValueProcessor(attrName, "" + val);
|
|
1601
|
-
val = this.replaceEntitiesValue(val);
|
|
1602
|
-
if (this.options.suppressBooleanAttributes && val === "true") {
|
|
1603
|
-
return " " + attrName;
|
|
1604
|
-
} else return " " + attrName + '="' + val + '"';
|
|
1605
|
-
};
|
|
1606
|
-
function processTextOrObjNode(object, key, level, ajPath) {
|
|
1607
|
-
const result = this.j2x(object, level + 1, ajPath.concat(key));
|
|
1608
|
-
if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
|
|
1609
|
-
return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
|
|
1610
|
-
} else {
|
|
1611
|
-
return this.buildObjectNode(result.val, key, result.attrStr, level);
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
Builder.prototype.buildObjectNode = function(val, key, attrStr, level) {
|
|
1615
|
-
if (val === "") {
|
|
1616
|
-
if (key[0] === "?") return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
|
|
1617
|
-
else {
|
|
1618
|
-
return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
|
|
1619
|
-
}
|
|
1620
|
-
} else {
|
|
1621
|
-
let tagEndExp = "</" + key + this.tagEndChar;
|
|
1622
|
-
let piClosingChar = "";
|
|
1623
|
-
if (key[0] === "?") {
|
|
1624
|
-
piClosingChar = "?";
|
|
1625
|
-
tagEndExp = "";
|
|
1626
|
-
}
|
|
1627
|
-
if ((attrStr || attrStr === "") && val.indexOf("<") === -1) {
|
|
1628
|
-
return this.indentate(level) + "<" + key + attrStr + piClosingChar + ">" + val + tagEndExp;
|
|
1629
|
-
} else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {
|
|
1630
|
-
return this.indentate(level) + `<!--${val}-->` + this.newLine;
|
|
1631
|
-
} else {
|
|
1632
|
-
return this.indentate(level) + "<" + key + attrStr + piClosingChar + this.tagEndChar + val + this.indentate(level) + tagEndExp;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
};
|
|
1636
|
-
Builder.prototype.closeTag = function(key) {
|
|
1637
|
-
let closeTag = "";
|
|
1638
|
-
if (this.options.unpairedTags.indexOf(key) !== -1) {
|
|
1639
|
-
if (!this.options.suppressUnpairedNode) closeTag = "/";
|
|
1640
|
-
} else if (this.options.suppressEmptyNode) {
|
|
1641
|
-
closeTag = "/";
|
|
1642
|
-
} else {
|
|
1643
|
-
closeTag = `></${key}`;
|
|
1644
|
-
}
|
|
1645
|
-
return closeTag;
|
|
1646
|
-
};
|
|
1647
|
-
Builder.prototype.buildTextValNode = function(val, key, attrStr, level) {
|
|
1648
|
-
if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {
|
|
1649
|
-
return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;
|
|
1650
|
-
} else if (this.options.commentPropName !== false && key === this.options.commentPropName) {
|
|
1651
|
-
return this.indentate(level) + `<!--${val}-->` + this.newLine;
|
|
1652
|
-
} else if (key[0] === "?") {
|
|
1653
|
-
return this.indentate(level) + "<" + key + attrStr + "?" + this.tagEndChar;
|
|
1654
|
-
} else {
|
|
1655
|
-
let textValue = this.options.tagValueProcessor(key, val);
|
|
1656
|
-
textValue = this.replaceEntitiesValue(textValue);
|
|
1657
|
-
if (textValue === "") {
|
|
1658
|
-
return this.indentate(level) + "<" + key + attrStr + this.closeTag(key) + this.tagEndChar;
|
|
1659
|
-
} else {
|
|
1660
|
-
return this.indentate(level) + "<" + key + attrStr + ">" + textValue + "</" + key + this.tagEndChar;
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
};
|
|
1664
|
-
Builder.prototype.replaceEntitiesValue = function(textValue) {
|
|
1665
|
-
if (textValue && textValue.length > 0 && this.options.processEntities) {
|
|
1666
|
-
for (let i = 0; i < this.options.entities.length; i++) {
|
|
1667
|
-
const entity = this.options.entities[i];
|
|
1668
|
-
textValue = textValue.replace(entity.regex, entity.val);
|
|
1669
|
-
}
|
|
1670
|
-
}
|
|
1671
|
-
return textValue;
|
|
1672
|
-
};
|
|
1673
|
-
function indentate(level) {
|
|
1674
|
-
return this.options.indentBy.repeat(level);
|
|
1675
|
-
}
|
|
1676
|
-
function isAttribute(name) {
|
|
1677
|
-
if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {
|
|
1678
|
-
return name.substr(this.attrPrefixLen);
|
|
1679
|
-
} else {
|
|
1680
|
-
return false;
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
module.exports = Builder;
|
|
1684
|
-
}
|
|
1685
|
-
});
|
|
1686
|
-
|
|
1687
|
-
// ../../node_modules/fast-xml-parser/src/fxp.js
|
|
1688
|
-
var require_fxp = __commonJS({
|
|
1689
|
-
"../../node_modules/fast-xml-parser/src/fxp.js"(exports, module) {
|
|
1690
|
-
var validator = require_validator();
|
|
1691
|
-
var XMLParser = require_XMLParser();
|
|
1692
|
-
var XMLBuilder = require_json2xml();
|
|
1693
|
-
module.exports = {
|
|
1694
|
-
XMLParser,
|
|
1695
|
-
XMLValidator: validator,
|
|
1696
|
-
XMLBuilder
|
|
1697
|
-
};
|
|
1698
|
-
}
|
|
1699
|
-
});
|
|
1700
|
-
export default require_fxp();
|
|
1701
|
-
//# sourceMappingURL=fxp-TCYZYIHZ.js.map
|