本文整理匯總了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);
}
}
示例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);
}
}
}
}
}
示例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;
}
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
示例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));
}
}
示例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);
}
}
}
示例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));
}
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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));
}
}
}
}
示例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);
}
}
}