当前位置: 首页>>代码示例>>Java>>正文


Java Node.removeChild方法代码示例

本文整理汇总了Java中org.w3c.dom.Node.removeChild方法的典型用法代码示例。如果您正苦于以下问题:Java Node.removeChild方法的具体用法?Java Node.removeChild怎么用?Java Node.removeChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Node的用法示例。


在下文中一共展示了Node.removeChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mergeChildNodes

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Merge child nodes
 * 
 * @param node     current node base
 * @param childNode child node if exist
 * @param foundBean child bean
 * @param currentChild current child node
 * @param patternChild current pattern child
 * @param nodeMap node map
 * @param document document
 * @param patternBean pattern bean
 * @param children list relevant childs current node base
 */
private static void mergeChildNodes(Node node, Node childNode, BaseBean foundBean,
        Node currentChild, Node patternChild, Map nodeMap, Document document,
        BaseBean patternBean, List children) {
    Node foundChild = childNode;
    if (foundChild == null) {
        foundChild = takeEqualNode(children, patternChild);
    }
    if (foundChild != null) {
        if (foundChild != currentChild) {
            node.removeChild(foundChild);
            node.insertBefore(foundChild, currentChild);
        }
        if (foundBean != null) {
            mergeBeans(nodeMap, foundBean, patternBean);
        } else if (isRelevantNode(foundChild) && foundChild.hasChildNodes()) {
            mergeNode(nodeMap, foundChild, patternChild);
        } else {
            foundChild.setNodeValue(patternChild.getNodeValue());
        }
    } else {
        Node child = document.importNode(patternChild, true);
        node.insertBefore(child, currentChild);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:Schema2BeansUtil.java

示例2: processSecurityElem

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void processSecurityElem(Document docDom, Node parent) {
    NodeList childNodes = parent.getChildNodes();
    int len = childNodes.getLength();
    for (int i = 0; i < len; i++) {
        Node node = childNodes.item(i);
        if (node != null && node.getNodeType() == Node.COMMENT_NODE) { // node might be null (don't know why)
            if (node.getNodeValue().equals(DEFAULT_JNLP_SECURITY)) {
                String securityProp = getProperty("jnlp.signed", null); //NOI18N // property in project.properties
                if (securityProp != null && securityProp.equalsIgnoreCase("true")) { //NOI18N
                    parent.replaceChild(createSecurityElement(docDom), node);
                } else {
                    parent.removeChild(node);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:GenerateJnlpFileTask.java

示例3: removeNoOps

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static void removeNoOps(Node program)
{
	NodeList statements = program.getChildNodes();
	for (int i = 0; i < statements.getLength(); i++)
	{
		Node statement = statements.item(i);
		int oldLength = statements.getLength();
		if (statement.getNodeName().equals("op"))
		    removeNoOpsFromOp(program,statement);
		else if (statement.getNodeName().equals("value"))
			program.removeChild(statement);
		if (oldLength > statements.getLength()){
			i = -1;
		}
	}
}
 
开发者ID:Christopher-Chianelli,项目名称:ccpa,代码行数:17,代码来源:TreeOptimizer.java

示例4: removeContents

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void removeContents() {
    Node currentChild = getFirstChild();

    while (currentChild != null) {
        Node temp = currentChild.getNextSibling();
        if (currentChild instanceof javax.xml.soap.Node) {
            ((javax.xml.soap.Node) currentChild).detachNode();
        } else {
            Node parent = currentChild.getParentNode();
            if (parent != null) {
                parent.removeChild(currentChild);
            }

        }
        currentChild = temp;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ElementImpl.java

示例5: removeUnusedVariables

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static void removeUnusedVariables(Node program)
{
	NodeList statements = program.getChildNodes();
	for (int i = 0; i < statements.getLength(); i++)
	{
		Node statement = statements.item(i);
		if (statement.getNodeName().equals("uses"))
		{
		    if (variableNotUsed(program,statement.getChildNodes().item(1)))
		    {
		    	program.removeChild(statement);
		    	i = -1;
		    }
		}
		else if (statement.getNodeName().equals("op"))
		{
			removeUnusedVariables(statement);
		}
	}
}
 
开发者ID:Christopher-Chianelli,项目名称:ccpa,代码行数:21,代码来源:TreeOptimizer.java

示例6: removeContents

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public void removeContents() {
    Node currentChild = getFirstChild();

    while (currentChild != null) {
        Node temp = currentChild.getNextSibling();
        if (currentChild instanceof javax.xml.soap.Node) {
            ((javax.xml.soap.Node) currentChild).detachNode();
        } else {
            Node parent = currentChild.getParentNode();
            if (parent != null) {
                parent.removeChild(currentChild);
            }

        }
        currentChild = temp;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ElementImpl.java

示例7: testVerifyFalseModfiedSig

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Test
public void testVerifyFalseModfiedSig() throws Exception {
    RedactableXMLSignature sig = RedactableXMLSignature.getInstance(algorithm);
    sig.initSign(keyPair);
    sig.setDocument(new FileInputStream("testdata/vehicles.xml"));
    sig.addSignSelector("#xpointer(id('a1'))", true);
    sig.addSignSelector("#xpointer(id('a2'))", true);
    sig.addSignSelector("#xpointer(id('a3'))", true);
    Document document = sig.sign();
    printDocument(document);

    Node proof = document.getElementsByTagName("Proof").item(0);
    proof.removeChild(proof.getFirstChild());

    sig.initVerify(keyPair.getPublic());
    sig.setDocument(document);
    try {
        assertFalse(sig.verify());
    } catch (Exception e) {
        assertTrue(true);
    }
    validateXSD(document);
}
 
开发者ID:woefe,项目名称:xmlrss,代码行数:24,代码来源:AbstractXMLRSSTest.java

示例8: removeAllChildren

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Removes all children nodes from the specified node.
 *
 * @param node the parent node whose children are to be removed
 */
public static void removeAllChildren(Node node) {
    NodeList children = node.getChildNodes();
    for (int i = 0, length = children.getLength(); i < length; i++) {
        node.removeChild(children.item(i));
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:DOMUtils.java

示例9: mergeNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Merge "unsupported" attributes and child elements of node
 *
 * @param nodeMap
 * @param node
 * @param patternNode
 */
private static void mergeNode(Map nodeMap, Node node, Node patternNode) {
    mergeAttributes(node, patternNode);
    NodeList childNodes = node.getChildNodes();
    List children = relevantNodes(childNodes);
    Document document = getOwnerDocument(node);
    for (int i = childNodes.getLength() - 1; i >= 0; i--) {//remove all comments and break lines from current document node
        Node childNode = childNodes.item(i);
        if (!isRelevantNode(childNode)) {
            node.removeChild(childNode);
        }
    }
    NodeList patternChildNodes = patternNode.getChildNodes();
    for (int i = 0; i < patternChildNodes.getLength(); i++) {
        Node patternChild = patternChildNodes.item(i);
        Node currentChild = childNodes.item(i);
        if (isRelevantNode(patternChild)) {
            BaseBean patternBean = (BaseBean) nodeMap.get(patternChild);
            BaseBean foundBean;
            Node foundChild;
            if (patternBean != null) {
                foundBean = takeEqualBean(nodeMap, children, patternBean);
                foundChild = foundBean == null ? null : foundBean.binding.getNode();
            } else {
                foundBean = null;
                foundChild = null;
            }
            mergeChildNodes(node, foundChild, foundBean, currentChild, patternChild, nodeMap, document, patternBean, children);
        } else {
            mergeChildNodes(node, null, null, currentChild, patternChild, nodeMap, document, null, children);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:Schema2BeansUtil.java

示例10: removeExpressionNodes

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void removeExpressionNodes(Node parent) {
	for (int i = 0; i < parent.getChildNodes().getLength(); i++) {
		if (parent.getChildNodes().item(i).getNodeName().equals(INCLUDE_EXTERNAL_EXPRESSION) || parent.getChildNodes().item(i).getNodeName().equals(EXPRESSION)) {
			parent.removeChild(parent.getChildNodes().item(i));
		}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:8,代码来源:ParseExternalElements.java

示例11: storeFileLocator

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void storeFileLocator (LinkedList<String> storedFileLocators, String iniFile ){
	Document doc= getXmlDocument(iniFile);
//	doc.getElementsByTagName(arg0)
	//System.out.println(storedFileLocators);
	Node fileLocatorNode = getElementByTagName (doc,"DEFINITIONFILELOCATORS");
	boolean tagUpdated=false;
	for (String fileLocator: storedFileLocators){//check if the file locator list contains file locator which are not stored in the ini setting 
	boolean fileLocatorIsStored=false; 
		for (int t = 0; t<fileLocatorNode.getChildNodes().getLength(); t++){
			 	if ( fileLocator.equals(fileLocatorNode.getChildNodes().item(t).getTextContent()) )
			 		fileLocatorIsStored=true;  
			 }
		if (!fileLocatorIsStored) {
			for (int tt = 0; tt<fileLocatorNode.getChildNodes().getLength(); tt++){
			 	if (fileLocatorNode.getChildNodes().item(tt).getNodeType()==1 ) 
			 		doc.renameNode( fileLocatorNode.getChildNodes().item(tt)
			 				,null,
			 				"FileLocator"+String.valueOf(Integer.valueOf(fileLocatorNode.getChildNodes().item(tt).getNodeName().substring(11))+1)  ); 
			 }
			Stack<Node> nodeStapel = new Stack<Node>(); 
			int childrenCount = fileLocatorNode.getChildNodes().getLength();
			for (int ttt = 0; ttt<childrenCount; ttt++){
			if (fileLocatorNode.getChildNodes().item( fileLocatorNode.getChildNodes().getLength()-1 ).getNodeType() == 1)//
				nodeStapel.push(fileLocatorNode.getChildNodes().item( fileLocatorNode.getChildNodes().getLength()-1 ));//Immer wird der Letzte genommen und auf dem Stack gesetzt, damit wird das letzte Kind auch das Letze in der neuen Reihe sein 
			fileLocatorNode.removeChild(fileLocatorNode.getChildNodes().item( fileLocatorNode.getChildNodes().getLength()-1 )); 
			//wird ein Kind removed und er hintel�sst danach eine Index-L�cke, wird die Kinder-Indexierung neu vergeben und das alte Kind 1 wird Kind 0  
			}
			Element neuesElement = doc.createElement("FileLocator0");
			neuesElement.appendChild(doc.createTextNode(fileLocator)  );
//			fileLocatorNode.appendChild(neuesElement);
			nodeStapel.push( neuesElement );//das neueste Element wird der erste FileLocator-tag sein  
			tagUpdated=true;
			childrenCount=1;
			while (!nodeStapel.isEmpty()&&childrenCount<=10){
				fileLocatorNode.appendChild(nodeStapel.pop());
				childrenCount++;
			}				
			//showMeTheDoc(fileLocatorNode, 0);
		}
	}
if (tagUpdated){
storeXmlDocToFile(iniFile, doc); 	  
 }
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:45,代码来源:QueryDefinitionParser.java

示例12: migrateBillingResultXml

import org.w3c.dom.Node; //导入方法依赖的package包/类
protected String migrateBillingResultXml(String billingXml)
        throws Exception {
    Document document = XMLConverter.convertToDocument(billingXml, false);
    NodeList subscriptionCosts = findSubscriptionCost(document);
    for (int i = 0; i < subscriptionCosts.getLength(); i++) {
        Node subscriptionCost = subscriptionCosts.item(i);
        Node parent = subscriptionCost.getParentNode();
        parent.removeChild(subscriptionCost);
    }
    return XMLConverter.convertToString(document, false);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:12,代码来源:MigrationBillingResultRemoveSubscriptionCost.java

示例13: detachNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
public void detachNode() {
    Node parent = getParentNode();
    if (parent != null) {
        parent.removeChild(this);
    }
    encodingStyleAttribute.clearNameAndValue();
    // Fix for CR: 6474641
    //tryToFindEncodingStyleAttributeName();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ElementImpl.java

示例14: removeSubjobComponentFromParentjob

import org.w3c.dom.Node; //导入方法依赖的package包/类
private void removeSubjobComponentFromParentjob(Document XmlDocument,
		String subjobId) {
	NodeList nodeList = XmlDocument.getFirstChild().getChildNodes();
	for (int i = 0; i < nodeList.getLength(); i++) {
		if (nodeList.item(i).getNodeName().matches(SUBJOB_COMPONENTS)) {
			String componentId = nodeList.item(i).getAttributes()
					.getNamedItem(ID).getNodeValue();
			if (componentId.equals(subjobId)) {
				Node parent = nodeList.item(i).getParentNode();
				parent.removeChild(nodeList.item(i));
			}
		}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:15,代码来源:ParseSubjob.java

示例15: removeAll

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void removeAll(Node node) {
    NodeList list = node.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        Node n = list.item(i);
        if (n.hasChildNodes()) {
            removeAll(n);
            node.removeChild(n);
        } else {
            node.removeChild(n);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:XMLOperation.java


注:本文中的org.w3c.dom.Node.removeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。