I want to modify the DifferenceListener in XMLUnit to ignore the attribute id while comparing XML files. I have tried to do it using the following.
import org.custommonkey.xmlunit.DifferenceListener;
import org.custommonkey.xmlunit.Difference;
import org.custommonkey.xmlunit.DifferenceConstants;
public class ignoreIDs implements DifferenceListener {
private static final int[] IGNORE_VALUES = new int[] {
DifferenceConstants.ATTR_VALUE.getId(),
};
private boolean isIgnoredDifference(Difference diff) {
int DiffId = diff.getId();
for (int value: IGNORE_VALUES) {
if (DiffId == value) return true;
}
return false;
}
public int differenceFound(Difference difference) {
if (isIgnoredDifference(difference)) return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
else return RETURN_ACCEPT_DIFFERENCE;
}
public void skippedComparison() {
}
}
But I am unable to understand how to enter only the id attribute in the IGNORE_VALUES array. Please help me out.