List of usage examples for com.google.gwt.xml.client Node DOCUMENT_NODE
short DOCUMENT_NODE
To view the source code for com.google.gwt.xml.client Node DOCUMENT_NODE.
Click Source Link
From source file:client.net.sf.saxon.ce.dom.DOMWriter.java
License:Mozilla Public License
/** * Set the attachment point for the new subtree * @param node the node to which the new subtree will be attached *///from w ww . j a v a 2 s .com public void setNode(Node node) { if (node == null) { return; } currentNode = node; if (node.getNodeType() == Node.DOCUMENT_NODE) { document = (Document) node; } else { document = currentNode.getOwnerDocument(); if (document == null) { // which might be because currentNode() is a parentless ElementOverNodeInfo. // we create a DocumentOverNodeInfo, which is immutable, and will cause the DOMWriter to fail //document = new DocumentOverNodeInfo(); // TODO:CLAXON - check this } } }
From source file:client.net.sf.saxon.ce.xmldom.NodeXml.java
License:Apache License
/** * This method creates a new node of the correct type. * // w w w .j a v a 2 s. c om * @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.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; } }