private static void removeAfterPushDown(Node p, String begin) { Node current = p; while ((current = current.getParentNode()) != null) { if (current.getAttributes() != null && current.getAttributes().getNamedItem(begin) != null) { current.getAttributes().removeNamedItem(begin); } } }
/** * Removes attributes like "versionCode" and "versionName" from file. * * @param file File representing AndroidManifest.xml * @throws AndrolibException */ public static void removeManifestVersions(File file) throws AndrolibException { if (file.exists()) { try { Document doc = loadDocument(file); Node manifest = doc.getFirstChild(); NamedNodeMap attr = manifest.getAttributes(); Node vCode = attr.getNamedItem("android:versionCode"); Node vName = attr.getNamedItem("android:versionName"); if (vCode != null) { attr.removeNamedItem("android:versionCode"); } if (vName != null) { attr.removeNamedItem("android:versionName"); } saveDocument(file, doc); } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) { } } }
/** * Replaces the node's attributes with the attributes in the given hashmap * * @param node XML node that should be edited * @param attributes HashMap of strings representing the attributes of a node (key = value) * @return The given node with ONLY the given attributes */ private static Node rewriteNodeAttributes(Node node, HashMap<String, String> attributes) { NamedNodeMap nodeAttrs = node.getAttributes(); // Remove all previous attributes while (nodeAttrs.getLength() > 0) { nodeAttrs.removeNamedItem(nodeAttrs.item(0).getNodeName()); } // Set to new attributes for (String key : attributes.keySet()) { ((Element) node).setAttribute(key, attributes.get(key)); } return node; }
/** * Removes "debug" tag from file * * @param file AndroidManifest file * @throws AndrolibException */ public static void removeApplicationDebugTag(File file) throws AndrolibException { if (file.exists()) { try { Document doc = loadDocument(file); Node application = doc.getElementsByTagName("application").item(0); // load attr NamedNodeMap attr = application.getAttributes(); Node debugAttr = attr.getNamedItem("android:debuggable"); // remove application:debuggable if (debugAttr != null) { attr.removeNamedItem("android:debuggable"); } saveDocument(file, doc); } catch (SAXException | ParserConfigurationException | IOException | TransformerException ignored) { } } }
private static Node removeNode(String nodeName, NamedNodeMap nodeMap) { try { return nodeMap.removeNamedItem(nodeName); } catch (DOMException e) { if (e.code != DOMException.NOT_FOUND_ERR) throw e; return null; } }
private static Node removeNode(String nodeName, NamedNodeMap nodeMap) { try { return nodeMap.removeNamedItem(nodeName); } catch (DOMException e) { if (e.code != DOMException.NOT_FOUND_ERR) throw e; return null; } }
private static Node removeNode(String nodeName, NamedNodeMap nodeMap) { try { return nodeMap.removeNamedItem(nodeName); } catch (DOMException e) { if (e.code != DOMException.NOT_FOUND_ERR) { throw e; } return null; } }
public static void removeAttribute(Node node, String attName) { NamedNodeMap attributes = node.getAttributes(); attributes.removeNamedItem(attName); }
public static void removeAttribute(Node node, String attName) { NamedNodeMap attributes = node.getAttributes(); attributes.removeNamedItem(attName); }
public static void removeAttribute(Node node, String attName) { NamedNodeMap attributes = node.getAttributes(); attributes.removeNamedItem(attName); }
@Override public void removeAttribute(String name) { this.element.getAttributes().removeNamedItem(name); }
/** remove stray "xmlns" default namespace element that seems to get left over even after removing namespacing from nodes */ public static void removeXmlNsAttribute( final Node node ) { final NamedNodeMap attr = node.getAttributes(); for( int i = 0; i < attr.getLength(); i++ ) { final Node item = attr.item( i ); if( ATTR_XMLNS.equals( item.getNodeName() ) ) { attr.removeNamedItem( ATTR_XMLNS ); return; } } }
private static void removeAfterPushDown(Node p, String begin) { Node current = p; while ((current = current.getParentNode()) != null) { if (current.getAttributes() != null && current.getAttributes().getNamedItem(begin) != null) { current.getAttributes().removeNamedItem(begin); } } }
private static void removeAfterPushDown(Node p, String begin) { Node current = p; while ((current = current.getParentNode()) != null) { if (current.getAttributes() != null && current.getAttributes().getNamedItem(begin) != null) { current.getAttributes().removeNamedItem(begin); } } }
/** * Removes the specified attribute. * @param name the name of the item to remove */ @JsxFunction public void removeNamedItem(final String name) { attributes_.removeNamedItem(name); }
/** * <b>DOM</b>: Implements {@link * org.w3c.dom.Element#removeAttribute(String)}. */ public void removeAttribute(String name) throws DOMException { if (!hasAttribute(name)) { return; } attributes.removeNamedItem(name); }
/** * Removes the specified attribute. * @param name the name of the item to remove */ @JsxFunction public void removeNamedItem(final String name) { attributes_.removeNamedItem(name); }
/** * <b>DOM</b>: Implements {@link * org.w3c.dom.Element#removeAttribute(String)}. */ public void removeAttribute(String name) throws DOMException { if (!hasAttribute(name)) { return; } attributes.removeNamedItem(name); }
@Override @SuppressWarnings("unchecked") public void execute(Rule rule, @SuppressWarnings("rawtypes") RuleContext context, DOMDocument document) { List<Node> nodes = (List<Node>) context.getData(MetaNameMisuseRule.ERRORED_META_NODES); for(Node node : nodes) { final String nameValue = node.getAttributes().getNamedItem("name").getTextContent(); node.getAttributes().removeNamedItem("name"); Node propertyNode = document.getOriginalDocument().createAttribute("property"); propertyNode.setNodeValue(nameValue); node.getAttributes().setNamedItem(propertyNode); } }
public DOMNode removeNamedItem(String name) throws DOMException { try { return wrap(_delegate.removeNamedItem(name)); } catch (org.w3c.dom.DOMException ex) { throw wrap(ex); } }