1 package org.xmldb.xupdate.lexus.commands; 2 3 55 56 import org.w3c.dom.Attr ; 57 import org.w3c.dom.Element ; 58 import org.w3c.dom.Node ; 59 60 65 public class RemoveCommand extends CommandObject { 66 67 68 71 public RemoveCommand(Node contextNode) throws Exception { 72 super(contextNode); 73 } 74 75 76 79 public boolean submitInstruction(int instruction) { 80 return false; 82 } 83 84 85 88 public boolean executeInstruction() { 89 return false; 91 } 92 93 94 97 public Node execute() throws Exception { 98 String selection = (String ) attributes.get("select"); 99 selectNodes(selection); 100 101 int selectionLength = selectionNodeList.getLength(); 102 for (int i = 0; i < selectionLength; i++) { 103 Node current = selectionNodeList.item(i); 104 Node parent; 105 switch (current.getNodeType()) { 106 case Node.ATTRIBUTE_NODE: 107 parent = ((Attr ) current).getOwnerElement(); 108 ((Element ) parent).removeAttribute(current.getNodeName()); 109 break; 110 default: 111 parent = current.getParentNode(); 112 parent.removeChild(current); 113 } 114 } 115 return contextNode; 116 } 117 } 118 119 | Popular Tags |