Java Code Examples for org.w3c.dom.Document#getInputEncoding()
The following examples show how to use
org.w3c.dom.Document#getInputEncoding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TCKEncodingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Assertion testing * for public String getInputEncoding(), * Encoding is not specified. getInputEncoding returns null.. */ @Test public void testGetInputEncoding002() { Document doc = null; try { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); doc = db.newDocument(); } catch (ParserConfigurationException e) { Assert.fail(e.toString()); } String encoding = doc.getInputEncoding(); if (encoding != null) { Assert.fail("expected encoding: null, returned: " + encoding); } System.out.println("OK"); }
Example 2
Source File: DOMSerializerImpl.java From Bytecoder with Apache License 2.0 | 5 votes |
private String _getInputEncoding(Node node) { Document doc = (node.getNodeType() == Node.DOCUMENT_NODE) ? (Document) node : node.getOwnerDocument(); if (doc != null) { try { return doc.getInputEncoding(); } // The VM ran out of memory or there was some other serious problem. Re-throw. catch (VirtualMachineError | ThreadDeath vme) { throw vme; } // Ignore all other exceptions and errors catch (Throwable t) { } } return null; }
Example 3
Source File: DOMSerializerImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private String _getInputEncoding(Node node) { Document doc = (node.getNodeType() == Node.DOCUMENT_NODE) ? (Document) node : node.getOwnerDocument(); if (doc != null) { try { return doc.getInputEncoding(); } // The VM ran out of memory or there was some other serious problem. Re-throw. catch (VirtualMachineError | ThreadDeath vme) { throw vme; } // Ignore all other exceptions and errors catch (Throwable t) { } } return null; }
Example 4
Source File: InternalGrammarDocument.java From JVoiceXML with GNU Lesser General Public License v2.1 | 5 votes |
/** * Constructs a new object from a grammar node. This constructor is intended * to be used to capture inline grammars in a VoiceXML document. * * @param node * the grammar node * @throws UnsupportedEncodingException * the node contains a grammar with an invalid character set */ public InternalGrammarDocument(final Grammar node) throws UnsupportedEncodingException { // Try getting the encoding of the owner document final Document owner = node.getOwnerDocument(); final String ownerEncoding = owner.getInputEncoding(); if (ownerEncoding == null) { charset = System.getProperty("file.encoding"); } else { charset = ownerEncoding; } document = null; buffer = node.toString().getBytes(charset); grammar = node; }
Example 5
Source File: DOMWriter.java From java-client-api with Apache License 2.0 | 5 votes |
public void serializeDocument(Document document) throws XMLStreamException { String encoding = document.getInputEncoding(); String version = document.getXmlVersion(); if (encoding != null) { serializer.writeStartDocument(encoding, version); } else { serializer.writeStartDocument(version); } if (document.hasChildNodes()) { serializeNodeList(document.getChildNodes()); } serializer.writeEndDocument(); }
Example 6
Source File: XMLUtils.java From pixymeta-android with Eclipse Public License 1.0 | 4 votes |
public static String serializeToString(Document doc) throws IOException { String encoding = doc.getInputEncoding(); if(encoding == null) encoding = "UTF-8"; return serializeToString(doc, encoding); }
Example 7
Source File: XMLUtils.java From icafe with Eclipse Public License 1.0 | 4 votes |
public static String serializeToString(Document doc) throws IOException { String encoding = doc.getInputEncoding(); if(encoding == null) encoding = "UTF-8"; return serializeToString(doc, encoding); }
Example 8
Source File: XMLUtils.java From pixymeta-android with Eclipse Public License 1.0 | 3 votes |
/** * Serialize XML Document to string using DOM Level 3 Load/Save * * @param doc XML Document * @param node the Node to serialize * @return String representation of the Document * @throws IOException */ public static String serializeToStringLS(Document doc, Node node) throws IOException { String encoding = doc.getInputEncoding(); if(encoding == null) encoding = "UTF-8"; return serializeToStringLS(doc, node, encoding); }
Example 9
Source File: XMLUtils.java From icafe with Eclipse Public License 1.0 | 3 votes |
/** * Serialize XML Document to string using DOM Level 3 Load/Save * * @param doc XML Document * @param node the Node to serialize * @return String representation of the Document * @throws IOException */ public static String serializeToStringLS(Document doc, Node node) throws IOException { String encoding = doc.getInputEncoding(); if(encoding == null) encoding = "UTF-8"; return serializeToStringLS(doc, node, encoding); }