List of usage examples for org.w3c.dom Document setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking);
From source file:Main.java
License:asdf
public static void main(String args[]) throws Exception { DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); // Create the parser Document xmlDoc = builder.parse(new InputSource(new StringReader(xmlString))); xmlDoc.setStrictErrorChecking(true); }
From source file:org.broad.igv.cbio.GeneNetwork.java
/** * Get the GraphML from this document. Filters will be finalized when this is called, * if they aren't already.//from ww w . j a v a 2 s . com * * @return */ public Document createDocument() { if (!filtersFinalized) { this.finalizeFilters(); } try { // Create a DOM document DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document document = documentBuilder.newDocument(); document.setStrictErrorChecking(false); // Global root element Element globalElement = document.createElement("graphml"); //Add schema and attributes for (Node node : schema) { globalElement.appendChild(node); } Element graphEl = document.createElement("graph"); for (int aa = 0; aa < graphAttr.getLength(); aa++) { Node attr = graphAttr.item(aa); graphEl.setAttribute(attr.getNodeName(), attr.getTextContent()); } //Add nodes and edges for (Node v : this.vertexSet()) { graphEl.appendChild(v); } for (Node e : this.edgeSet()) { graphEl.appendChild(e); } globalElement.appendChild(graphEl); document.appendChild(globalElement); return document; } catch (Exception e) { throw new RuntimeException("Error outputting graph"); } }