private Node resolve(XmlUtils xml, String xpath) throws Exception { Node parent = xml.getSingleNode(xpath); if (parent == null) { log.trace("Failed to resolve " + xpath + ", creating node"); try { // This can be quite an obscure stack trace. parent = xml.createNode(xpath); } catch (Exception e) { throw new Exception("Failed to create node [" + xpath + "]", e); } } return parent; }