-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FT Variable Substitution - Parser changed from ltx to xmldom (#11401)
Parser changed from ltx to xmldom
- Loading branch information
1 parent
f81941e
commit b4692e1
Showing
17 changed files
with
227 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
var varUtility = require("./variableutility.js"); | ||
var DOMParser = require('xmldom').DOMParser; | ||
|
||
export class NpmDomUtility { | ||
|
||
private xmlDomLookUpTable = {}; | ||
private xmlDom; | ||
|
||
public constructor(xmlContent) { | ||
this.xmlDomLookUpTable = {}; | ||
this.xmlDom = new DOMParser().parseFromString(xmlContent,"text/xml"); | ||
this.buildLookUpTable(this.xmlDom); | ||
} | ||
|
||
public getXmlDom() { | ||
return this.xmlDom; | ||
} | ||
|
||
public getContentWithHeader(xmlDom) { | ||
return xmlDom ? xmlDom.toString() : ""; | ||
} | ||
|
||
/** | ||
* Define method to create a lookup for DOM | ||
*/ | ||
private buildLookUpTable(node) { | ||
if(node){ | ||
let nodeName = node.nodeName; | ||
if(nodeName){ | ||
nodeName = nodeName.toLowerCase(); | ||
let listOfNodes = this.xmlDomLookUpTable[nodeName]; | ||
if(listOfNodes == null || !(Array.isArray(listOfNodes))) { | ||
this.xmlDomLookUpTable[nodeName] = []; | ||
} | ||
(this.xmlDomLookUpTable[nodeName]).push(node); | ||
if(node.hasChildNodes()) { | ||
let children = node.childNodes; | ||
for(let i=0 ; i < children.length; i++) { | ||
this.buildLookUpTable(children[i]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Returns array of nodes which match with the tag name. | ||
*/ | ||
public getElementsByTagName(nodeName) { | ||
if(varUtility.isEmpty(nodeName)) | ||
return []; | ||
let selectedElements = this.xmlDomLookUpTable[nodeName.toLowerCase()]; | ||
if(!selectedElements){ | ||
selectedElements = []; | ||
} | ||
return selectedElements; | ||
} | ||
|
||
/** | ||
* Search in subtree with provided node name | ||
*/ | ||
public getChildElementsByTagName(node, tagName) { | ||
if(!varUtility.isObject(node) ) | ||
return []; | ||
var liveNodes = []; | ||
if(node.hasChildNodes()){ | ||
var children = node.childNodes; | ||
for(let i=0; i < children.length; i++ ){ | ||
let childName = children[i].nodeName; | ||
if( !varUtility.isEmpty(childName) && tagName == childName){ | ||
liveNodes.push(children[i]); | ||
} | ||
let liveChildNodes = this.getChildElementsByTagName(children[i], tagName); | ||
if(liveChildNodes && liveChildNodes.length > 0){ | ||
liveNodes = liveNodes.concat(liveChildNodes); | ||
} | ||
} | ||
} | ||
return liveNodes; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
219 changes: 125 additions & 94 deletions
219
Tasks/Common/webdeployment-common-v2/xmlvariablesubstitutionutility.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters