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

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

Introduction

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

Prototype

short COMMENT_NODE

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

Click Source Link

Document

The constant 8 denotes DOM nodes of type Comment.

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   www. jav  a2 s  .co m
 * @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:com.sensia.gwt.relaxNG.XMLSensorMLParser.java

License:Open Source License

/**
 * Parses the children./*from  w w  w  . j av  a  2  s .  c  o m*/
 *
 * @param parent the parent
 * @param element the element
 */
protected void parseChildren(RNGTag parent, Node element) {
    NodeList children = element.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node node = children.item(i);

        if (node.getNodeType() == Node.TEXT_NODE) {
            RNGValue val = new RNGValue();
            //val.setText(node.getNodeValue().replace("\\s+", " "));
            val.setText(node.getNodeValue());
            ((RNGTagList) parent).add(val);
        } else if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element elt = (Element) node;
            RNGElement rngElt = new RNGElement();
            QName qName = parseName(elt.getNodeName());

            rngElt.setName(qName.localName);
            rngElt.setNamespace(qName.namespaceURI);

            //add attributes if any
            if (elt.hasAttributes()) {
                NamedNodeMap attributes = elt.getAttributes();

                for (int j = 0; j < attributes.getLength(); j++) {
                    Node attr = attributes.item(j);
                    RNGAttribute rngAtt = new RNGAttribute();
                    qName = parseName(attr.getNodeName());

                    rngAtt.setName(qName.localName);
                    rngAtt.setNamespace(qName.namespaceURI);

                    RNGValue rngValue = new RNGValue();
                    //rngValue.setText(attr.getNodeValue().replace("\\s+", " "));
                    rngValue.setText(attr.getNodeValue());
                    //add value to attribute
                    rngAtt.add(rngValue);

                    //add attribute to element
                    rngElt.add(rngAtt);
                }
            }
            ((RNGTagList) parent).add(rngElt);
            parseChildren(rngElt, elt);
        } else if (node.getNodeType() == Node.COMMENT_NODE) {
            RNGText rngComment = new RNGText();
            rngComment.setText("\n<!--" + node.getNodeValue() + "-->");
            ((RNGTagList) parent).add(rngComment);
        }
    }
}

From source file:com.sensia.gwt.relaxNG.XMLSerializer.java

License:Open Source License

protected static void serialize(Node node, StringBuilder doc, StringBuilder indent) {
    switch (node.getNodeType()) {
    case Node.DOCUMENT_NODE:
        serialize(((Document) node).getDocumentElement(), doc, indent);
        break;/*from w  w  w  . j  a  v a  2  s.co  m*/

    case Node.ELEMENT_NODE:
        // start element
        if (indent.length() > 0) {
            doc.append('\n');
            doc.append(indent.toString());
        }
        doc.append('<');
        doc.append(node.getNodeName());

        // attributes
        NamedNodeMap atts = ((Element) node).getAttributes();
        for (int i = 0; i < atts.getLength(); i++) {
            Attr att = (Attr) atts.item(i);
            doc.append(' ');
            doc.append(att.getNodeName());
            doc.append("=\"");
            doc.append(att.getNodeValue());
            doc.append('"');
        }

        NodeList children = node.getChildNodes();
        if (children.getLength() == 0)
            doc.append("/>");
        else
            doc.append('>');

        // children
        indent.append(INDENT);
        for (int i = 0; i < children.getLength(); i++)
            serialize(children.item(i), doc, indent);
        indent.setLength(indent.length() - INDENT.length());

        // close element
        if (children.getLength() > 0) {
            if (doc.charAt(doc.length() - 1) == '>') {
                doc.append('\n');
                doc.append(indent.toString());
            }
            doc.append("</");
            doc.append(node.getNodeName());
            doc.append('>');
        }
        break;

    case Node.TEXT_NODE:
        // TODO properly escape
        doc.append(node.getNodeValue());
        break;

    case Node.COMMENT_NODE:
        doc.append('\n');
        doc.append(indent.toString());
        doc.append("<!--");
        doc.append(node.getNodeValue());
        doc.append("-->");
        break;
    }
}

From source file:org.gk.ui.client.com.tree.xml.gkXMLTreeGridIC.java

License:Open Source License

/**
 * /*  w w w  . j  av a 2 s.co  m*/
 * @param xmlNode
 * @param treeModel
 * @param cm
 */
public void preprocessNode(Node xmlNode, BaseTreeModel treeModel, ColumnModel cm) {
    NodeList xmlNodeList = xmlNode.getChildNodes();
    // ?
    for (int i = 0; i < xmlNodeList.getLength(); i++) {
        Node subXMLNode = xmlNodeList.item(i);
        if (subXMLNode.getNodeType() == Node.COMMENT_NODE || subXMLNode.getNodeType() == Node.TEXT_NODE) {
            continue;
        }

        BaseTreeModel subTreeNode = createTreeNode(subXMLNode, cm);
        preprocessNode(subXMLNode, subTreeNode, cm);
        treeModel.add(subTreeNode);
    }
}

From source file:org.gk.ui.client.com.tree.xml.gkXMLTreePanelIC.java

License:Open Source License

/**
 * ?/*from  ww w  . j a v a 2  s  .c o  m*/
 * 
 * @param store
 * @param xmlNode
 * @param treeNode
 */
public void preprocessNode(TreeStore store, Node xmlNode, ModelData treeNode) {
    NodeList xmlNodeList = xmlNode.getChildNodes();
    // ?
    for (int i = 0; i < xmlNodeList.getLength(); i++) {
        Node subXMLNode = xmlNodeList.item(i);
        if (subXMLNode.getNodeType() == Node.COMMENT_NODE || subXMLNode.getNodeType() == Node.TEXT_NODE) {
            continue;
        }
        gkMap subTreeNode = createTreeNode(subXMLNode);
        store.add(treeNode, subTreeNode, true);
        preprocessNode(store, subXMLNode, subTreeNode);
    }
}