private Document getXMLDocumentFromString( String xmlText ) { return (Document) XMLParser.parse( xmlText ); }
/** * Constructor for an empty document. * * @param mediaType * The representation's media type. */ public DomRepresentation(MediaType mediaType) { super(mediaType); this.dom = XMLParser.createDocument(); }
/** * This method removes all <code>Text</code> nodes which are made up of only * white space. * * @param n the node which is to have all of its whitespace descendents * removed. */ public static void removeWhitespace(Node n) { removeWhitespaceInner(n, null); }
/** * Returns the wrapped DOM document. If no document is defined yet, it * attempts to parse the XML representation eventually given at construction * time. Otherwise, it just creates a new document. * * @return The wrapped DOM document. * @throws IOException */ public Document getDocument() throws IOException { if (this.dom == null) { if (this.xmlRepresentation != null) { this.dom = XMLParser.parse(this.xmlRepresentation.getText()); } else { this.dom = XMLParser.createDocument(); } } return this.dom; }
/** * Returns the wrapped DOM document. If no document is defined yet, it * attempts to parse the XML representation eventually given at construction * time. Otherwise, it just creates a new document. * * @return The wrapped DOM document. */ public Document getDocument() { if (this.dom == null) { if (this.xmlRepresentation != null) { this.dom = XMLParser.parse(this.xmlRepresentation.getText()); } else { this.dom = XMLParser.createDocument(); } } return this.dom; }
public String validate(String code) { try { XMLParser.parse(code); return null; } catch (Exception e) { return e.getMessage(); } } }
/** * Constructor for an empty document. * * @param mediaType * The representation's media type. */ public XmlRepresentation(MediaType mediaType) { super(mediaType); this.dom = XMLParser.createDocument(); }
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); } } 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); } } }
public String validate(String code) { try { XMLParser.parse(code); return null; } catch (Exception e) { return e.getMessage(); } } }
protected XMLPacketImplGWT(final String name, @Nullable final String namespace) { document = XMLParser.createDocument(); element = document.createElement(name); if (namespace != null) { element.setAttribute("xmlns", namespace); } document.appendChild(element); }
/** * This method removes all <code>Text</code> nodes which are made up of only * white space. * * @param n the node which is to have all of its whitespace descendents * removed. */ public static void removeWhitespace(Node n) { removeWhitespaceInner(n, null); }
@Override protected Element stringToElement( String xml ) { return XMLParser.parse( xml ).getDocumentElement(); }
public XmlDebugPanel(TreeTableModel model) { this.model = model; nodes = new IdentityHashMap<Object, Element>(); document = XMLParser.createDocument(); root = document.createElement("debug-panel"); initWidget(textArea = new TextArea()); textArea.ensureDebugId("debug-panel-xml"); textArea.setStyleName(Utils.style() + "-xml"); // Build the XML document based on the current state. document.appendChild(root); nodes.put(model.getRoot(), root); build(model.getRoot()); model.addTreeTableModelListener(this); }
/** * This method removes all <code>Text</code> nodes which are made up of only * white space. * * @param n the node which is to have all of its whitespace descendents * removed. */ public static void removeWhitespace(Node n) { removeWhitespaceInner(n, null); }
@Nullable private Document convertFromXML(@Nonnull final Response response) { if (response.getText() != null) { return XMLParser.parse(response.getText()); } else { return null; } } }
public String convertToXml( IDatabaseConnection dbConn ) { Document document = XMLParser.createDocument(); try { Element databaseConnection = document.createElement( DATABASE_CONNECTION );
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); } } 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); } } }
@Override protected Document parseResult() throws Exception { try { return XMLParser.parse(response.getText()); } catch (Throwable e) { throw new ResponseFormatException("Response was NOT a valid XML document", e); } } });
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); } } 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); } } }
public void onResponseReceived(Request request, Response response) { PropertiesManager.this.properties = XMLParser.parse(response.getText()); Application.continueStartup(); } };