List of utility methods to do XML Document Create
Document | createDocument(final File file) create Document return createBuilder().parse(file);
|
Document | createDocument(final String rootName) Creates a new DOM. if (docBuilder == null) { try { docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (final ParserConfigurationException exc) { exc.printStackTrace(); return null; final Document doc = docBuilder.newDocument(); if (rootName != null) doc.appendChild(doc.createElement(rootName)); return doc; |
Document | createDocument(InputSource is) create Document DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setIgnoringElementContentWhitespace(true);
factory.setCoalescing(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(is);
|
Document | createDocument(Node node) create Document DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); if (node != null) { Transformer t = TransformerFactory.newInstance().newTransformer(); t.transform(new DOMSource(node), new DOMResult(doc)); return doc; ... |
Document | createDocument(Node sourceNode) create Document Document doc = createDocumentBuilder().newDocument(); Node source; if (sourceNode.getNodeType() == Node.DOCUMENT_NODE) { source = ((Document) sourceNode).getDocumentElement(); } else { source = sourceNode; Node node = doc.importNode(source, true); ... |
Document | CreateDocument(Path xml, Path xsd) Create Document DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(true); factory.setNamespaceAware(true); factory.setIgnoringComments(true); factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema"); if (xsd != null) factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsd.toString()); ... |
Document | createDocument(String content, String charset) create Document try { InputStream is = new ByteArrayInputStream(content.getBytes(charset)); return getBuilder().parse(is); } catch (Exception e) { throw new RuntimeException(e); |
Document | createDocument(String docElt) Creates a new DOM document. getImplementation(); return impl.createDocument("", docElt, null); |
Document | createDocument(String docElt) Creates a new DOM document. getImplementation(); return impl.createDocument("", docElt, null); |
Document | createDocument(String iName) create Document DocumentBuilderFactory lFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder lBuilder = lFactory.newDocumentBuilder();
DOMImplementation lBuilderImpl = lBuilder.getDOMImplementation();
return lBuilderImpl.createDocument(null, iName, null);
|