fast-xml-parser 5.3.2 → 5.3.3
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 +3 -0
- package/README.md +5 -4
- package/lib/fxp.cjs +1 -1
- 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 +4 -2
- package/src/xmlparser/OrderedObjParser.js +19 -8
|
@@ -140,7 +140,7 @@ function resolveNameSpace(tagname) {
|
|
|
140
140
|
//const attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm");
|
|
141
141
|
const attrsRegx = new RegExp('([^\\s=]+)\\s*(=\\s*([\'"])([\\s\\S]*?)\\3)?', 'gm');
|
|
142
142
|
|
|
143
|
-
function buildAttributesMap(attrStr, jPath
|
|
143
|
+
function buildAttributesMap(attrStr, jPath) {
|
|
144
144
|
if (this.options.ignoreAttributes !== true && typeof attrStr === 'string') {
|
|
145
145
|
// attrStr = attrStr.replace(/\r?\n/g, ' ');
|
|
146
146
|
//attrStr = attrStr || attrStr.trim();
|
|
@@ -252,14 +252,14 @@ const parseXml = function(xmlData) {
|
|
|
252
252
|
|
|
253
253
|
textData = this.saveTextToParentTag(textData, currentNode, jPath);
|
|
254
254
|
if( (this.options.ignoreDeclaration && tagData.tagName === "?xml") || this.options.ignorePiTags){
|
|
255
|
-
|
|
255
|
+
//do nothing
|
|
256
256
|
}else{
|
|
257
257
|
|
|
258
258
|
const childNode = new xmlNode(tagData.tagName);
|
|
259
259
|
childNode.add(this.options.textNodeName, "");
|
|
260
260
|
|
|
261
261
|
if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){
|
|
262
|
-
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath
|
|
262
|
+
childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
|
|
263
263
|
}
|
|
264
264
|
this.addChild(currentNode, childNode, jPath, i);
|
|
265
265
|
}
|
|
@@ -306,7 +306,12 @@ const parseXml = function(xmlData) {
|
|
|
306
306
|
let closeIndex = result.closeIndex;
|
|
307
307
|
|
|
308
308
|
if (this.options.transformTagName) {
|
|
309
|
-
|
|
309
|
+
//console.log(tagExp, tagName)
|
|
310
|
+
const newTagName = this.options.transformTagName(tagName);
|
|
311
|
+
if(tagExp === tagName) {
|
|
312
|
+
tagExp = newTagName
|
|
313
|
+
}
|
|
314
|
+
tagName = newTagName;
|
|
310
315
|
}
|
|
311
316
|
|
|
312
317
|
//save text as child node
|
|
@@ -357,7 +362,8 @@ const parseXml = function(xmlData) {
|
|
|
357
362
|
const childNode = new xmlNode(tagName);
|
|
358
363
|
|
|
359
364
|
if(tagName !== tagExp && attrExpPresent){
|
|
360
|
-
childNode[":@"] = this.buildAttributesMap(tagExp, jPath
|
|
365
|
+
childNode[":@"] = this.buildAttributesMap(tagExp, jPath
|
|
366
|
+
);
|
|
361
367
|
}
|
|
362
368
|
if(tagContent) {
|
|
363
369
|
tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
|
|
@@ -379,12 +385,16 @@ const parseXml = function(xmlData) {
|
|
|
379
385
|
}
|
|
380
386
|
|
|
381
387
|
if(this.options.transformTagName) {
|
|
382
|
-
|
|
388
|
+
const newTagName = this.options.transformTagName(tagName);
|
|
389
|
+
if(tagExp === tagName) {
|
|
390
|
+
tagExp = newTagName
|
|
391
|
+
}
|
|
392
|
+
tagName = newTagName;
|
|
383
393
|
}
|
|
384
394
|
|
|
385
395
|
const childNode = new xmlNode(tagName);
|
|
386
396
|
if(tagName !== tagExp && attrExpPresent){
|
|
387
|
-
childNode[":@"] = this.buildAttributesMap(tagExp, jPath
|
|
397
|
+
childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
|
|
388
398
|
}
|
|
389
399
|
this.addChild(currentNode, childNode, jPath, startIndex);
|
|
390
400
|
jPath = jPath.substr(0, jPath.lastIndexOf("."));
|
|
@@ -395,7 +405,7 @@ const parseXml = function(xmlData) {
|
|
|
395
405
|
this.tagsNodeStack.push(currentNode);
|
|
396
406
|
|
|
397
407
|
if(tagName !== tagExp && attrExpPresent){
|
|
398
|
-
childNode[":@"] = this.buildAttributesMap(tagExp, jPath
|
|
408
|
+
childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
|
|
399
409
|
}
|
|
400
410
|
this.addChild(currentNode, childNode, jPath, startIndex);
|
|
401
411
|
currentNode = childNode;
|
|
@@ -416,6 +426,7 @@ function addChild(currentNode, childNode, jPath, startIndex){
|
|
|
416
426
|
if (!this.options.captureMetaData) startIndex = undefined;
|
|
417
427
|
const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"])
|
|
418
428
|
if(result === false){
|
|
429
|
+
//do nothing
|
|
419
430
|
} else if(typeof result === "string"){
|
|
420
431
|
childNode.tagname = result
|
|
421
432
|
currentNode.addChild(childNode, startIndex);
|