本文整理了Java中org.dom4j.Node.detach()
方法的一些代码示例,展示了Node.detach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.detach()
方法的具体详情如下:
包路径:org.dom4j.Node
类名称:Node
方法名:detach
[英]Removes this node from its parent if there is one. If this node is the root element of a document then it is removed from the document as well.
This method is useful if you want to remove a node from its source document and add it to another document. For exampleNode node = ...; Element someOtherElement = ...; someOtherElement.add( node.detach() );
[中]如果存在父节点,则将其从父节点中移除。如果此节点是文档的根元素,则它也将从文档中删除。
如果要从源文档中删除节点并将其添加到另一个文档中,此方法非常有用。例如Node node = ...; Element someOtherElement = ...; someOtherElement.add( node.detach() );
代码示例来源:origin: igniterealtime/Openfire
((Node) iter.next()).detach();
代码示例来源:origin: jenkinsci/jenkins
root.addText(o.toString());
} else {
root.add(((org.dom4j.Node)o).detach());
代码示例来源:origin: alibaba/PelicanDT
@Override
public void deleteNode(Node node) {
if (null == node) {
log.warn("The node to be deleted is null, operation skip!");
} else {
node.detach();
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory)
throws HibernateException {
if ( !isEmbeddedInXML ) {
node.detach();
}
else {
replaceNode( node, (Element) value );
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory)
throws HibernateException {
if ( !isEmbeddedInXML ) {
node.detach();
}
else {
replaceNode( node, (Element) value );
}
}
代码示例来源:origin: hibernate/hibernate
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory)
throws HibernateException {
if ( !isEmbeddedInXML ) {
node.detach();
}
else {
replaceNode( node, (Element) value );
}
}
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory)
throws HibernateException {
if ( !isEmbeddedInXML ) {
node.detach();
}
else {
replaceNode( node, (Element) value );
}
}
代码示例来源:origin: stackoverflow.com
Node node = ...;
Element someOtherElement = ...;
someOtherElement.add( node.detach() );
代码示例来源:origin: stackoverflow.com
@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();
}
代码示例来源:origin: com.societegenerale.ci-droid/extensions
@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);
}
代码示例来源:origin: org.igniterealtime.openfire/xmppserver
((Node) iter.next()).detach();
代码示例来源:origin: hibernate/hibernate
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);
}
}
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
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);
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
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);
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
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);
}
}
代码示例来源:origin: org.opencms/opencms-core
if (!(node instanceof Element)) {
node.detach();
} else {
代码示例来源:origin: com.atlassian.bamboo.plugins.dotnet/atlassian-bamboo-plugin-dotnet
StreamSource source = new StreamSource(inputStream);
Document newDocument = DocumentFactory.getInstance().createDocument();
newDocument.add(run.detach());
try
代码示例来源:origin: org.cogchar/org.cogchar.lib.convoid
ArrayList<Node> nodesCopy = new ArrayList<Node>(nodes);
for (Node n : nodesCopy) {
n.detach();
System.out.println("Copying node: " + n);
stepElement.add(n);
代码示例来源:origin: org.alfresco.surf/spring-surf
/**
* <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;
}
代码示例来源:origin: org.springframework.extensions.surf/spring-surf
/**
* <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;
}
内容来源于网络,如有侵权,请联系作者删除!