Example usage for com.google.gwt.xml.client Node getNodeValue

List of usage examples for com.google.gwt.xml.client Node getNodeValue

Introduction

In this page you can find the example usage for com.google.gwt.xml.client Node getNodeValue.

Prototype

String getNodeValue();

Source Link

Document

This method retrieves the value.

Usage

From source file:anzsoft.xmpp4gwt.client.packet.PacketGwtImpl.java

License:Open Source License

public String getCData() {
    Node x = element.getFirstChild();
    if (x != null) {
        return x.getNodeValue();
    }/*from   www. j a v a 2 s.c om*/
    return null;
}

From source file:bz.davide.dmxmljson.unmarshalling.xml.gwt.GWTXMLStructure.java

License:Open Source License

private void extractChildElementByName() {
    NodeList nl = this.element.element.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
        Node node = nl.item(i);
        if (node instanceof Element) {
            Element element = (Element) node;

            String tagName = element.getTagName();
            String[] parts = GWTXMLStructure.extractNameAndSubtype(tagName);

            String attrName = parts[0];
            ElementAndSubtype elementAndSubtype = new ElementAndSubtype();
            elementAndSubtype.element = element;
            elementAndSubtype.subtype = parts[1];

            ArrayList<ElementAndSubtype> elements = this.elementsByName.get(attrName);
            if (elements == null) {
                elements = new ArrayList<ElementAndSubtype>();
                this.elementsByName.put(attrName, elements);
            }//from   w  ww .  j a  v  a  2 s. co m
            elements.add(elementAndSubtype);

            ElementAndSubtype childElementAndSubtype = new ElementAndSubtype();
            childElementAndSubtype.element = element;
            childElementAndSubtype.subtype = tagName;
            // Convert first letter to upper case, because java classes start normally with upper case
            childElementAndSubtype.subtype = childElementAndSubtype.subtype.substring(0, 1).toUpperCase()
                    + childElementAndSubtype.subtype.substring(1);
            this.childNodes.add(childElementAndSubtype);
        }
        if (node instanceof Text) {
            String txt = node.getNodeValue();
            if (txt.trim().length() > 0) {
                ElementAndSubtype childElementAndSubtype = new ElementAndSubtype();
                childElementAndSubtype.element = node;
                childElementAndSubtype.subtype = "TextNode";
                this.childNodes.add(childElementAndSubtype);
            }
        }
    }
}

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  o m*/
    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:ccc.client.gwt.core.GWTValidations.java

License:Open Source License

/** {@inheritDoc} */
@Override//from  ww  w .  j av  a 2 s .co  m
public String notValidXML(final String definition) {
    try {
        final Document d = XMLParser.parse(definition);
        final NodeList fields = d.getElementsByTagName("field");
        if (fields.getLength() > 32) {
            return UI_CONSTANTS.tooManyFields();
        }

        final NodeList l = d.getElementsByTagName("option");
        for (int n = 0; n < l.getLength(); n++) {
            final NamedNodeMap al = l.item(n).getAttributes();
            final Node value = al.getNamedItem("value");
            if (value != null && value.getNodeValue().indexOf(',') != -1) {
                return "XML option value " + UI_CONSTANTS.mustNotContainComma();
            }
        }
    } catch (final DOMParseException e) {
        return "XML " + UI_CONSTANTS.isNotValid();
    }
    return null;
}

From source file:ch.systemsx.cisd.openbis.generic.client.web.client.application.FormPanelListener.java

License:Apache License

private final void extractAndDisplay(final String msg) {
    final Document document = XMLParser.parse(msg);
    final Node message = document.getFirstChild();
    final Node typeNode = message.getAttributes().getNamedItem("type");
    final String messageText = message.getFirstChild().getNodeValue();
    final String type = typeNode.getNodeValue();
    if ("info".equals(type)) {
        infoBox.displayInfo(messageText);
    } else {/*from w  w w . j  a  v  a2  s .  c o  m*/
        infoBox.displayError(messageText);
    }
}

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);//from w  w w  .  ja  v a2s .co  m
        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());
            }
            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.calclab.emite.base.xml.XMLPacketImplGWT.java

License:Open Source License

@Override
public String getText() {
    final StringBuilder result = new StringBuilder();
    final NodeList nodes = element.getChildNodes();
    for (int i = 0; i < nodes.getLength(); i++) {
        final Node child = nodes.item(i);
        if (child.getNodeType() == Node.TEXT_NODE)
            result.append(child.getNodeValue());
    }//  w  w  w.ja  va2 s .  com

    return result.toString();
}

From source file:com.calclab.emite.core.client.packet.gwt.GWTPacket.java

License:Open Source License

@Override
public HashMap<String, String> getAttributes() {
    final HashMap<String, String> map = new HashMap<String, String>();
    final NamedNodeMap attributes = element.getAttributes();
    for (int index = 0; index < attributes.getLength(); index++) {
        final Node attrib = attributes.item(index);
        if (attrib == null) {
            continue;
        }/*from   w w  w  . j a  v  a  2s. com*/

        map.put(attrib.getNodeName(), attrib.getNodeValue());
    }
    return map;
}

From source file:com.calclab.emite.core.client.packet.gwt.GWTPacket.java

License:Open Source License

public Map<String, String> getAttributtes() {
    final HashMap<String, String> attributes = new HashMap<String, String>();
    final NamedNodeMap original = element.getAttributes();
    for (int index = 0; index < original.getLength(); index++) {
        final Node node = original.item(index);
        if (node == null) {
            continue;
        }//ww w .  j a  va  2s .  c o  m

        attributes.put(node.getNodeName(), node.getNodeValue());
    }
    return attributes;
}

From source file:com.calclab.emite.core.client.packet.gwt.GWTPacket.java

License:Open Source License

@Override
public String getText() {
    Node item;
    final NodeList childs = element.getChildNodes();
    for (int index = 0; index < childs.getLength(); index++) {
        item = childs.item(index);//www  . jav a  2  s . c o m
        if (item.getNodeType() == Node.TEXT_NODE)
            return item.getNodeValue();
    }
    return null;
}