transformer

transformer.setOutputProperty(OutputKeys.ENCODING, “UTF-8”) is NOT working

拈花ヽ惹草 提交于 2019-11-28 10:57:20
I have the following method to write an XMLDom to a stream: public void writeToOutputStream(Document fDoc, OutputStream out) throws Exception { fDoc.setXmlStandalone(true); DOMSource docSource = new DOMSource(fDoc); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "no"); transformer.transform(docSource, new StreamResult(out)); } I am testing some other XML functionality, and this is just the method

java append to file

♀尐吖头ヾ 提交于 2019-11-28 09:16:22
问题 I googled for this for a while but can't seem to find it and it should be easy. I want to append a CR to then end of an XML file that I am creating with a Transformer. Is there a way to do this> I tried the following but this resulted in a blank file? Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "file:///ReportWiz.dtd"); xformer.transform(source, result); OutputStream writer = new FileOutputStream(file); Byte b =

Setting namespaces and prefixes in a Java DOM document

不打扰是莪最后的温柔 提交于 2019-11-28 09:16:18
I'm trying to convert a ResultSet to an XML file. I've first used this example for the serialization. import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.Document; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; ... DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); ... LSSerializer writer = impl.createLSSerializer(); String str = writer.writeToString(document); After I made this work, I tried to validate my XML file, there were a

Pretty print XML in java 8

女生的网名这么多〃 提交于 2019-11-28 06:51:31
I have an XML file stored as a DOM Document and I would like to pretty print it to the console, preferably without using an external library. I am aware that this question has been asked multiple times on this site, however none of the previous answers have worked for me. I am using java 8, so perhaps this is where my code differs from previous questions? I have also tried to set the transformer manually using code found from the web, however this just caused a not found error. Here is my code which currently just outputs each xml element on a new line to the left of the console. import java

The “touchmove” event on android system: Transformer Prime

本秂侑毒 提交于 2019-11-27 20:57:55
问题 I am working on a Transformer Pad and developing a drawing plate. I use PhoneGap(javascript) to write the code instead of JAVA. But the touchmove event is quite weird. I think as I move my finger on the pad, it will continuously to collect the coordinates which I touch on the canvas. BUT IT DOES NOT! It's ridiculous, it only collect "1" coordinate: the first point on the canvas my finger moves to. Here are my code about the "Touch && Move event": function touchStart(event){ if (event

transformer.setOutputProperty(OutputKeys.ENCODING, “UTF-8”) is NOT working

北慕城南 提交于 2019-11-27 03:17:18
问题 I have the following method to write an XMLDom to a stream: public void writeToOutputStream(Document fDoc, OutputStream out) throws Exception { fDoc.setXmlStandalone(true); DOMSource docSource = new DOMSource(fDoc); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "no"); transformer.transform

Setting namespaces and prefixes in a Java DOM document

感情迁移 提交于 2019-11-27 02:16:00
问题 I'm trying to convert a ResultSet to an XML file. I've first used this example for the serialization. import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.Document; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; ... DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS impl = (DOMImplementationLS)registry.getDOMImplementation("LS"); ... LSSerializer writer = impl.createLSSerializer(); String str

Pretty print XML in java 8

两盒软妹~` 提交于 2019-11-27 01:37:59
问题 I have an XML file stored as a DOM Document and I would like to pretty print it to the console, preferably without using an external library. I am aware that this question has been asked multiple times on this site, however none of the previous answers have worked for me. I am using java 8, so perhaps this is where my code differs from previous questions? I have also tried to set the transformer manually using code found from the web, however this just caused a not found error. Here is my