@Override public void normalize() { node.normalize(); }
/** * Normalises the current element. */ public void flush() { this.currentElement.normalize(); }
/** * @see org.w3c.dom.Node#normalize() */ public void normalize() { m_attributeNode.normalize(); }
protected static Triple<Short,String,Boolean> parseClassData(Node protocol) { protocol.normalize(); NamedNodeMap attrs=protocol.getAttributes(); boolean external=false; String magicnumber=attrs.getNamedItem("id").getNodeValue(); String clazzname=attrs.getNamedItem("name").getNodeValue(); Node tmp=attrs.getNamedItem("external"); if(tmp != null) external=Boolean.parseBoolean(tmp.getNodeValue()); return new Triple<>(Short.valueOf(magicnumber), clazzname,external); }
/** * Normalize the text nodes within this subtree. Although named similarly, * this method is unrelated to Document.normalize. */ @Override public final void normalize() { Node next; for (Node node = getFirstChild(); node != null; node = next) { next = node.getNextSibling(); node.normalize(); if (node.getNodeType() == Node.TEXT_NODE) { ((TextImpl) node).minimize(); } } }
/** * {@inheritDoc} * * @throws DOMException If thrown by method invoked on the underlying DOM document */ public void closeElement() throws DOMException, IllegalCloseElementException { if (this.currentElement.getNodeType() == Node.DOCUMENT_NODE) throw new IllegalCloseElementException(); this.depth--; this.isNude = false; Boolean hasChildren = this.childrenFlags.remove(this.childrenFlags.size() - 1); if (hasChildren.booleanValue()) { indent(); } this.currentElement.normalize(); this.currentElement = (Element)this.currentElement.getParentNode(); // new line if parent has children if (this.indent) { Boolean b = this.childrenFlags.get(this.childrenFlags.size() - 1); if (b.booleanValue()) { newLine(); } } }
private Map<String, Object> convertXMLtoMap(String xml2) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new ByteArrayInputStream(xml2.getBytes())); Node de = doc.getDocumentElement(); de.normalize(); Map<String, Object> map = new HashMap<>(); put(de, map); return map; } }
DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(file); doc.getDocumentElement().normalize(); NodeList nodeLst = doc.getElementsByTagName("employee"); for (int s = 0; s < nodeLst.getLength(); s++) {
doc.getDocumentElement().normalize();
/** * Compares two DOM {@link Node nodes} by comparing the representations of * the nodes as XML strings * * @param node1 the first node * @param node2 the second node * @return true if the XML representation node1 is the same as the XML * representation of node2, otherwise false */ public static boolean compareNodes(Node node1, Node node2) { Validate.notNull(node1, "First node required"); Validate.notNull(node2, "Second node required"); // The documents need to be cloned as normalization has side-effects node1 = node1.cloneNode(true); node2 = node2.cloneNode(true); // The documents need to be normalized before comparison takes place to // remove any formatting that interfere with comparison if (node1 instanceof Document && node2 instanceof Document) { ((Document) node1).normalizeDocument(); ((Document) node2).normalizeDocument(); } else { node1.normalize(); node2.normalize(); } return nodeToString(node1).equals(nodeToString(node2)); }
/** * @see org.w3c.dom.Node#normalize() */ public void normalize() { m_attributeNode.normalize(); }
/** * @see org.w3c.dom.Node#normalize() */ public void normalize() { m_attributeNode.normalize(); }
/** * End of an element. */ public void endElement() throws XPathException { if (canNormalize) { try { currentNode.normalize(); } catch (Throwable err) { canNormalize = false; } // in case it's a Level 1 DOM } currentNode = currentNode.getParentNode(); level--; }
private String getText(Node node) { node.normalize(); Node text = node.getFirstChild(); if (text != null && text.getNodeType() == Node.TEXT_NODE) { return text.getNodeValue(); } return ""; //$NON-NLS-1$ }
private String getText(Node node) { node.normalize(); Node text = node.getFirstChild(); if (text != null && text.getNodeType() == Node.TEXT_NODE) { return text.getNodeValue(); } return ""; //$NON-NLS-1$ }
private String getText(Node node) { node.normalize(); Node text = node.getFirstChild(); if (text != null && text.getNodeType() == Node.TEXT_NODE) { return text.getNodeValue(); } return ""; //$NON-NLS-1$ }
private String getText(Node node) { node.normalize(); Node text = node.getFirstChild(); if (text != null && text.getNodeType() == Node.TEXT_NODE) { return text.getNodeValue(); } return ""; //$NON-NLS-1$ }
protected static Triple<Short,String,Boolean> parseClassData(Node protocol) { protocol.normalize(); NamedNodeMap attrs=protocol.getAttributes(); String clazzname; String magicnumber; boolean external=false; magicnumber=attrs.getNamedItem("id").getNodeValue(); clazzname=attrs.getNamedItem("name").getNodeValue(); Node tmp=attrs.getNamedItem("external"); if(tmp != null) external=Boolean.parseBoolean(tmp.getNodeValue()); return new Triple<>(Short.valueOf(magicnumber), clazzname,external); }
/** * <b>DOM</b>: Implements {@link org.w3c.dom.Node#normalize()}. */ public void normalize() { super.normalize(); if (attributes != null) { NamedNodeMap map = getAttributes(); for (int i = map.getLength() - 1; i >= 0; i--) { map.item(i).normalize(); } } }
/** * Creates a new Node (of the same type as the original node) that * is similar to the orginal but doesn't contain any empty text or * CDATA nodes and where all textual content including attribute * values or comments are trimmed. */ public static Node stripWhitespace(Node original) { Node cloned = original.cloneNode(true); cloned.normalize(); handleWsRec(cloned, false); return cloned; }