if (!file.exists())
// XXX not sure if this case should return true or false...
return true;
try {
final XmlParser xmlParser = xmlParserFactory.newXmlParser(file);
final XPath xPath = xPathFactory.newXPath();
final Map<XPathExpression, Collection<Node>> insertedNodes = getElementsToInsert(xPath, xmlParser);
final Map<XPathExpression, Node> replacedNodes = getRemovalMap(xPath, xmlParser);
for (final Entry<XPathExpression, Collection<Node>> entry : insertedNodes.entrySet()) {
if (xmlParser.hasNode(entry.getKey())) {
for (final Node inserted : entry.getValue()) {
xmlParser.removeChildNode(entry.getKey(), inserted);
}
}
}
for (final Entry<XPathExpression, Node> entry : replacedNodes.entrySet()) {
if (xmlParser.hasNode(entry.getKey())) {
xmlParser.replaceNode(entry.getKey(), entry.getValue());
}
}
xmlParser.close();
}
catch (Exception e) {
error("Error occurred while attempting to verify xml resource " + file.getAbsolutePath(), e);
return false;
}