List of usage examples for org.dom4j.tree AbstractElement remove
public boolean remove(Text text)
From source file:com.devoteam.srit.xmlloader.core.utils.XMLTree.java
License:Open Source License
/** * Replace nodes previously identified by the method compute() * accordingly to the XMLElementReplacer. * @throws java.lang.Exception//from ww w . j av a 2 s . c o m */ public void replace(XMLElementReplacer replacer, ParameterPool parameterPool) throws Exception { if (null == replacer) { throw new ExecutionException("XMLElementReplacer must not be null"); } for (Element e : elementsOrder) { List<Element> newNodesList = replacer.replace(e, parameterPool); if (newNodesList.isEmpty()) { Element element = new DefaultElement("removedElement"); newNodesList.add(element); } elementsMap.put(e, newNodesList); AbstractElement parent = (AbstractElement) e.getParent(); if (null != parent) { for (Element newChild : newNodesList) { DefaultElementInterface.insertNode((DefaultElement) parent, e, newChild); } e.detach(); parent.remove(e); if (1 == newNodesList.size() && e == root) { root = newNodesList.get(0); } } else if (1 == newNodesList.size()) { newNodesList.get(0); root = newNodesList.get(0); e.detach(); } else { // some error } } }