domDiff.js
/**
 * Compares two XML DOM nodes and returns the delta between them
 * relatedXpathsToCompare - In some cases there are other XML elements that are not within the node but are related to it. This list represents relative paths for the each node in existNodes, modNodes
 * @returns uniqueExistNodes - Nodes from existNodes that were not found in modNodes
 *			uniqueModNodes - Nodes from modNodes that were not found in existNodes
 *			differenceCount - summative count of number of nodes in uniqueExistNodes and uniqueModNodes
 */
Compares two XML DOM nodes and returns the delta between them
relatedXpathsToCompare - In some cases there are other XML elements that are not within the node but are related to it. This list represents relative paths for the each node in existNodes, modNodes
@returns uniqueExistNodes - Nodes from existNodes that were not found in modNodes
uniqueModNodes - Nodes from modNodes that were not found in existNodes
differenceCount - summative count of number of nodes in uniqueExistNodes and uniqueModNodes
Compares two XML DOM nodes and returns the delta between them relatedXpathsToCompare - In some cases there are other XML elements that are not within the node but are related to it . This list represents relative paths for the each node in existNodes modNodes @returns uniqueExistNodes - Nodes from existNodes that were not found in modNodes uniqueModNodes - Nodes from modNodes that were not found in existNodes differenceCount - summative count of number of nodes in uniqueExistNodes and uniqueModNodes
function compareNodes(existNodes, modNodes, relatedXpathsToCompare)
{
	for(let i = existNodes.length-1; i >= 0; i--) 
	{
		for(let j = modNodes.length-1; j >= 0; j--)
		{
			let mainResult = compare(existNodes[i], modNodes[j]);
			let isSame = mainResult.getResult();
			if(relatedXpathsToCompare && relatedXpathsToCompare.length > 0)
			{ 
				for(let k = 0; k < relatedXpathsToCompare.length; k++)
				{
					let nodeDiff = compare(xpath.select1(relatedXpathsToCompare[k], existNodes[i]), xpath.select1(relatedXpathsToCompare[k], modNodes[j]));
					isSame = isSame && nodeDiff.getResult(); 
				}
			}
			if(isSame)
			{ 
				existNodes.splice(i, 1); 
				modNodes.splice(j, 1);
				break; 
			}
		}
	}
	return {"uniqueExistNodes": existNodes, "uniqueModNodes": modNodes, "differenceCount": (existNodes.length + modNodes.length)};
}
function compareNodes ( existNodes , modNodes , relatedXpathsToCompare ) { for ( let i = existNodes . length - 1 ; i >= 0 ; i -- ) { for ( let j = modNodes . length - 1 ; j >= 0 ; j -- ) { let mainResult = compare ( existNodes [ i ] , modNodes [ j ] ) ; let isSame = mainResult . getResult ( ) ; if ( relatedXpathsToCompare && relatedXpathsToCompare . length > 0 ) { for ( let k = 0 ; k < relatedXpathsToCompare . length ; k ++ ) { let nodeDiff = compare ( xpath . select1 ( relatedXpathsToCompare [ k ] , existNodes [ i ] ) , xpath . select1 ( relatedXpathsToCompare [ k ] , modNodes [ j ] ) ) ; isSame = isSame && nodeDiff . getResult ( ) ; } } if ( isSame ) { existNodes . splice ( i , 1 ) ; modNodes . splice ( j , 1 ) ; break ; } } } return { "uniqueExistNodes" : existNodes , "uniqueModNodes" : modNodes , "differenceCount" : ( existNodes . length + modNodes . length ) } ; }
Compares two XML DOM nodes and returns the delta between them
 relatedXpathsToCompare - In some cases there are other XML elements that are not within the node but are related to it.
Compares two XML DOM nodes and returns the delta between them relatedXpathsToCompare - In some cases there are other XML elements that are not within the node but are related to it .
//starting from the end of the list because code below will remove entries from array //log.debug(message: `Examining existNodes ${i} and modNodes ${j}. existNodes.length is ${existNodes.length} and modNodes.length is ${modNodes.length}`); //Check all related paths if they exist //ANDing the results will cause a single not equal element to set the whole thing to false //if(mainResult.getResult()) //they were the same //delete this entry since it has a match // no need to continue in the loop