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

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

Introduction

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

Prototype

short ATTRIBUTE_NODE

To view the source code for com.google.gwt.xml.client Node ATTRIBUTE_NODE.

Click Source Link

Document

The constant 2 denotes DOM nodes of type Attribute.

Usage

From source file:client.net.sf.saxon.ce.xmldom.NodeXml.java

License:Apache License

/**
 * This method creates a new node of the correct type.
 * /*from  ww  w .j a  v a 2s  .  com*/
 * @param node - the supplied DOM JavaScript object
 * @return a Node object that corresponds to the DOM object
 */
public static Node build(JavaScriptObject node) {
    if (node == null) {
        return null;
    }
    short nodeType = XMLParserImpl.getNodeType(node);
    switch (nodeType) {
    case Node.ATTRIBUTE_NODE:
        return new AttrImpl(node);
    case Node.CDATA_SECTION_NODE:
        return new CDATASectionImpl(node);
    case Node.COMMENT_NODE:
        return new CommentImpl(node);
    case Node.DOCUMENT_FRAGMENT_NODE:
        return new DocumentFragmentImpl(node);
    case Node.DOCUMENT_NODE:
        return new DocumentImpl(node);
    case Node.ELEMENT_NODE:
        return new ElementImpl(node);
    case Node.PROCESSING_INSTRUCTION_NODE:
        return new ProcessingInstructionImpl(node);
    case Node.TEXT_NODE:
        return new TextImpl(node);
    default:
        return new NodeXml(node);
    }
}

From source file:fast.servicescreen.client.rpc.SendRequestHandler.java

License:Open Source License

private void addChildTree(TreeItem treeItem, Node item) {
    // add this node
    String nodeName = item.getNodeName();
    String nodeValue = item.getNodeValue();
    boolean subNodeProcessed = false;

    short nodeType = item.getNodeType();
    if (nodeType == Node.TEXT_NODE && nodeValue.startsWith("\n")) {
        // skip newline text nodes
        return;/*from  ww w . j  a  va 2 s  .co m*/
    }

    NodeList childNodes = item.getChildNodes();

    if (nodeValue == null && childNodes.getLength() == 1
            && childNodes.item(0).getNodeType() == Node.TEXT_NODE) {
        // if it has only one child of type text, add that text as value for this node
        nodeValue = childNodes.item(0).getNodeValue();
        subNodeProcessed = true;
    }

    if (nodeValue == null) {
        nodeValue = "";
    }

    TreeItem thisTreeItem = treeItem.addItem(nodeName + " : " + nodeValue);

    // add attributes
    try {
        if (nodeType != Node.ATTRIBUTE_NODE && nodeType != Node.TEXT_NODE) {
            NamedNodeMap attributes = item.getAttributes();
            for (int i = 0; i < attributes.getLength(); i++) {
                Node subItem = attributes.item(i);
                addChildTree(thisTreeItem, subItem);
            }
        }
    } catch (Exception e) {
        System.out.println("Could not access attributes for node of type " + nodeType);
    }

    // add sub nodes
    if (!subNodeProcessed && nodeType != Node.ATTRIBUTE_NODE && nodeType != Node.TEXT_NODE) {
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node subItem = childNodes.item(i);
            addChildTree(thisTreeItem, subItem);
        }
    }
}

From source file:org.catrobat.html5player.client.Parser.java

License:Open Source License

private String getText(Node context) {
    if (context == null)
        return null;
    StringBuffer text = new StringBuffer();
    if (context.getNodeType() == Node.ELEMENT_NODE) {

        NodeList children = context.getChildNodes();
        int childLength = children.getLength();
        boolean wrap = false;
        for (int i = 0; i < childLength; i++) {
            Node child = children.item(i);
            if (child.getNodeType() == Node.TEXT_NODE) {
                if (wrap) {
                    text.append("\n");
                }//from   w w  w . j  a  v a  2 s.co  m
                wrap = true;
                text.append(((Text) child).getData());
            }
        }
    } else if (context.getNodeType() == Node.TEXT_NODE) {
        text.append(((Text) context).getData());
    } else if (context.getNodeType() == Node.ATTRIBUTE_NODE) {
        text.append(((Attr) context).getValue());
    }
    return text.toString();
}