The attached test code fails to parse the attached XML document in a reasonable timeframe:
failing.zip
The issue causing this appears to be a regular expression to split the XML on newlines, which either never returns, or is incredibly slow to return:
At: xmldom/lib/sax.js:69:
function position(p,m){
while(p>=lineEnd && (m = linePattern.exec(source))){
lineStart = m.index;
lineEnd = lineStart + m[0].length;
locator.lineNumber++;
//console.log('line++:',locator,startPos,endPos)
}
locator.columnNumber = p-lineStart+1;
}
var lineStart = 0;
var lineEnd = 0;
var linePattern = /.*(?:\r\n?|\n)|.*$/g
It appears that the solution would be to re-engineer the parser to process the XML in stream mode, not by splitting lines with a regular expression
The attached test code fails to parse the attached XML document in a reasonable timeframe:
failing.zip
The issue causing this appears to be a regular expression to split the XML on newlines, which either never returns, or is incredibly slow to return:
At: xmldom/lib/sax.js:69:
It appears that the solution would be to re-engineer the parser to process the XML in stream mode, not by splitting lines with a regular expression