fast-xml-parser 5.0.6 → 5.0.8
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/CHANGELOG.md +7 -0
- package/lib/fxp.cjs +1 -1
- package/lib/fxp.d.cts +429 -0
- package/lib/fxp.min.js +1 -1
- package/lib/fxp.min.js.map +1 -1
- package/lib/fxparser.min.js +1 -1
- package/lib/fxparser.min.js.map +1 -1
- package/package.json +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
<small>Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library.</small>
|
|
2
2
|
|
|
3
|
+
**5.0.8 / 2025-02-27**
|
|
4
|
+
- fix parsing 0 if skiplike option is used.
|
|
5
|
+
- updating strnum dependency
|
|
6
|
+
|
|
7
|
+
**5.0.7 / 2025-02-25**
|
|
8
|
+
- fix (#724) typings for cjs.
|
|
9
|
+
|
|
3
10
|
**5.0.6 / 2025-02-20**
|
|
4
11
|
- fix cli output (By [Angel Delgado](https://github.com/angeld7))
|
|
5
12
|
- remove multiple JSON parsing
|
package/lib/fxp.cjs
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
\***************************************/
|
|
17
17
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
18
18
|
|
|
19
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ toNumber)\n/* harmony export */ });\nconst hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;\nconst numRegex = /^([\\-\\+])?(0*)([0-9]*(\\.[0-9]*)?)$/;\n// const octRegex = /^0x[a-z0-9]+/;\n// const binRegex = /0x[a-z0-9]+/;\n\n \nconst consider = {\n hex : true,\n // oct: false,\n leadingZeros: true,\n decimalPoint: \"\\.\",\n eNotation: true,\n //skipLike: /regex/\n};\n\nfunction toNumber(str, options = {}){\n options = Object.assign({}, consider, options );\n if(!str || typeof str !== \"string\" ) return str;\n
|
|
19
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (/* binding */ toNumber)\n/* harmony export */ });\nconst hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;\nconst numRegex = /^([\\-\\+])?(0*)([0-9]*(\\.[0-9]*)?)$/;\n// const octRegex = /^0x[a-z0-9]+/;\n// const binRegex = /0x[a-z0-9]+/;\n\n \nconst consider = {\n hex : true,\n // oct: false,\n leadingZeros: true,\n decimalPoint: \"\\.\",\n eNotation: true,\n //skipLike: /regex/\n};\n\nfunction toNumber(str, options = {}){\n options = Object.assign({}, consider, options );\n if(!str || typeof str !== \"string\" ) return str;\n \n let trimmedStr = str.trim();\n \n if(options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;\n else if(str===\"0\") return 0;\n else if (options.hex && hexRegex.test(trimmedStr)) {\n return parse_int(trimmedStr, 16);\n // }else if (options.oct && octRegex.test(str)) {\n // return Number.parseInt(val, 8);\n }else if (trimmedStr.search(/[eE]/)!== -1) { //eNotation\n const notation = trimmedStr.match(/^([-\\+])?(0*)([0-9]*(\\.[0-9]*)?[eE][-\\+]?[0-9]+)$/); \n // +00.123 => [ , '+', '00', '.123', ..\n if(notation){\n // console.log(notation)\n if(options.leadingZeros){ //accept with leading zeros\n trimmedStr = (notation[1] || \"\") + notation[3];\n }else{\n if(notation[2] === \"0\" && notation[3][0]=== \".\"){ //valid number\n }else{\n return str;\n }\n }\n return options.eNotation ? Number(trimmedStr) : str;\n }else{\n return str;\n }\n // }else if (options.parseBin && binRegex.test(str)) {\n // return Number.parseInt(val, 2);\n }else{\n //separate negative sign, leading zeros, and rest number\n const match = numRegex.exec(trimmedStr);\n // +00.123 => [ , '+', '00', '.123', ..\n if(match){\n const sign = match[1];\n const leadingZeros = match[2];\n let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros\n //trim ending zeros for floating number\n \n if(!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== \".\") return str; //-0123\n else if(!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== \".\") return str; //0123\n else if(options.leadingZeros && leadingZeros===str) return 0; //00\n \n else{//no leading zeros or leading zeros are allowed\n const num = Number(trimmedStr);\n const numStr = \"\" + num;\n\n if(numStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation\n if(options.eNotation) return num;\n else return str;\n }else if(trimmedStr.indexOf(\".\") !== -1){ //floating number\n if(numStr === \"0\" && (numTrimmedByZeros === \"\") ) return num; //0.0\n else if(numStr === numTrimmedByZeros) return num; //0.456. 0.79000\n else if( sign && numStr === \"-\"+numTrimmedByZeros) return num;\n else return str;\n }\n \n if(leadingZeros){\n return (numTrimmedByZeros === numStr) || (sign+numTrimmedByZeros === numStr) ? num : str\n }else {\n return (trimmedStr === numStr) || (trimmedStr === sign+numStr) ? num : str\n }\n }\n }else{ //non-numeric string\n return str;\n }\n }\n}\n\n/**\n * \n * @param {string} numStr without leading zeros\n * @returns \n */\nfunction trimZeros(numStr){\n if(numStr && numStr.indexOf(\".\") !== -1){//float\n numStr = numStr.replace(/0+$/, \"\"); //remove ending zeros\n if(numStr === \".\") numStr = \"0\";\n else if(numStr[0] === \".\") numStr = \"0\"+numStr;\n else if(numStr[numStr.length-1] === \".\") numStr = numStr.substr(0,numStr.length-1);\n return numStr;\n }\n return numStr;\n}\n\nfunction parse_int(numStr, base){\n //polyfill\n if(parseInt) return parseInt(numStr, base);\n else if(Number.parseInt) return Number.parseInt(numStr, base);\n else if(window && window.parseInt) return window.parseInt(numStr, base);\n else throw new Error(\"parseInt, Number.parseInt, window.parseInt are not supported\")\n}\n\n//# sourceURL=webpack://fast-xml-parser/./node_modules/strnum/strnum.js?");
|
|
20
20
|
|
|
21
21
|
/***/ }),
|
|
22
22
|
|
package/lib/fxp.d.cts
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
type X2jOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Preserve the order of tags in resulting JS object
|
|
4
|
+
*
|
|
5
|
+
* Defaults to `false`
|
|
6
|
+
*/
|
|
7
|
+
preserveOrder?: boolean;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Give a prefix to the attribute name in the resulting JS object
|
|
11
|
+
*
|
|
12
|
+
* Defaults to '@_'
|
|
13
|
+
*/
|
|
14
|
+
attributeNamePrefix?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A name to group all attributes of a tag under, or `false` to disable
|
|
18
|
+
*
|
|
19
|
+
* Defaults to `false`
|
|
20
|
+
*/
|
|
21
|
+
attributesGroupName?: false | string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The name of the next node in the resulting JS
|
|
25
|
+
*
|
|
26
|
+
* Defaults to `#text`
|
|
27
|
+
*/
|
|
28
|
+
textNodeName?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Whether to ignore attributes when parsing
|
|
32
|
+
*
|
|
33
|
+
* When `true` - ignores all the attributes
|
|
34
|
+
*
|
|
35
|
+
* When `false` - parses all the attributes
|
|
36
|
+
*
|
|
37
|
+
* When `Array<string | RegExp>` - filters out attributes that match provided patterns
|
|
38
|
+
*
|
|
39
|
+
* When `Function` - calls the function for each attribute and filters out those for which the function returned `true`
|
|
40
|
+
*
|
|
41
|
+
* Defaults to `true`
|
|
42
|
+
*/
|
|
43
|
+
ignoreAttributes?: boolean | (string | RegExp)[] | ((attrName: string, jPath: string) => boolean);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether to remove namespace string from tag and attribute names
|
|
47
|
+
*
|
|
48
|
+
* Defaults to `false`
|
|
49
|
+
*/
|
|
50
|
+
removeNSPrefix?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Whether to allow attributes without value
|
|
54
|
+
*
|
|
55
|
+
* Defaults to `false`
|
|
56
|
+
*/
|
|
57
|
+
allowBooleanAttributes?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Whether to parse tag value with `strnum` package
|
|
61
|
+
*
|
|
62
|
+
* Defaults to `true`
|
|
63
|
+
*/
|
|
64
|
+
parseTagValue?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Whether to parse tag value with `strnum` package
|
|
68
|
+
*
|
|
69
|
+
* Defaults to `false`
|
|
70
|
+
*/
|
|
71
|
+
parseAttributeValue?: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether to remove surrounding whitespace from tag or attribute value
|
|
75
|
+
*
|
|
76
|
+
* Defaults to `true`
|
|
77
|
+
*/
|
|
78
|
+
trimValues?: boolean;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Give a property name to set CDATA values to instead of merging to tag's text value
|
|
82
|
+
*
|
|
83
|
+
* Defaults to `false`
|
|
84
|
+
*/
|
|
85
|
+
cdataPropName?: false | string;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* If set, parse comments and set as this property
|
|
89
|
+
*
|
|
90
|
+
* Defaults to `false`
|
|
91
|
+
*/
|
|
92
|
+
commentPropName?: false | string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Control how tag value should be parsed. Called only if tag value is not empty
|
|
96
|
+
*
|
|
97
|
+
* @returns {undefined|null} `undefined` or `null` to set original value.
|
|
98
|
+
* @returns {unknown}
|
|
99
|
+
*
|
|
100
|
+
* 1. Different value or value with different data type to set new value.
|
|
101
|
+
* 2. Same value to set parsed value if `parseTagValue: true`.
|
|
102
|
+
*
|
|
103
|
+
* Defaults to `(tagName, val, jPath, hasAttributes, isLeafNode) => val`
|
|
104
|
+
*/
|
|
105
|
+
tagValueProcessor?: (tagName: string, tagValue: string, jPath: string, hasAttributes: boolean, isLeafNode: boolean) => unknown;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Control how attribute value should be parsed
|
|
109
|
+
*
|
|
110
|
+
* @param attrName
|
|
111
|
+
* @param attrValue
|
|
112
|
+
* @param jPath
|
|
113
|
+
* @returns {undefined|null} `undefined` or `null` to set original value
|
|
114
|
+
* @returns {unknown}
|
|
115
|
+
*
|
|
116
|
+
* Defaults to `(attrName, val, jPath) => val`
|
|
117
|
+
*/
|
|
118
|
+
attributeValueProcessor?: (attrName: string, attrValue: string, jPath: string) => unknown;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Options to pass to `strnum` for parsing numbers
|
|
122
|
+
*
|
|
123
|
+
* Defaults to `{ hex: true, leadingZeros: true, eNotation: true }`
|
|
124
|
+
*/
|
|
125
|
+
numberParseOptions?: strnumOptions;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Nodes to stop parsing at
|
|
129
|
+
*
|
|
130
|
+
* Defaults to `[]`
|
|
131
|
+
*/
|
|
132
|
+
stopNodes?: string[];
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* List of tags without closing tags
|
|
136
|
+
*
|
|
137
|
+
* Defaults to `[]`
|
|
138
|
+
*/
|
|
139
|
+
unpairedTags?: string[];
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Whether to always create a text node
|
|
143
|
+
*
|
|
144
|
+
* Defaults to `false`
|
|
145
|
+
*/
|
|
146
|
+
alwaysCreateTextNode?: boolean;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Determine whether a tag should be parsed as an array
|
|
150
|
+
*
|
|
151
|
+
* @param tagName
|
|
152
|
+
* @param jPath
|
|
153
|
+
* @param isLeafNode
|
|
154
|
+
* @param isAttribute
|
|
155
|
+
* @returns {boolean}
|
|
156
|
+
*
|
|
157
|
+
* Defaults to `() => false`
|
|
158
|
+
*/
|
|
159
|
+
isArray?: (tagName: string, jPath: string, isLeafNode: boolean, isAttribute: boolean) => boolean;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Whether to process default and DOCTYPE entities
|
|
163
|
+
*
|
|
164
|
+
* Defaults to `true`
|
|
165
|
+
*/
|
|
166
|
+
processEntities?: boolean;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Whether to process HTML entities
|
|
170
|
+
*
|
|
171
|
+
* Defaults to `false`
|
|
172
|
+
*/
|
|
173
|
+
htmlEntities?: boolean;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Whether to ignore the declaration tag from output
|
|
177
|
+
*
|
|
178
|
+
* Defaults to `false`
|
|
179
|
+
*/
|
|
180
|
+
ignoreDeclaration?: boolean;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Whether to ignore Pi tags
|
|
184
|
+
*
|
|
185
|
+
* Defaults to `false`
|
|
186
|
+
*/
|
|
187
|
+
ignorePiTags?: boolean;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Transform tag names
|
|
191
|
+
*
|
|
192
|
+
* Defaults to `false`
|
|
193
|
+
*/
|
|
194
|
+
transformTagName?: ((tagName: string) => string) | false;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Transform attribute names
|
|
198
|
+
*
|
|
199
|
+
* Defaults to `false`
|
|
200
|
+
*/
|
|
201
|
+
transformAttributeName?: ((attributeName: string) => string) | false;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Change the tag name when a different name is returned. Skip the tag from parsed result when false is returned.
|
|
205
|
+
* Modify `attrs` object to control attributes for the given tag.
|
|
206
|
+
*
|
|
207
|
+
* @returns {string} new tag name.
|
|
208
|
+
* @returns false to skip the tag
|
|
209
|
+
*
|
|
210
|
+
* Defaults to `(tagName, jPath, attrs) => tagName`
|
|
211
|
+
*/
|
|
212
|
+
updateTag?: (tagName: string, jPath: string, attrs: {[k: string]: string}) => string | boolean;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
type strnumOptions = {
|
|
216
|
+
hex: boolean;
|
|
217
|
+
leadingZeros: boolean,
|
|
218
|
+
skipLike?: RegExp,
|
|
219
|
+
eNotation?: boolean
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
type validationOptions = {
|
|
223
|
+
/**
|
|
224
|
+
* Whether to allow attributes without value
|
|
225
|
+
*
|
|
226
|
+
* Defaults to `false`
|
|
227
|
+
*/
|
|
228
|
+
allowBooleanAttributes?: boolean;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* List of tags without closing tags
|
|
232
|
+
*
|
|
233
|
+
* Defaults to `[]`
|
|
234
|
+
*/
|
|
235
|
+
unpairedTags?: string[];
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
type XmlBuilderOptions = {
|
|
239
|
+
/**
|
|
240
|
+
* Give a prefix to the attribute name in the resulting JS object
|
|
241
|
+
*
|
|
242
|
+
* Defaults to '@_'
|
|
243
|
+
*/
|
|
244
|
+
attributeNamePrefix?: string;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A name to group all attributes of a tag under, or `false` to disable
|
|
248
|
+
*
|
|
249
|
+
* Defaults to `false`
|
|
250
|
+
*/
|
|
251
|
+
attributesGroupName?: false | string;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* The name of the next node in the resulting JS
|
|
255
|
+
*
|
|
256
|
+
* Defaults to `#text`
|
|
257
|
+
*/
|
|
258
|
+
textNodeName?: string;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Whether to ignore attributes when building
|
|
262
|
+
*
|
|
263
|
+
* When `true` - ignores all the attributes
|
|
264
|
+
*
|
|
265
|
+
* When `false` - builds all the attributes
|
|
266
|
+
*
|
|
267
|
+
* When `Array<string | RegExp>` - filters out attributes that match provided patterns
|
|
268
|
+
*
|
|
269
|
+
* When `Function` - calls the function for each attribute and filters out those for which the function returned `true`
|
|
270
|
+
*
|
|
271
|
+
* Defaults to `true`
|
|
272
|
+
*/
|
|
273
|
+
ignoreAttributes?: boolean | (string | RegExp)[] | ((attrName: string, jPath: string) => boolean);
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Give a property name to set CDATA values to instead of merging to tag's text value
|
|
277
|
+
*
|
|
278
|
+
* Defaults to `false`
|
|
279
|
+
*/
|
|
280
|
+
cdataPropName?: false | string;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* If set, parse comments and set as this property
|
|
284
|
+
*
|
|
285
|
+
* Defaults to `false`
|
|
286
|
+
*/
|
|
287
|
+
commentPropName?: false | string;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Whether to make output pretty instead of single line
|
|
291
|
+
*
|
|
292
|
+
* Defaults to `false`
|
|
293
|
+
*/
|
|
294
|
+
format?: boolean;
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* If `format` is set to `true`, sets the indent string
|
|
299
|
+
*
|
|
300
|
+
* Defaults to ` `
|
|
301
|
+
*/
|
|
302
|
+
indentBy?: string;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Give a name to a top-level array
|
|
306
|
+
*
|
|
307
|
+
* Defaults to `undefined`
|
|
308
|
+
*/
|
|
309
|
+
arrayNodeName?: string;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Create empty tags for tags with no text value
|
|
313
|
+
*
|
|
314
|
+
* Defaults to `false`
|
|
315
|
+
*/
|
|
316
|
+
suppressEmptyNode?: boolean;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Suppress an unpaired tag
|
|
320
|
+
*
|
|
321
|
+
* Defaults to `true`
|
|
322
|
+
*/
|
|
323
|
+
suppressUnpairedNode?: boolean;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Don't put a value for boolean attributes
|
|
327
|
+
*
|
|
328
|
+
* Defaults to `true`
|
|
329
|
+
*/
|
|
330
|
+
suppressBooleanAttributes?: boolean;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Preserve the order of tags in resulting JS object
|
|
334
|
+
*
|
|
335
|
+
* Defaults to `false`
|
|
336
|
+
*/
|
|
337
|
+
preserveOrder?: boolean;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* List of tags without closing tags
|
|
341
|
+
*
|
|
342
|
+
* Defaults to `[]`
|
|
343
|
+
*/
|
|
344
|
+
unpairedTags?: string[];
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Nodes to stop parsing at
|
|
348
|
+
*
|
|
349
|
+
* Defaults to `[]`
|
|
350
|
+
*/
|
|
351
|
+
stopNodes?: string[];
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Control how tag value should be parsed. Called only if tag value is not empty
|
|
355
|
+
*
|
|
356
|
+
* @returns {undefined|null} `undefined` or `null` to set original value.
|
|
357
|
+
* @returns {unknown}
|
|
358
|
+
*
|
|
359
|
+
* 1. Different value or value with different data type to set new value.
|
|
360
|
+
* 2. Same value to set parsed value if `parseTagValue: true`.
|
|
361
|
+
*
|
|
362
|
+
* Defaults to `(tagName, val, jPath, hasAttributes, isLeafNode) => val`
|
|
363
|
+
*/
|
|
364
|
+
tagValueProcessor?: (name: string, value: unknown) => unknown;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Control how attribute value should be parsed
|
|
368
|
+
*
|
|
369
|
+
* @param attrName
|
|
370
|
+
* @param attrValue
|
|
371
|
+
* @param jPath
|
|
372
|
+
* @returns {undefined|null} `undefined` or `null` to set original value
|
|
373
|
+
* @returns {unknown}
|
|
374
|
+
*
|
|
375
|
+
* Defaults to `(attrName, val, jPath) => val`
|
|
376
|
+
*/
|
|
377
|
+
attributeValueProcessor?: (name: string, value: unknown) => unknown;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Whether to process default and DOCTYPE entities
|
|
381
|
+
*
|
|
382
|
+
* Defaults to `true`
|
|
383
|
+
*/
|
|
384
|
+
processEntities?: boolean;
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
oneListGroup?: boolean;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
type ESchema = string | object | Array<string|object>;
|
|
391
|
+
|
|
392
|
+
type ValidationError = {
|
|
393
|
+
err: {
|
|
394
|
+
code: string;
|
|
395
|
+
msg: string,
|
|
396
|
+
line: number,
|
|
397
|
+
col: number
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
declare class XMLParser {
|
|
402
|
+
constructor(options?: X2jOptions);
|
|
403
|
+
parse(xmlData: string | Buffer ,validationOptions?: validationOptions | boolean): any;
|
|
404
|
+
/**
|
|
405
|
+
* Add Entity which is not by default supported by this library
|
|
406
|
+
* @param entityIdentifier {string} Eg: 'ent' for &ent;
|
|
407
|
+
* @param entityValue {string} Eg: '\r'
|
|
408
|
+
*/
|
|
409
|
+
addEntity(entityIdentifier: string, entityValue: string): void;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
declare class XMLValidator{
|
|
413
|
+
static validate(xmlData: string, options?: validationOptions): true | ValidationError;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
declare class XMLBuilder {
|
|
417
|
+
constructor(options?: XmlBuilderOptions);
|
|
418
|
+
build(jObj: any): any;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
declare namespace fxp {
|
|
422
|
+
export {
|
|
423
|
+
XMLParser,
|
|
424
|
+
XMLValidator,
|
|
425
|
+
XMLBuilder
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export = fxp;
|
package/lib/fxp.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxp=e():t.fxp=e()}(this,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>ht,XMLParser:()=>rt,XMLValidator:()=>gt});var r=":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",i=new RegExp("^["+r+"]["+r+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function n(t,e){for(var r=[],i=e.exec(t);i;){var n=[];n.startIndex=e.lastIndex-i[0].length;for(var a=i.length,s=0;s<a;s++)n.push(i[s]);r.push(n),i=e.exec(t)}return r}var a=function(t){return!(null==i.exec(t))},s={allowBooleanAttributes:!1,unpairedTags:[]};function o(t,e){e=Object.assign({},s,e);var r=[],i=!1,n=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var o=0;o<t.length;o++)if("<"===t[o]&&"?"===t[o+1]){if((o=l(t,o+=2)).err)return o}else{if("<"!==t[o]){if(u(t[o]))continue;return m("InvalidChar","char '"+t[o]+"' is not expected.",b(t,o))}var f=o;if("!"===t[++o]){o=h(t,o);continue}var d=!1;"/"===t[o]&&(d=!0,o++);for(var g="";o<t.length&&">"!==t[o]&&" "!==t[o]&&"\t"!==t[o]&&"\n"!==t[o]&&"\r"!==t[o];o++)g+=t[o];if("/"===(g=g.trim())[g.length-1]&&(g=g.substring(0,g.length-1),o--),!a(g))return m("InvalidTag",0===g.trim().length?"Invalid space after '<'.":"Tag '"+g+"' is an invalid name.",b(t,o));var x=p(t,o);if(!1===x)return m("InvalidAttr","Attributes for '"+g+"' have open quote.",b(t,o));var N=x.value;if(o=x.index,"/"===N[N.length-1]){var y=o-N.length,E=c(N=N.substring(0,N.length-1),e);if(!0!==E)return m(E.err.code,E.err.msg,b(t,y+E.err.line));i=!0}else if(d){if(!x.tagClosed)return m("InvalidTag","Closing tag '"+g+"' doesn't have proper closing.",b(t,o));if(N.trim().length>0)return m("InvalidTag","Closing tag '"+g+"' can't have attributes or invalid starting.",b(t,f));if(0===r.length)return m("InvalidTag","Closing tag '"+g+"' has not been opened.",b(t,f));var T=r.pop();if(g!==T.tagName){var w=b(t,T.tagStartPos);return m("InvalidTag","Expected closing tag '"+T.tagName+"' (opened in line "+w.line+", col "+w.col+") instead of closing tag '"+g+"'.",b(t,f))}0==r.length&&(n=!0)}else{var A=c(N,e);if(!0!==A)return m(A.err.code,A.err.msg,b(t,o-N.length+A.err.line));if(!0===n)return m("InvalidXml","Multiple possible root nodes found.",b(t,o));-1!==e.unpairedTags.indexOf(g)||r.push({tagName:g,tagStartPos:f}),i=!0}for(o++;o<t.length;o++)if("<"===t[o]){if("!"===t[o+1]){o=h(t,++o);continue}if("?"!==t[o+1])break;if((o=l(t,++o)).err)return o}else if("&"===t[o]){var O=v(t,o);if(-1==O)return m("InvalidChar","char '&' is not expected.",b(t,o));o=O}else if(!0===n&&!u(t[o]))return m("InvalidXml","Extra text at the end",b(t,o));"<"===t[o]&&o--}return i?1==r.length?m("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",b(t,r[0].tagStartPos)):!(r.length>0)||m("InvalidXml","Invalid '"+JSON.stringify(r.map((function(t){return t.tagName})),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):m("InvalidXml","Start tag expected.",1)}function u(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function l(t,e){for(var r=e;e<t.length;e++)if("?"!=t[e]&&" "!=t[e]);else{var i=t.substr(r,e-r);if(e>5&&"xml"===i)return m("InvalidXml","XML declaration allowed only at the start of the document.",b(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}}return e}function h(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){var r=1;for(e+=8;e<t.length;e++)if("<"===t[e])r++;else if(">"===t[e]&&0==--r)break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}var f='"',d="'";function p(t,e){for(var r="",i="",n=!1;e<t.length;e++){if(t[e]===f||t[e]===d)""===i?i=t[e]:i!==t[e]||(i="");else if(">"===t[e]&&""===i){n=!0;break}r+=t[e]}return""===i&&{value:r,index:e,tagClosed:n}}var g=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function c(t,e){for(var r=n(t,g),i={},a=0;a<r.length;a++){if(0===r[a][1].length)return m("InvalidAttr","Attribute '"+r[a][2]+"' has no space in starting.",N(r[a]));if(void 0!==r[a][3]&&void 0===r[a][4])return m("InvalidAttr","Attribute '"+r[a][2]+"' is without value.",N(r[a]));if(void 0===r[a][3]&&!e.allowBooleanAttributes)return m("InvalidAttr","boolean attribute '"+r[a][2]+"' is not allowed.",N(r[a]));var s=r[a][2];if(!x(s))return m("InvalidAttr","Attribute '"+s+"' is an invalid name.",N(r[a]));if(i.hasOwnProperty(s))return m("InvalidAttr","Attribute '"+s+"' is repeated.",N(r[a]));i[s]=1}return!0}function v(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){var r=/\d/;for("x"===t[e]&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(r))break}return-1}(t,++e);for(var r=0;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(";"===t[e])break;return-1}return e}function m(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function x(t){return a(t)}function b(t,e){var r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function N(t){return t.startIndex+t[1].length}var y={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:function(){return!1},commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}},E=function(){function t(t){this.tagname=t,this.child=[],this[":@"]={}}var e=t.prototype;return e.add=function(t,e){var r;"__proto__"===t&&(t="#__proto__"),this.child.push(((r={})[t]=e,r))},e.addChild=function(t){var e,r;"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push(((e={})[t.tagname]=t.child,e[":@"]=t[":@"],e)):this.child.push(((r={})[t.tagname]=t.child,r))},t}();function T(t,e){var r={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");e+=9;for(var i=1,n=!1,a=!1;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,i--):i--,0===i)break}else"["===t[e]?n=!0:t[e];else{if(n&&O(t,e)){var s,o=void 0,u=w(t,(e+=7)+1);s=u[0],o=u[1],e=u[2],-1===o.indexOf("&")&&(r[S(s)]={regx:RegExp("&"+s+";","g"),val:o})}else if(n&&P(t,e))e+=8;else if(n&&I(t,e))e+=8;else if(n&&C(t,e))e+=9;else{if(!A)throw new Error("Invalid DOCTYPE");a=!0}i++}if(0!==i)throw new Error("Unclosed DOCTYPE");return{entities:r,i:e}}function w(t,e){for(var r="";e<t.length&&"'"!==t[e]&&'"'!==t[e];e++)r+=t[e];if(-1!==(r=r.trim()).indexOf(" "))throw new Error("External entites are not supported");for(var i=t[e++],n="";e<t.length&&t[e]!==i;e++)n+=t[e];return[r,n,e]}function A(t,e){return"!"===t[e+1]&&"-"===t[e+2]&&"-"===t[e+3]}function O(t,e){return"!"===t[e+1]&&"E"===t[e+2]&&"N"===t[e+3]&&"T"===t[e+4]&&"I"===t[e+5]&&"T"===t[e+6]&&"Y"===t[e+7]}function P(t,e){return"!"===t[e+1]&&"E"===t[e+2]&&"L"===t[e+3]&&"E"===t[e+4]&&"M"===t[e+5]&&"E"===t[e+6]&&"N"===t[e+7]&&"T"===t[e+8]}function I(t,e){return"!"===t[e+1]&&"A"===t[e+2]&&"T"===t[e+3]&&"T"===t[e+4]&&"L"===t[e+5]&&"I"===t[e+6]&&"S"===t[e+7]&&"T"===t[e+8]}function C(t,e){return"!"===t[e+1]&&"N"===t[e+2]&&"O"===t[e+3]&&"T"===t[e+4]&&"A"===t[e+5]&&"T"===t[e+6]&&"I"===t[e+7]&&"O"===t[e+8]&&"N"===t[e+9]}function S(t){if(a(t))return t;throw new Error("Invalid entity name "+t)}const j=/^[-+]?0x[a-fA-F0-9]+$/,V=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,_={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function k(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function F(t){return"function"==typeof t?t:Array.isArray(t)?function(e){for(var r,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return k(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(r=i()).done;){var n=r.value;if("string"==typeof n&&e===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}}:function(){return!1}}var D=function(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:function(t,e){return String.fromCharCode(Number.parseInt(e,10))}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return String.fromCharCode(Number.parseInt(e,16))}}},this.addExternalEntities=L,this.parseXml=R,this.parseTextData=B,this.resolveNameSpace=M,this.buildAttributesMap=X,this.isItStopNode=$,this.replaceEntitiesValue=Z,this.readStopNodeData=z,this.saveTextToParentTag=Y,this.addChild=U,this.ignoreAttributesFn=F(this.options.ignoreAttributes)};function L(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];this.lastEntities[i]={regex:new RegExp("&"+i+";","g"),val:t[i]}}}function B(t,e,r,i,n,a,s){if(void 0!==t&&(this.options.trimValues&&!i&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t));var o=this.options.tagValueProcessor(e,t,r,n,a);return null==o?t:typeof o!=typeof t||o!==t?o:this.options.trimValues||t.trim()===t?J(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function M(t){if(this.options.removeNSPrefix){var e=t.split(":"),r="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=r+e[1])}return t}var G=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function X(t,e,r){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){for(var i=n(t,G),a=i.length,s={},o=0;o<a;o++){var u=this.resolveNameSpace(i[o][1]);if(!this.ignoreAttributesFn(u,e)){var l=i[o][4],h=this.options.attributeNamePrefix+u;if(u.length)if(this.options.transformAttributeName&&(h=this.options.transformAttributeName(h)),"__proto__"===h&&(h="#__proto__"),void 0!==l){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);var f=this.options.attributeValueProcessor(u,l,e);s[h]=null==f?l:typeof f!=typeof l||f!==l?f:J(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[h]=!0)}}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){var d={};return d[this.options.attributesGroupName]=s,d}return s}}var R=function(t){t=t.replace(/\r\n?/g,"\n");for(var e=new E("!xml"),r=e,i="",n="",a=0;a<t.length;a++)if("<"===t[a])if("/"===t[a+1]){var s=q(t,">",a,"Closing Tag is not closed."),o=t.substring(a+2,s).trim();if(this.options.removeNSPrefix){var u=o.indexOf(":");-1!==u&&(o=o.substr(u+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),r&&(i=this.saveTextToParentTag(i,r,n));var l=n.substring(n.lastIndexOf(".")+1);if(o&&-1!==this.options.unpairedTags.indexOf(o))throw new Error("Unpaired tag can not be used as closing tag: </"+o+">");var h=0;l&&-1!==this.options.unpairedTags.indexOf(l)?(h=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):h=n.lastIndexOf("."),n=n.substring(0,h),r=this.tagsNodeStack.pop(),i="",a=s}else if("?"===t[a+1]){var f=W(t,a,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,r,n),this.options.ignoreDeclaration&&"?xml"===f.tagName||this.options.ignorePiTags);else{var d=new E(f.tagName);d.add(this.options.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(d[":@"]=this.buildAttributesMap(f.tagExp,n,f.tagName)),this.addChild(r,d,n)}a=f.closeIndex+1}else if("!--"===t.substr(a+1,3)){var p=q(t,"--\x3e",a+4,"Comment is not closed.");if(this.options.commentPropName){var g,c=t.substring(a+4,p-2);i=this.saveTextToParentTag(i,r,n),r.add(this.options.commentPropName,[(g={},g[this.options.textNodeName]=c,g)])}a=p}else if("!D"===t.substr(a+1,2)){var v=T(t,a);this.docTypeEntities=v.entities,a=v.i}else if("!["===t.substr(a+1,2)){var m=q(t,"]]>",a,"CDATA is not closed.")-2,x=t.substring(a+9,m);i=this.saveTextToParentTag(i,r,n);var b,N=this.parseTextData(x,r.tagname,n,!0,!1,!0,!0);null==N&&(N=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[(b={},b[this.options.textNodeName]=x,b)]):r.add(this.options.textNodeName,N),a=m+2}else{var y=W(t,a,this.options.removeNSPrefix),w=y.tagName,A=y.rawTagName,O=y.tagExp,P=y.attrExpPresent,I=y.closeIndex;this.options.transformTagName&&(w=this.options.transformTagName(w)),r&&i&&"!xml"!==r.tagname&&(i=this.saveTextToParentTag(i,r,n,!1));var C=r;if(C&&-1!==this.options.unpairedTags.indexOf(C.tagname)&&(r=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),w!==e.tagname&&(n+=n?"."+w:w),this.isItStopNode(this.options.stopNodes,n,w)){var S="";if(O.length>0&&O.lastIndexOf("/")===O.length-1)"/"===w[w.length-1]?(w=w.substr(0,w.length-1),n=n.substr(0,n.length-1),O=w):O=O.substr(0,O.length-1),a=y.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(w))a=y.closeIndex;else{var j=this.readStopNodeData(t,A,I+1);if(!j)throw new Error("Unexpected end of "+A);a=j.i,S=j.tagContent}var V=new E(w);w!==O&&P&&(V[":@"]=this.buildAttributesMap(O,n,w)),S&&(S=this.parseTextData(S,w,n,!0,P,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),V.add(this.options.textNodeName,S),this.addChild(r,V,n)}else{if(O.length>0&&O.lastIndexOf("/")===O.length-1){"/"===w[w.length-1]?(w=w.substr(0,w.length-1),n=n.substr(0,n.length-1),O=w):O=O.substr(0,O.length-1),this.options.transformTagName&&(w=this.options.transformTagName(w));var _=new E(w);w!==O&&P&&(_[":@"]=this.buildAttributesMap(O,n,w)),this.addChild(r,_,n),n=n.substr(0,n.lastIndexOf("."))}else{var k=new E(w);this.tagsNodeStack.push(r),w!==O&&P&&(k[":@"]=this.buildAttributesMap(O,n,w)),this.addChild(r,k,n),r=k}i="",a=I}}else i+=t[a];return e.child};function U(t,e,r){var i=this.options.updateTag(e.tagname,r,e[":@"]);!1===i||("string"==typeof i?(e.tagname=i,t.addChild(e)):t.addChild(e))}var Z=function(t){if(this.options.processEntities){for(var e in this.docTypeEntities){var r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(var i in this.lastEntities){var n=this.lastEntities[i];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(var a in this.htmlEntities){var s=this.htmlEntities[a];t=t.replace(s.regex,s.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function Y(t,e,r,i){return t&&(void 0===i&&(i=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,i))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function $(t,e,r){var i="*."+r;for(var n in t){var a=t[n];if(i===a||e===a)return!0}return!1}function q(t,e,r,i){var n=t.indexOf(e,r);if(-1===n)throw new Error(i);return n+e.length-1}function W(t,e,r,i){void 0===i&&(i=">");var n=function(t,e,r){var i;void 0===r&&(r=">");for(var n="",a=e;a<t.length;a++){var s=t[a];if(i)s===i&&(i="");else if('"'===s||"'"===s)i=s;else if(s===r[0]){if(!r[1])return{data:n,index:a};if(t[a+1]===r[1])return{data:n,index:a}}else"\t"===s&&(s=" ");n+=s}}(t,e+1,i);if(n){var a=n.data,s=n.index,o=a.search(/\s/),u=a,l=!0;-1!==o&&(u=a.substring(0,o),a=a.substring(o+1).trimStart());var h=u;if(r){var f=u.indexOf(":");-1!==f&&(l=(u=u.substr(f+1))!==n.data.substr(f+1))}return{tagName:u,tagExp:a,closeIndex:s,attrExpPresent:l,rawTagName:h}}}function z(t,e,r){for(var i=r,n=1;r<t.length;r++)if("<"===t[r])if("/"===t[r+1]){var a=q(t,">",r,e+" is not closed");if(t.substring(r+2,a).trim()===e&&0==--n)return{tagContent:t.substring(i,r),i:a};r=a}else if("?"===t[r+1])r=q(t,"?>",r+1,"StopNode is not closed.");else if("!--"===t.substr(r+1,3))r=q(t,"--\x3e",r+3,"StopNode is not closed.");else if("!["===t.substr(r+1,2))r=q(t,"]]>",r,"StopNode is not closed.")-2;else{var s=W(t,r,">");s&&((s&&s.tagName)===e&&"/"!==s.tagExp[s.tagExp.length-1]&&n++,r=s.closeIndex)}}function J(t,e,r){if(e&&"string"==typeof t){var i=t.trim();return"true"===i||"false"!==i&&function(t,e={}){if(e=Object.assign({},_,e),!t||"string"!=typeof t)return t;if("0"===t)return 0;let r=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(r))return t;if(e.hex&&j.test(r))return function(t){if(parseInt)return parseInt(t,16);if(Number.parseInt)return Number.parseInt(t,16);if(window&&window.parseInt)return window.parseInt(t,16);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(r);if(-1!==r.search(/[eE]/)){const i=r.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(i){if(e.leadingZeros)r=(i[1]||"")+i[3];else if("0"!==i[2]||"."!==i[3][0])return t;return e.eNotation?Number(r):t}return t}{const n=V.exec(r);if(n){const a=n[1],s=n[2];let o=(i=n[3])&&-1!==i.indexOf(".")?("."===(i=i.replace(/0+$/,""))?i="0":"."===i[0]?i="0"+i:"."===i[i.length-1]&&(i=i.substr(0,i.length-1)),i):i;if(!e.leadingZeros&&s.length>0&&a&&"."!==r[2])return t;if(!e.leadingZeros&&s.length>0&&!a&&"."!==r[1])return t;if(e.leadingZeros&&s===t)return 0;{const i=Number(r),n=""+i;return-1!==n.search(/[eE]/)?e.eNotation?i:t:-1!==r.indexOf(".")?"0"===n&&""===o||n===o||a&&n==="-"+o?i:t:s?o===n||a+o===n?i:t:r===n||r===a+n?i:t}}return t}var i}(t,r)}return void 0!==t?t:""}function H(t,e){return K(t,e)}function K(t,e,r){for(var i,n={},a=0;a<t.length;a++){var s,o=t[a],u=Q(o);if(s=void 0===r?u:r+"."+u,u===e.textNodeName)void 0===i?i=o[u]:i+=""+o[u];else{if(void 0===u)continue;if(o[u]){var l=K(o[u],e,s),h=et(l,e);o[":@"]?tt(l,o[":@"],s,e):1!==Object.keys(l).length||void 0===l[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(l).length&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""):l=l[e.textNodeName],void 0!==n[u]&&n.hasOwnProperty(u)?(Array.isArray(n[u])||(n[u]=[n[u]]),n[u].push(l)):e.isArray(u,s,h)?n[u]=[l]:n[u]=l}}}return"string"==typeof i?i.length>0&&(n[e.textNodeName]=i):void 0!==i&&(n[e.textNodeName]=i),n}function Q(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(":@"!==i)return i}}function tt(t,e,r,i){if(e)for(var n=Object.keys(e),a=n.length,s=0;s<a;s++){var o=n[s];i.isArray(o,r+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}function et(t,e){var r=e.textNodeName,i=Object.keys(t).length;return 0===i||!(1!==i||!t[r]&&"boolean"!=typeof t[r]&&0!==t[r])}var rt=function(){function t(t){this.externalEntities={},this.options=function(t){return Object.assign({},y,t)}(t)}var e=t.prototype;return e.parse=function(t,e){if("string"==typeof t);else{if(!t.toString)throw new Error("XML data is accepted in String or Bytes[] form.");t=t.toString()}if(e){!0===e&&(e={});var r=o(t,e);if(!0!==r)throw Error(r.err.msg+":"+r.err.line+":"+r.err.col)}var i=new D(this.options);i.addExternalEntities(this.externalEntities);var n=i.parseXml(t);return this.options.preserveOrder||void 0===n?n:H(n,this.options)},e.addEntity=function(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t}();function it(t,e){var r="";return e.format&&e.indentBy.length>0&&(r="\n"),nt(t,e,"",r)}function nt(t,e,r,i){for(var n="",a=!1,s=0;s<t.length;s++){var o=t[s],u=at(o);if(void 0!==u){var l;if(l=0===r.length?u:r+"."+u,u!==e.textNodeName)if(u!==e.cdataPropName)if(u!==e.commentPropName)if("?"!==u[0]){var h=i;""!==h&&(h+=e.indentBy);var f=i+"<"+u+st(o[":@"],e),d=nt(o[u],e,l,h);-1!==e.unpairedTags.indexOf(u)?e.suppressUnpairedNode?n+=f+">":n+=f+"/>":d&&0!==d.length||!e.suppressEmptyNode?d&&d.endsWith(">")?n+=f+">"+d+i+"</"+u+">":(n+=f+">",d&&""!==i&&(d.includes("/>")||d.includes("</"))?n+=i+e.indentBy+d+i:n+=d,n+="</"+u+">"):n+=f+"/>",a=!0}else{var p=st(o[":@"],e),g="?xml"===u?"":i,c=o[u][0][e.textNodeName];n+=g+"<"+u+(c=0!==c.length?" "+c:"")+p+"?>",a=!0}else n+=i+"\x3c!--"+o[u][0][e.textNodeName]+"--\x3e",a=!0;else a&&(n+=i),n+="<![CDATA["+o[u][0][e.textNodeName]+"]]>",a=!1;else{var v=o[u];ot(l,e)||(v=ut(v=e.tagValueProcessor(u,v),e)),a&&(n+=i),n+=v,a=!1}}}return n}function at(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(t.hasOwnProperty(i)&&":@"!==i)return i}}function st(t,e){var r="";if(t&&!e.ignoreAttributes)for(var i in t)if(t.hasOwnProperty(i)){var n=e.attributeValueProcessor(i,t[i]);!0===(n=ut(n,e))&&e.suppressBooleanAttributes?r+=" "+i.substr(e.attributeNamePrefix.length):r+=" "+i.substr(e.attributeNamePrefix.length)+'="'+n+'"'}return r}function ot(t,e){var r=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(var i in e.stopNodes)if(e.stopNodes[i]===t||e.stopNodes[i]==="*."+r)return!0;return!1}function ut(t,e){if(t&&t.length>0&&e.processEntities)for(var r=0;r<e.entities.length;r++){var i=e.entities[r];t=t.replace(i.regex,i.val)}return t}var lt={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function ht(t){this.options=Object.assign({},lt,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=F(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=pt),this.processTextOrObjNode=ft,this.options.format?(this.indentate=dt,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function ft(t,e,r,i){var n=this.j2x(t,r+1,i.concat(e));return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function dt(t){return this.options.indentBy.repeat(t)}function pt(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}ht.prototype.build=function(t){return this.options.preserveOrder?it(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&((e={})[this.options.arrayNodeName]=t,t=e),this.j2x(t,0,[]).val);var e},ht.prototype.j2x=function(t,e,r){var i="",n="",a=r.join(".");for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))if(void 0===t[s])this.isAttribute(s)&&(n+="");else if(null===t[s])this.isAttribute(s)||s===this.options.cdataPropName?n+="":"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if(t[s]instanceof Date)n+=this.buildTextValNode(t[s],s,"",e);else if("object"!=typeof t[s]){var o=this.isAttribute(s);if(o&&!this.ignoreAttributesFn(o,a))i+=this.buildAttrPairStr(o,""+t[s]);else if(!o)if(s===this.options.textNodeName){var u=this.options.tagValueProcessor(s,""+t[s]);n+=this.replaceEntitiesValue(u)}else n+=this.buildTextValNode(t[s],s,"",e)}else if(Array.isArray(t[s])){for(var l=t[s].length,h="",f="",d=0;d<l;d++){var p=t[s][d];if(void 0===p);else if(null===p)"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if("object"==typeof p)if(this.options.oneListGroup){var g=this.j2x(p,e+1,r.concat(s));h+=g.val,this.options.attributesGroupName&&p.hasOwnProperty(this.options.attributesGroupName)&&(f+=g.attrStr)}else h+=this.processTextOrObjNode(p,s,e,r);else if(this.options.oneListGroup){var c=this.options.tagValueProcessor(s,p);h+=c=this.replaceEntitiesValue(c)}else h+=this.buildTextValNode(p,s,"",e)}this.options.oneListGroup&&(h=this.buildObjectNode(h,s,f,e)),n+=h}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName)for(var v=Object.keys(t[s]),m=v.length,x=0;x<m;x++)i+=this.buildAttrPairStr(v[x],""+t[s][v[x]]);else n+=this.processTextOrObjNode(t[s],s,e,r);return{attrStr:i,val:n}},ht.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},ht.prototype.buildObjectNode=function(t,e,r,i){if(""===t)return"?"===e[0]?this.indentate(i)+"<"+e+r+"?"+this.tagEndChar:this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar;var n="</"+e+this.tagEndChar,a="";return"?"===e[0]&&(a="?",n=""),!r&&""!==r||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===a.length?this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine:this.indentate(i)+"<"+e+r+a+this.tagEndChar+t+this.indentate(i)+n:this.indentate(i)+"<"+e+r+a+">"+t+n},ht.prototype.closeTag=function(t){var e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":"></"+t,e},ht.prototype.buildTextValNode=function(t,e,r,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+"<![CDATA["+t+"]]>"+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;var n=this.options.tagValueProcessor(e,t);return""===(n=this.replaceEntitiesValue(n))?this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+r+">"+n+"</"+e+this.tagEndChar},ht.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(var e=0;e<this.options.entities.length;e++){var r=this.options.entities[e];t=t.replace(r.regex,r.val)}return t};var gt={validate:o};return e})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.fxp=e():t.fxp=e()}(this,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var i in r)t.o(r,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:r[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>ht,XMLParser:()=>rt,XMLValidator:()=>gt});var r=":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",i=new RegExp("^["+r+"]["+r+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function n(t,e){for(var r=[],i=e.exec(t);i;){var n=[];n.startIndex=e.lastIndex-i[0].length;for(var a=i.length,s=0;s<a;s++)n.push(i[s]);r.push(n),i=e.exec(t)}return r}var a=function(t){return!(null==i.exec(t))},s={allowBooleanAttributes:!1,unpairedTags:[]};function o(t,e){e=Object.assign({},s,e);var r=[],i=!1,n=!1;"\ufeff"===t[0]&&(t=t.substr(1));for(var o=0;o<t.length;o++)if("<"===t[o]&&"?"===t[o+1]){if((o=l(t,o+=2)).err)return o}else{if("<"!==t[o]){if(u(t[o]))continue;return m("InvalidChar","char '"+t[o]+"' is not expected.",b(t,o))}var f=o;if("!"===t[++o]){o=h(t,o);continue}var d=!1;"/"===t[o]&&(d=!0,o++);for(var g="";o<t.length&&">"!==t[o]&&" "!==t[o]&&"\t"!==t[o]&&"\n"!==t[o]&&"\r"!==t[o];o++)g+=t[o];if("/"===(g=g.trim())[g.length-1]&&(g=g.substring(0,g.length-1),o--),!a(g))return m("InvalidTag",0===g.trim().length?"Invalid space after '<'.":"Tag '"+g+"' is an invalid name.",b(t,o));var x=p(t,o);if(!1===x)return m("InvalidAttr","Attributes for '"+g+"' have open quote.",b(t,o));var N=x.value;if(o=x.index,"/"===N[N.length-1]){var y=o-N.length,E=c(N=N.substring(0,N.length-1),e);if(!0!==E)return m(E.err.code,E.err.msg,b(t,y+E.err.line));i=!0}else if(d){if(!x.tagClosed)return m("InvalidTag","Closing tag '"+g+"' doesn't have proper closing.",b(t,o));if(N.trim().length>0)return m("InvalidTag","Closing tag '"+g+"' can't have attributes or invalid starting.",b(t,f));if(0===r.length)return m("InvalidTag","Closing tag '"+g+"' has not been opened.",b(t,f));var T=r.pop();if(g!==T.tagName){var w=b(t,T.tagStartPos);return m("InvalidTag","Expected closing tag '"+T.tagName+"' (opened in line "+w.line+", col "+w.col+") instead of closing tag '"+g+"'.",b(t,f))}0==r.length&&(n=!0)}else{var A=c(N,e);if(!0!==A)return m(A.err.code,A.err.msg,b(t,o-N.length+A.err.line));if(!0===n)return m("InvalidXml","Multiple possible root nodes found.",b(t,o));-1!==e.unpairedTags.indexOf(g)||r.push({tagName:g,tagStartPos:f}),i=!0}for(o++;o<t.length;o++)if("<"===t[o]){if("!"===t[o+1]){o=h(t,++o);continue}if("?"!==t[o+1])break;if((o=l(t,++o)).err)return o}else if("&"===t[o]){var O=v(t,o);if(-1==O)return m("InvalidChar","char '&' is not expected.",b(t,o));o=O}else if(!0===n&&!u(t[o]))return m("InvalidXml","Extra text at the end",b(t,o));"<"===t[o]&&o--}return i?1==r.length?m("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",b(t,r[0].tagStartPos)):!(r.length>0)||m("InvalidXml","Invalid '"+JSON.stringify(r.map((function(t){return t.tagName})),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):m("InvalidXml","Start tag expected.",1)}function u(t){return" "===t||"\t"===t||"\n"===t||"\r"===t}function l(t,e){for(var r=e;e<t.length;e++)if("?"!=t[e]&&" "!=t[e]);else{var i=t.substr(r,e-r);if(e>5&&"xml"===i)return m("InvalidXml","XML declaration allowed only at the start of the document.",b(t,e));if("?"==t[e]&&">"==t[e+1]){e++;break}}return e}function h(t,e){if(t.length>e+5&&"-"===t[e+1]&&"-"===t[e+2]){for(e+=3;e<t.length;e++)if("-"===t[e]&&"-"===t[e+1]&&">"===t[e+2]){e+=2;break}}else if(t.length>e+8&&"D"===t[e+1]&&"O"===t[e+2]&&"C"===t[e+3]&&"T"===t[e+4]&&"Y"===t[e+5]&&"P"===t[e+6]&&"E"===t[e+7]){var r=1;for(e+=8;e<t.length;e++)if("<"===t[e])r++;else if(">"===t[e]&&0==--r)break}else if(t.length>e+9&&"["===t[e+1]&&"C"===t[e+2]&&"D"===t[e+3]&&"A"===t[e+4]&&"T"===t[e+5]&&"A"===t[e+6]&&"["===t[e+7])for(e+=8;e<t.length;e++)if("]"===t[e]&&"]"===t[e+1]&&">"===t[e+2]){e+=2;break}return e}var f='"',d="'";function p(t,e){for(var r="",i="",n=!1;e<t.length;e++){if(t[e]===f||t[e]===d)""===i?i=t[e]:i!==t[e]||(i="");else if(">"===t[e]&&""===i){n=!0;break}r+=t[e]}return""===i&&{value:r,index:e,tagClosed:n}}var g=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function c(t,e){for(var r=n(t,g),i={},a=0;a<r.length;a++){if(0===r[a][1].length)return m("InvalidAttr","Attribute '"+r[a][2]+"' has no space in starting.",N(r[a]));if(void 0!==r[a][3]&&void 0===r[a][4])return m("InvalidAttr","Attribute '"+r[a][2]+"' is without value.",N(r[a]));if(void 0===r[a][3]&&!e.allowBooleanAttributes)return m("InvalidAttr","boolean attribute '"+r[a][2]+"' is not allowed.",N(r[a]));var s=r[a][2];if(!x(s))return m("InvalidAttr","Attribute '"+s+"' is an invalid name.",N(r[a]));if(i.hasOwnProperty(s))return m("InvalidAttr","Attribute '"+s+"' is repeated.",N(r[a]));i[s]=1}return!0}function v(t,e){if(";"===t[++e])return-1;if("#"===t[e])return function(t,e){var r=/\d/;for("x"===t[e]&&(e++,r=/[\da-fA-F]/);e<t.length;e++){if(";"===t[e])return e;if(!t[e].match(r))break}return-1}(t,++e);for(var r=0;e<t.length;e++,r++)if(!(t[e].match(/\w/)&&r<20)){if(";"===t[e])break;return-1}return e}function m(t,e,r){return{err:{code:t,msg:e,line:r.line||r,col:r.col}}}function x(t){return a(t)}function b(t,e){var r=t.substring(0,e).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function N(t){return t.startIndex+t[1].length}var y={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:function(){return!1},commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(t,e,r){return t}},E=function(){function t(t){this.tagname=t,this.child=[],this[":@"]={}}var e=t.prototype;return e.add=function(t,e){var r;"__proto__"===t&&(t="#__proto__"),this.child.push(((r={})[t]=e,r))},e.addChild=function(t){var e,r;"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push(((e={})[t.tagname]=t.child,e[":@"]=t[":@"],e)):this.child.push(((r={})[t.tagname]=t.child,r))},t}();function T(t,e){var r={};if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");e+=9;for(var i=1,n=!1,a=!1;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,i--):i--,0===i)break}else"["===t[e]?n=!0:t[e];else{if(n&&O(t,e)){var s,o=void 0,u=w(t,(e+=7)+1);s=u[0],o=u[1],e=u[2],-1===o.indexOf("&")&&(r[S(s)]={regx:RegExp("&"+s+";","g"),val:o})}else if(n&&P(t,e))e+=8;else if(n&&I(t,e))e+=8;else if(n&&C(t,e))e+=9;else{if(!A)throw new Error("Invalid DOCTYPE");a=!0}i++}if(0!==i)throw new Error("Unclosed DOCTYPE");return{entities:r,i:e}}function w(t,e){for(var r="";e<t.length&&"'"!==t[e]&&'"'!==t[e];e++)r+=t[e];if(-1!==(r=r.trim()).indexOf(" "))throw new Error("External entites are not supported");for(var i=t[e++],n="";e<t.length&&t[e]!==i;e++)n+=t[e];return[r,n,e]}function A(t,e){return"!"===t[e+1]&&"-"===t[e+2]&&"-"===t[e+3]}function O(t,e){return"!"===t[e+1]&&"E"===t[e+2]&&"N"===t[e+3]&&"T"===t[e+4]&&"I"===t[e+5]&&"T"===t[e+6]&&"Y"===t[e+7]}function P(t,e){return"!"===t[e+1]&&"E"===t[e+2]&&"L"===t[e+3]&&"E"===t[e+4]&&"M"===t[e+5]&&"E"===t[e+6]&&"N"===t[e+7]&&"T"===t[e+8]}function I(t,e){return"!"===t[e+1]&&"A"===t[e+2]&&"T"===t[e+3]&&"T"===t[e+4]&&"L"===t[e+5]&&"I"===t[e+6]&&"S"===t[e+7]&&"T"===t[e+8]}function C(t,e){return"!"===t[e+1]&&"N"===t[e+2]&&"O"===t[e+3]&&"T"===t[e+4]&&"A"===t[e+5]&&"T"===t[e+6]&&"I"===t[e+7]&&"O"===t[e+8]&&"N"===t[e+9]}function S(t){if(a(t))return t;throw new Error("Invalid entity name "+t)}const j=/^[-+]?0x[a-fA-F0-9]+$/,V=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,_={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function k(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function F(t){return"function"==typeof t?t:Array.isArray(t)?function(e){for(var r,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return k(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?k(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(r=i()).done;){var n=r.value;if("string"==typeof n&&e===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}}:function(){return!1}}var D=function(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:function(t,e){return String.fromCharCode(Number.parseInt(e,10))}},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:function(t,e){return String.fromCharCode(Number.parseInt(e,16))}}},this.addExternalEntities=L,this.parseXml=R,this.parseTextData=B,this.resolveNameSpace=M,this.buildAttributesMap=X,this.isItStopNode=$,this.replaceEntitiesValue=Z,this.readStopNodeData=z,this.saveTextToParentTag=Y,this.addChild=U,this.ignoreAttributesFn=F(this.options.ignoreAttributes)};function L(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];this.lastEntities[i]={regex:new RegExp("&"+i+";","g"),val:t[i]}}}function B(t,e,r,i,n,a,s){if(void 0!==t&&(this.options.trimValues&&!i&&(t=t.trim()),t.length>0)){s||(t=this.replaceEntitiesValue(t));var o=this.options.tagValueProcessor(e,t,r,n,a);return null==o?t:typeof o!=typeof t||o!==t?o:this.options.trimValues||t.trim()===t?J(t,this.options.parseTagValue,this.options.numberParseOptions):t}}function M(t){if(this.options.removeNSPrefix){var e=t.split(":"),r="/"===t.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(t=r+e[1])}return t}var G=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function X(t,e,r){if(!0!==this.options.ignoreAttributes&&"string"==typeof t){for(var i=n(t,G),a=i.length,s={},o=0;o<a;o++){var u=this.resolveNameSpace(i[o][1]);if(!this.ignoreAttributesFn(u,e)){var l=i[o][4],h=this.options.attributeNamePrefix+u;if(u.length)if(this.options.transformAttributeName&&(h=this.options.transformAttributeName(h)),"__proto__"===h&&(h="#__proto__"),void 0!==l){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);var f=this.options.attributeValueProcessor(u,l,e);s[h]=null==f?l:typeof f!=typeof l||f!==l?f:J(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[h]=!0)}}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){var d={};return d[this.options.attributesGroupName]=s,d}return s}}var R=function(t){t=t.replace(/\r\n?/g,"\n");for(var e=new E("!xml"),r=e,i="",n="",a=0;a<t.length;a++)if("<"===t[a])if("/"===t[a+1]){var s=q(t,">",a,"Closing Tag is not closed."),o=t.substring(a+2,s).trim();if(this.options.removeNSPrefix){var u=o.indexOf(":");-1!==u&&(o=o.substr(u+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),r&&(i=this.saveTextToParentTag(i,r,n));var l=n.substring(n.lastIndexOf(".")+1);if(o&&-1!==this.options.unpairedTags.indexOf(o))throw new Error("Unpaired tag can not be used as closing tag: </"+o+">");var h=0;l&&-1!==this.options.unpairedTags.indexOf(l)?(h=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):h=n.lastIndexOf("."),n=n.substring(0,h),r=this.tagsNodeStack.pop(),i="",a=s}else if("?"===t[a+1]){var f=W(t,a,!1,"?>");if(!f)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,r,n),this.options.ignoreDeclaration&&"?xml"===f.tagName||this.options.ignorePiTags);else{var d=new E(f.tagName);d.add(this.options.textNodeName,""),f.tagName!==f.tagExp&&f.attrExpPresent&&(d[":@"]=this.buildAttributesMap(f.tagExp,n,f.tagName)),this.addChild(r,d,n)}a=f.closeIndex+1}else if("!--"===t.substr(a+1,3)){var p=q(t,"--\x3e",a+4,"Comment is not closed.");if(this.options.commentPropName){var g,c=t.substring(a+4,p-2);i=this.saveTextToParentTag(i,r,n),r.add(this.options.commentPropName,[(g={},g[this.options.textNodeName]=c,g)])}a=p}else if("!D"===t.substr(a+1,2)){var v=T(t,a);this.docTypeEntities=v.entities,a=v.i}else if("!["===t.substr(a+1,2)){var m=q(t,"]]>",a,"CDATA is not closed.")-2,x=t.substring(a+9,m);i=this.saveTextToParentTag(i,r,n);var b,N=this.parseTextData(x,r.tagname,n,!0,!1,!0,!0);null==N&&(N=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[(b={},b[this.options.textNodeName]=x,b)]):r.add(this.options.textNodeName,N),a=m+2}else{var y=W(t,a,this.options.removeNSPrefix),w=y.tagName,A=y.rawTagName,O=y.tagExp,P=y.attrExpPresent,I=y.closeIndex;this.options.transformTagName&&(w=this.options.transformTagName(w)),r&&i&&"!xml"!==r.tagname&&(i=this.saveTextToParentTag(i,r,n,!1));var C=r;if(C&&-1!==this.options.unpairedTags.indexOf(C.tagname)&&(r=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),w!==e.tagname&&(n+=n?"."+w:w),this.isItStopNode(this.options.stopNodes,n,w)){var S="";if(O.length>0&&O.lastIndexOf("/")===O.length-1)"/"===w[w.length-1]?(w=w.substr(0,w.length-1),n=n.substr(0,n.length-1),O=w):O=O.substr(0,O.length-1),a=y.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(w))a=y.closeIndex;else{var j=this.readStopNodeData(t,A,I+1);if(!j)throw new Error("Unexpected end of "+A);a=j.i,S=j.tagContent}var V=new E(w);w!==O&&P&&(V[":@"]=this.buildAttributesMap(O,n,w)),S&&(S=this.parseTextData(S,w,n,!0,P,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),V.add(this.options.textNodeName,S),this.addChild(r,V,n)}else{if(O.length>0&&O.lastIndexOf("/")===O.length-1){"/"===w[w.length-1]?(w=w.substr(0,w.length-1),n=n.substr(0,n.length-1),O=w):O=O.substr(0,O.length-1),this.options.transformTagName&&(w=this.options.transformTagName(w));var _=new E(w);w!==O&&P&&(_[":@"]=this.buildAttributesMap(O,n,w)),this.addChild(r,_,n),n=n.substr(0,n.lastIndexOf("."))}else{var k=new E(w);this.tagsNodeStack.push(r),w!==O&&P&&(k[":@"]=this.buildAttributesMap(O,n,w)),this.addChild(r,k,n),r=k}i="",a=I}}else i+=t[a];return e.child};function U(t,e,r){var i=this.options.updateTag(e.tagname,r,e[":@"]);!1===i||("string"==typeof i?(e.tagname=i,t.addChild(e)):t.addChild(e))}var Z=function(t){if(this.options.processEntities){for(var e in this.docTypeEntities){var r=this.docTypeEntities[e];t=t.replace(r.regx,r.val)}for(var i in this.lastEntities){var n=this.lastEntities[i];t=t.replace(n.regex,n.val)}if(this.options.htmlEntities)for(var a in this.htmlEntities){var s=this.htmlEntities[a];t=t.replace(s.regex,s.val)}t=t.replace(this.ampEntity.regex,this.ampEntity.val)}return t};function Y(t,e,r,i){return t&&(void 0===i&&(i=0===e.child.length),void 0!==(t=this.parseTextData(t,e.tagname,r,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,i))&&""!==t&&e.add(this.options.textNodeName,t),t=""),t}function $(t,e,r){var i="*."+r;for(var n in t){var a=t[n];if(i===a||e===a)return!0}return!1}function q(t,e,r,i){var n=t.indexOf(e,r);if(-1===n)throw new Error(i);return n+e.length-1}function W(t,e,r,i){void 0===i&&(i=">");var n=function(t,e,r){var i;void 0===r&&(r=">");for(var n="",a=e;a<t.length;a++){var s=t[a];if(i)s===i&&(i="");else if('"'===s||"'"===s)i=s;else if(s===r[0]){if(!r[1])return{data:n,index:a};if(t[a+1]===r[1])return{data:n,index:a}}else"\t"===s&&(s=" ");n+=s}}(t,e+1,i);if(n){var a=n.data,s=n.index,o=a.search(/\s/),u=a,l=!0;-1!==o&&(u=a.substring(0,o),a=a.substring(o+1).trimStart());var h=u;if(r){var f=u.indexOf(":");-1!==f&&(l=(u=u.substr(f+1))!==n.data.substr(f+1))}return{tagName:u,tagExp:a,closeIndex:s,attrExpPresent:l,rawTagName:h}}}function z(t,e,r){for(var i=r,n=1;r<t.length;r++)if("<"===t[r])if("/"===t[r+1]){var a=q(t,">",r,e+" is not closed");if(t.substring(r+2,a).trim()===e&&0==--n)return{tagContent:t.substring(i,r),i:a};r=a}else if("?"===t[r+1])r=q(t,"?>",r+1,"StopNode is not closed.");else if("!--"===t.substr(r+1,3))r=q(t,"--\x3e",r+3,"StopNode is not closed.");else if("!["===t.substr(r+1,2))r=q(t,"]]>",r,"StopNode is not closed.")-2;else{var s=W(t,r,">");s&&((s&&s.tagName)===e&&"/"!==s.tagExp[s.tagExp.length-1]&&n++,r=s.closeIndex)}}function J(t,e,r){if(e&&"string"==typeof t){var i=t.trim();return"true"===i||"false"!==i&&function(t,e={}){if(e=Object.assign({},_,e),!t||"string"!=typeof t)return t;let r=t.trim();if(void 0!==e.skipLike&&e.skipLike.test(r))return t;if("0"===t)return 0;if(e.hex&&j.test(r))return function(t){if(parseInt)return parseInt(t,16);if(Number.parseInt)return Number.parseInt(t,16);if(window&&window.parseInt)return window.parseInt(t,16);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(r);if(-1!==r.search(/[eE]/)){const i=r.match(/^([-\+])?(0*)([0-9]*(\.[0-9]*)?[eE][-\+]?[0-9]+)$/);if(i){if(e.leadingZeros)r=(i[1]||"")+i[3];else if("0"!==i[2]||"."!==i[3][0])return t;return e.eNotation?Number(r):t}return t}{const n=V.exec(r);if(n){const a=n[1],s=n[2];let o=(i=n[3])&&-1!==i.indexOf(".")?("."===(i=i.replace(/0+$/,""))?i="0":"."===i[0]?i="0"+i:"."===i[i.length-1]&&(i=i.substr(0,i.length-1)),i):i;if(!e.leadingZeros&&s.length>0&&a&&"."!==r[2])return t;if(!e.leadingZeros&&s.length>0&&!a&&"."!==r[1])return t;if(e.leadingZeros&&s===t)return 0;{const i=Number(r),n=""+i;return-1!==n.search(/[eE]/)?e.eNotation?i:t:-1!==r.indexOf(".")?"0"===n&&""===o||n===o||a&&n==="-"+o?i:t:s?o===n||a+o===n?i:t:r===n||r===a+n?i:t}}return t}var i}(t,r)}return void 0!==t?t:""}function H(t,e){return K(t,e)}function K(t,e,r){for(var i,n={},a=0;a<t.length;a++){var s,o=t[a],u=Q(o);if(s=void 0===r?u:r+"."+u,u===e.textNodeName)void 0===i?i=o[u]:i+=""+o[u];else{if(void 0===u)continue;if(o[u]){var l=K(o[u],e,s),h=et(l,e);o[":@"]?tt(l,o[":@"],s,e):1!==Object.keys(l).length||void 0===l[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(l).length&&(e.alwaysCreateTextNode?l[e.textNodeName]="":l=""):l=l[e.textNodeName],void 0!==n[u]&&n.hasOwnProperty(u)?(Array.isArray(n[u])||(n[u]=[n[u]]),n[u].push(l)):e.isArray(u,s,h)?n[u]=[l]:n[u]=l}}}return"string"==typeof i?i.length>0&&(n[e.textNodeName]=i):void 0!==i&&(n[e.textNodeName]=i),n}function Q(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(":@"!==i)return i}}function tt(t,e,r,i){if(e)for(var n=Object.keys(e),a=n.length,s=0;s<a;s++){var o=n[s];i.isArray(o,r+"."+o,!0,!0)?t[o]=[e[o]]:t[o]=e[o]}}function et(t,e){var r=e.textNodeName,i=Object.keys(t).length;return 0===i||!(1!==i||!t[r]&&"boolean"!=typeof t[r]&&0!==t[r])}var rt=function(){function t(t){this.externalEntities={},this.options=function(t){return Object.assign({},y,t)}(t)}var e=t.prototype;return e.parse=function(t,e){if("string"==typeof t);else{if(!t.toString)throw new Error("XML data is accepted in String or Bytes[] form.");t=t.toString()}if(e){!0===e&&(e={});var r=o(t,e);if(!0!==r)throw Error(r.err.msg+":"+r.err.line+":"+r.err.col)}var i=new D(this.options);i.addExternalEntities(this.externalEntities);var n=i.parseXml(t);return this.options.preserveOrder||void 0===n?n:H(n,this.options)},e.addEntity=function(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e},t}();function it(t,e){var r="";return e.format&&e.indentBy.length>0&&(r="\n"),nt(t,e,"",r)}function nt(t,e,r,i){for(var n="",a=!1,s=0;s<t.length;s++){var o=t[s],u=at(o);if(void 0!==u){var l;if(l=0===r.length?u:r+"."+u,u!==e.textNodeName)if(u!==e.cdataPropName)if(u!==e.commentPropName)if("?"!==u[0]){var h=i;""!==h&&(h+=e.indentBy);var f=i+"<"+u+st(o[":@"],e),d=nt(o[u],e,l,h);-1!==e.unpairedTags.indexOf(u)?e.suppressUnpairedNode?n+=f+">":n+=f+"/>":d&&0!==d.length||!e.suppressEmptyNode?d&&d.endsWith(">")?n+=f+">"+d+i+"</"+u+">":(n+=f+">",d&&""!==i&&(d.includes("/>")||d.includes("</"))?n+=i+e.indentBy+d+i:n+=d,n+="</"+u+">"):n+=f+"/>",a=!0}else{var p=st(o[":@"],e),g="?xml"===u?"":i,c=o[u][0][e.textNodeName];n+=g+"<"+u+(c=0!==c.length?" "+c:"")+p+"?>",a=!0}else n+=i+"\x3c!--"+o[u][0][e.textNodeName]+"--\x3e",a=!0;else a&&(n+=i),n+="<![CDATA["+o[u][0][e.textNodeName]+"]]>",a=!1;else{var v=o[u];ot(l,e)||(v=ut(v=e.tagValueProcessor(u,v),e)),a&&(n+=i),n+=v,a=!1}}}return n}function at(t){for(var e=Object.keys(t),r=0;r<e.length;r++){var i=e[r];if(t.hasOwnProperty(i)&&":@"!==i)return i}}function st(t,e){var r="";if(t&&!e.ignoreAttributes)for(var i in t)if(t.hasOwnProperty(i)){var n=e.attributeValueProcessor(i,t[i]);!0===(n=ut(n,e))&&e.suppressBooleanAttributes?r+=" "+i.substr(e.attributeNamePrefix.length):r+=" "+i.substr(e.attributeNamePrefix.length)+'="'+n+'"'}return r}function ot(t,e){var r=(t=t.substr(0,t.length-e.textNodeName.length-1)).substr(t.lastIndexOf(".")+1);for(var i in e.stopNodes)if(e.stopNodes[i]===t||e.stopNodes[i]==="*."+r)return!0;return!1}function ut(t,e){if(t&&t.length>0&&e.processEntities)for(var r=0;r<e.entities.length;r++){var i=e.entities[r];t=t.replace(i.regex,i.val)}return t}var lt={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(t,e){return e},attributeValueProcessor:function(t,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function ht(t){this.options=Object.assign({},lt,t),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=F(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=pt),this.processTextOrObjNode=ft,this.options.format?(this.indentate=dt,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function ft(t,e,r,i){var n=this.j2x(t,r+1,i.concat(e));return void 0!==t[this.options.textNodeName]&&1===Object.keys(t).length?this.buildTextValNode(t[this.options.textNodeName],e,n.attrStr,r):this.buildObjectNode(n.val,e,n.attrStr,r)}function dt(t){return this.options.indentBy.repeat(t)}function pt(t){return!(!t.startsWith(this.options.attributeNamePrefix)||t===this.options.textNodeName)&&t.substr(this.attrPrefixLen)}ht.prototype.build=function(t){return this.options.preserveOrder?it(t,this.options):(Array.isArray(t)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&((e={})[this.options.arrayNodeName]=t,t=e),this.j2x(t,0,[]).val);var e},ht.prototype.j2x=function(t,e,r){var i="",n="",a=r.join(".");for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))if(void 0===t[s])this.isAttribute(s)&&(n+="");else if(null===t[s])this.isAttribute(s)||s===this.options.cdataPropName?n+="":"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if(t[s]instanceof Date)n+=this.buildTextValNode(t[s],s,"",e);else if("object"!=typeof t[s]){var o=this.isAttribute(s);if(o&&!this.ignoreAttributesFn(o,a))i+=this.buildAttrPairStr(o,""+t[s]);else if(!o)if(s===this.options.textNodeName){var u=this.options.tagValueProcessor(s,""+t[s]);n+=this.replaceEntitiesValue(u)}else n+=this.buildTextValNode(t[s],s,"",e)}else if(Array.isArray(t[s])){for(var l=t[s].length,h="",f="",d=0;d<l;d++){var p=t[s][d];if(void 0===p);else if(null===p)"?"===s[0]?n+=this.indentate(e)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(e)+"<"+s+"/"+this.tagEndChar;else if("object"==typeof p)if(this.options.oneListGroup){var g=this.j2x(p,e+1,r.concat(s));h+=g.val,this.options.attributesGroupName&&p.hasOwnProperty(this.options.attributesGroupName)&&(f+=g.attrStr)}else h+=this.processTextOrObjNode(p,s,e,r);else if(this.options.oneListGroup){var c=this.options.tagValueProcessor(s,p);h+=c=this.replaceEntitiesValue(c)}else h+=this.buildTextValNode(p,s,"",e)}this.options.oneListGroup&&(h=this.buildObjectNode(h,s,f,e)),n+=h}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName)for(var v=Object.keys(t[s]),m=v.length,x=0;x<m;x++)i+=this.buildAttrPairStr(v[x],""+t[s][v[x]]);else n+=this.processTextOrObjNode(t[s],s,e,r);return{attrStr:i,val:n}},ht.prototype.buildAttrPairStr=function(t,e){return e=this.options.attributeValueProcessor(t,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+t:" "+t+'="'+e+'"'},ht.prototype.buildObjectNode=function(t,e,r,i){if(""===t)return"?"===e[0]?this.indentate(i)+"<"+e+r+"?"+this.tagEndChar:this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar;var n="</"+e+this.tagEndChar,a="";return"?"===e[0]&&(a="?",n=""),!r&&""!==r||-1!==t.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===a.length?this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine:this.indentate(i)+"<"+e+r+a+this.tagEndChar+t+this.indentate(i)+n:this.indentate(i)+"<"+e+r+a+">"+t+n},ht.prototype.closeTag=function(t){var e="";return-1!==this.options.unpairedTags.indexOf(t)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":"></"+t,e},ht.prototype.buildTextValNode=function(t,e,r,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+"<![CDATA["+t+"]]>"+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+"\x3c!--"+t+"--\x3e"+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+r+"?"+this.tagEndChar;var n=this.options.tagValueProcessor(e,t);return""===(n=this.replaceEntitiesValue(n))?this.indentate(i)+"<"+e+r+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+r+">"+n+"</"+e+this.tagEndChar},ht.prototype.replaceEntitiesValue=function(t){if(t&&t.length>0&&this.options.processEntities)for(var e=0;e<this.options.entities.length;e++){var r=this.options.entities[e];t=t.replace(r.regex,r.val)}return t};var gt={validate:o};return e})()));
|
|
2
2
|
//# sourceMappingURL=fxp.min.js.map
|