private string mapExternPathToInternPathWithIndex(string source, string destination)
{
string destinationPathWithIndex = "";
// load the xpath from source node
// x[1]\y[2]\f[1]
// X[1]\XType[2]\Y[1]\yType[4]\F[1]\FType[2]\
string[] sourceSplitWidthIndex = source.Split('/');
// f[1]\y[2]\x[1]
Array.Reverse(sourceSplitWidthIndex);
string[] destinationSplit = destination.Split('/');
// XFType\F\yType\Y\XType\x
Array.Reverse(destinationSplit);
int j =0;
for (int i = 0; i < sourceSplitWidthIndex.Length; i++)
{
string tmp = sourceSplitWidthIndex[i];
if (tmp.Contains("["))
{
string tmpIndex = tmp.Split('[')[1];
string index = tmpIndex.Remove(tmpIndex.IndexOf(']'));
//set to destination array
//set j
if (i == 0) j = 0;
else if(i == 1) j = i + 1;
else j = i * 2;
if (destinationSplit.Length > j+1)
{
string destinationTemp = destinationSplit[j];
destinationSplit[j] = destinationTemp + "[" + index + "]";
//set parent
string destinationTempParent = destinationSplit[j+1];
destinationSplit[j+1] = destinationTempParent + "[" + 1 + "]";
}
}
}
Array.Reverse(destinationSplit);
// XFType[2]\F[1]\yType[4]\Y[1]\XType[2]\x[1]
return String.Join("/", destinationSplit); ;
}