((Node) iter.next()).detach();
root.addText(o.toString()); } else { root.add(((org.dom4j.Node)o).detach());
@Override public void deleteNode(Node node) { if (null == node) { log.warn("The node to be deleted is null, operation skip!"); } else { node.detach(); } }
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { if ( !isEmbeddedInXML ) { node.detach(); } else { replaceNode( node, (Element) value ); } }
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { if ( !isEmbeddedInXML ) { node.detach(); } else { replaceNode( node, (Element) value ); } }
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { if ( !isEmbeddedInXML ) { node.detach(); } else { replaceNode( node, (Element) value ); } }
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { if ( !isEmbeddedInXML ) { node.detach(); } else { replaceNode( node, (Element) value ); } }
Node node = ...; Element someOtherElement = ...; someOtherElement.add( node.detach() );
@Test public void dom4j() throws DocumentException, IOException { String absolutePath = Paths.get(PATH_TO_XML).toAbsolutePath().toString(); SAXReader reader = new SAXReader(); Document document = reader.read(absolutePath); Node node = document.selectSingleNode(XPATH_TO_NODE); node.detach(); XMLWriter writer = new XMLWriter(new FileWriter(absolutePath), OutputFormat.createPrettyPrint()); writer.write(document); writer.close(); }
@Override public String provideContent(String documentToProcess, ResourceToUpdate resourceToUpdate) throws IssueProvidingContentException { Document originalDocument = parseStringIntoDocument(documentToProcess); List<Node> elementUnderXpathWeLookFor = originalDocument.selectNodes(xpathElementToRemove); if (elementUnderXpathWeLookFor.isEmpty()) { log.info(xpathElementToRemove + " didn't match any element - not removing any element"); return documentToProcess; } elementUnderXpathWeLookFor.stream().forEach(e -> e.detach()); return prettyPrint(originalDocument); }
((Node) iter.next()).detach();
protected static void replaceNode(Node container, Element value) { if ( container!=value ) { //not really necessary, I guess... Element parent = container.getParent(); container.detach(); value.setName( container.getName() ); value.detach(); parent.add(value); } }
protected static void replaceNode(Node container, Element value) { if ( container!=value ) { //not really necessary, I guess... Element parent = container.getParent(); container.detach(); value.setName( container.getName() ); value.detach(); parent.add(value); } }
protected static void replaceNode(Node container, Element value) { if ( container!=value ) { //not really necessary, I guess... Element parent = container.getParent(); container.detach(); value.setName( container.getName() ); value.detach(); parent.add(value); } }
protected static void replaceNode(Node container, Element value) { if ( container!=value ) { //not really necessary, I guess... Element parent = container.getParent(); container.detach(); value.setName( container.getName() ); value.detach(); parent.add(value); } }
if (!(node instanceof Element)) { node.detach(); } else {
StreamSource source = new StreamSource(inputStream); Document newDocument = DocumentFactory.getInstance().createDocument(); newDocument.add(run.detach()); try
ArrayList<Node> nodesCopy = new ArrayList<Node>(nodes); for (Node n : nodesCopy) { n.detach(); System.out.println("Copying node: " + n); stepElement.add(n);
/** * <p>Deleting an {@link ExtensionModule} is a two stage process. First it is necessary to locate the * {@link ExtensionModule} in the {@link List} and then remove it if it is present. Secondly it is necessary * to update the {@link Document} maintained by the {@link ExtensionImpl}.</p> * * @param moduleId String * @return ExtensionModule */ public ExtensionModule deleteExtensionModule(String moduleId) { ExtensionModule targetModule = null; Document extensionDocument = getDocument(); ModuleObjectAndNode moan = findModule(moduleId, extensionDocument); if (moan != null) { if (moan.getObject() != null) { getExtensionModules().remove(moan.getObject()); targetModule = moan.getObject(); } if (moan.getNode() != null) { moan.getNode().detach(); this.updateXML(extensionDocument); } } return targetModule; }
/** * <p>Deleting an {@link ExtensionModule} is a two stage process. First it is necessary to locate the * {@link ExtensionModule} in the {@link List} and then remove it if it is present. Secondly it is necessary * to update the {@link Document} maintained by the {@link ExtensionImpl}.</p> * * @param moduleId String * @return ExtensionModule */ public ExtensionModule deleteExtensionModule(String moduleId) { ExtensionModule targetModule = null; Document extensionDocument = getDocument(); ModuleObjectAndNode moan = findModule(moduleId, extensionDocument); if (moan != null) { if (moan.getObject() != null) { getExtensionModules().remove(moan.getObject()); targetModule = moan.getObject(); } if (moan.getNode() != null) { moan.getNode().detach(); this.updateXML(extensionDocument); } } return targetModule; }