List of usage examples for com.google.gwt.xml.client Node getChildNodes
NodeList getChildNodes();
From source file:bz.davide.dmxmljson.unmarshalling.xml.gwt.GWTXMLValue.java
License:Open Source License
void recursiveText(Node node, StringBuffer sb) { if (node.getNodeType() == Node.TEXT_NODE) { sb.append(node.getNodeValue());/*from w w w . ja v a 2 s .c om*/ } if (node.getNodeType() == Node.ELEMENT_NODE) { NodeList nl = node.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { this.recursiveText(nl.item(i), sb); } } }
From source file:client.net.sf.saxon.ce.xmldom.XMLParser.java
License:Mozilla Public License
private static void removeWhitespaceInner(Node n, Node parent) { // This n is removed from the parent if n is a whitespace node if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) { Text t = (Text) n; if (t.getData().matches("[ \t\n]*")) { parent.removeChild(t);/* w w w . jav a 2 s.co m*/ } } if (n.hasChildNodes()) { int length = n.getChildNodes().getLength(); List<Node> toBeProcessed = new ArrayList<Node>(); // We collect all the nodes to iterate as the child nodes will change // upon removal for (int i = 0; i < length; i++) { toBeProcessed.add(n.getChildNodes().item(i)); } // This changes the child nodes, but the iterator of nodes never changes // meaning that this is safe for (Node childNode : toBeProcessed) { removeWhitespaceInner(childNode, n); } } }
From source file:com.bramosystems.oss.player.playlist.client.impl.SAXParser.java
License:Apache License
private void processNodes(NodeList node) throws ParseException { for (int i = 0; i < node.getLength(); i++) { Node nd = node.item(i); switch (nd.getNodeType()) { case Node.ELEMENT_NODE: HashMap<String, String> attr = new HashMap<String, String>(); NamedNodeMap nnm = nd.getAttributes(); for (int j = 0; j < nnm.getLength(); j++) { Node nm = nnm.item(j); attr.put(nm.getNodeName(), nm.getNodeValue()); }/*from w w w . j a v a 2s .c om*/ handler.onNodeStart(nd.getNodeName(), attr, nd.getNamespaceURI()); processNodes(nd.getChildNodes()); handler.onNodeEnd(nd.getNodeName()); break; case Node.TEXT_NODE: handler.setNodeValue(nd.getParentNode().getNodeName(), nd.getNodeValue()); } } }
From source file:com.codenvy.editor.api.editor.common.ContentFormatter.java
License:Apache License
/** * Transform children nodes of xml node to text format. * * @param node/*from w w w .j a v a 2 s. c om*/ * node that contains children which need to be formatted * @param depth * depth of parent node in xml * @return children nodes in text format */ @NotNull private static String transformChildrenNodes(@NotNull Node node, int depth) { StringBuilder text = new StringBuilder(); NodeList nodeList = node.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node currentNode = nodeList.item(i); if (isTextNode(currentNode)) { text.append(currentNode.toString()); } else if (currentNode.hasChildNodes()) { text.append(parseXMLNode(currentNode, depth + 1)); } else { text.append('\n').append(createTab(depth + 1)).append(currentNode); } } return text.toString(); }
From source file:com.codenvy.editor.api.editor.common.ContentFormatter.java
License:Apache License
/** * Returns whether a node has a text child node. * * @param node//from w w w. j a va 2s .c o m * node that need to be checked * @return <code>true</code> if a node has a text child node, and <code>false</code> otherwise */ private static boolean hasTextChildNode(@NotNull Node node) { if (node.hasChildNodes()) { Node child = node.getChildNodes().item(0); return isTextNode(child); } return false; }
From source file:com.codenvy.editor.api.editor.elements.AbstractLink.java
License:Apache License
/** {@inheritDoc} */ @Override// w w w. j av a 2s. c om public void deserializeInternalFormat(@Nonnull Node node) { NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); applyProperty(item); } }
From source file:com.codenvy.editor.api.editor.elements.AbstractLink.java
License:Apache License
/** {@inheritDoc} */ @Override// ww w. j a va 2 s . c o m public void applyProperty(@Nonnull Node node) { String nodeName = node.getNodeName(); String nodeValue = node.getChildNodes().item(0).getNodeValue(); switch (nodeName) { case "source": source = nodeValue; break; case "target": target = nodeValue; break; case "uuid": id = nodeValue; break; } }
From source file:com.codenvy.editor.api.editor.elements.AbstractShape.java
License:Apache License
/** {@inheritDoc} */ @Override/*from w ww. ja v a 2 s. c om*/ public void deserialize(@Nonnull Node node) { NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); String name = item.getNodeName(); if (isProperty(name)) { applyProperty(item); } else { Element element = findElement(name); element.deserialize(item); if (element instanceof Shape) { addShape((Shape) element); } else { addLink((Link) element); } } } }
From source file:com.codenvy.editor.api.editor.elements.AbstractShape.java
License:Apache License
/** {@inheritDoc} */ @Override/* w w w .ja v a2s. c om*/ public void deserializeInternalFormat(@Nonnull Node node) { NodeList childNodes = node.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node item = childNodes.item(i); String name = item.getNodeName(); if (isInternalProperty(name)) { applyProperty(item); } else { Element element = findElement(name); element.deserializeInternalFormat(item); if (element instanceof Shape) { addShape((Shape) element); } else { addLink((Link) element); } } } }
From source file:com.codenvy.editor.client.elements.Shape1.java
License:Apache License
@Override public void applyProperty(@Nonnull Node node) { String nodeName = node.getNodeName(); String nodeValue = node.getChildNodes().item(0).getNodeValue(); switch (nodeName) { case "property1": property1 = nodeValue;//from ww w . j a v a2 s.c om break; case "x": setX(Integer.valueOf(nodeValue)); break; case "y": setY(Integer.valueOf(nodeValue)); break; case "uuid": id = nodeValue; break; case "autoAlign": setAutoAlignmentParam(Boolean.valueOf(nodeValue)); break; } }