*/
private int compareAttributes(final Element node1, final Element node2) {
int diffCount = 0;
for (Iterator i = node1.getAttributeIterator(); i.hasNext(); ) {
Attribute attr1 = (Attribute) i.next();
// Does node2 have this attribute at all?
String attValue2 = node2.getAttribute(attr1.getNamespaceURI(), attr1.getLocalName());
if (attValue2 == null) {
// Is this an attribute that is allowed to be missing sometimes?
if (missingattributeIsIgnorable(attr1)) {
continue;
}
// If not, complain
printElementChangeBlock(node1, node2, "Attribute '"
+ attr1.getNodeLocation()
+ "' does not exist in the second document.");
diffCount++;
continue;
}
// If it does, does it have the same value?
String attValue1 = attr1.getStringValue();
if (!compareTextLikeQName(node1, node2, attValue1, attValue2)) {
printElementChangeBlock(node1, node2, "Attribute '"
+ attr1.getNodeLocation()
+ "' values are different.");
diffCount++;
}
}
// Look for attributes on node 2 that are not on node 1
for (Iterator i = node2.getAttributeIterator(); i.hasNext(); ) {
Attribute attr2 = (Attribute) i.next();
if (node1.getAttribute(attr2.getNamespaceURI(), attr2.getLocalName()) == null) {
// Is this an attribute that is allowed to be missing sometimes?
if (missingattributeIsIgnorable(attr2)) {
continue;
}
// If not, complain
printElementChangeBlock(node1, node2, "Attribute '"
+ attr2.getNodeLocation()
+ "' does not exist in the first document.");
diffCount++;
}
}