private boolean appendPath(Element from, Parent to, String appendPath) { Element append = to.getChild(appendPath); if (append == null) { throw new IllegalStateException("Cannot append " + name + " to path " + appendPath); } append.addNode(cleanup(from.copy())); return true; }
private boolean replacePath(Element from, Parent to, String replacePath) { Element replace = to.getChild(replacePath); if (replace == null) { // if nothing to replace, then append it to parent int lastSlash = replacePath.lastIndexOf('/'); if (lastSlash == -1) { throw new IllegalStateException("Cannot replace path " + replacePath + " with " + name); } Parent p = to.getChild(replacePath.substring(0, lastSlash)); if (p == null) { throw new IllegalStateException("Cannot append/replace path " + replacePath + " with " + name); } p.addNode(cleanup(from.copy())); } else { replace(replace, cleanup(from.copy())); } return true; }
private void processElem(Element from, Parent to) { String merge = from.getAttributeValue("merge"); if ("replace".equals(merge)) { // find first element by the same name and merge into that one Element other = to.getChild(from.getName()); if (other != null) { replace(other, cleanup(from.copy())); return; } } else if (Boolean.parseBoolean(merge)) { // find first element by the same name and merge into that one Element other = to.getChild(from.getName()); if (other != null) { merge(from, other); return; } } to.addNode(cleanup(from.copy())); }