List of usage examples for javax.xml.transform OutputKeys ENCODING
String ENCODING
To view the source code for javax.xml.transform OutputKeys ENCODING.
Click Source Link
From source file:org.expath.tools.model.exist.EXistSequence.java
/** * Borrowed from {@link org.expath.tools.saxon.model.SaxonSequence} *//*from w ww . j av a2 s . co m*/ private Properties makeOutputProperties(final SerialParameters params) throws ToolsException { final Properties props = new Properties(); setOutputKey(props, OutputKeys.METHOD, params.getMethod()); setOutputKey(props, OutputKeys.MEDIA_TYPE, params.getMediaType()); setOutputKey(props, OutputKeys.ENCODING, params.getEncoding()); setOutputKey(props, OutputKeys.CDATA_SECTION_ELEMENTS, params.getCdataSectionElements()); setOutputKey(props, OutputKeys.DOCTYPE_PUBLIC, params.getDoctypePublic()); setOutputKey(props, OutputKeys.DOCTYPE_SYSTEM, params.getDoctypeSystem()); setOutputKey(props, OutputKeys.INDENT, params.getIndent()); setOutputKey(props, OutputKeys.OMIT_XML_DECLARATION, params.getOmitXmlDeclaration()); setOutputKey(props, OutputKeys.STANDALONE, params.getStandalone()); setOutputKey(props, OutputKeys.VERSION, params.getVersion()); return props; }
From source file:org.fireflow.clientwidget.FpdlExporter.java
public static String getXml(Node node, String encoding) { try {// www . j av a 2 s .c om Transformer tf = TransformerFactory.newInstance().newTransformer(); tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); tf.setOutputProperty(OutputKeys.ENCODING, encoding); tf.setOutputProperty(OutputKeys.INDENT, "yes"); tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); StreamResult dest = new StreamResult(new StringWriter()); tf.transform(new DOMSource(node), dest); return dest.getWriter().toString(); } catch (Exception e) { // ignore } return ""; }
From source file:org.fireflow.model.io.resource.ResourceSerializer.java
public static void serialize(List<ResourceDef> resources, OutputStream out, String charset) throws IOException, SerializerException { try {/* w w w . ja v a 2 s. c om*/ Document document = serializeToDOM(resources); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, charset); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, CDATA_SECTION_ELEMENT_LIST); transformer.transform(new DOMSource(document), new StreamResult(out)); out.flush(); } catch (TransformerConfigurationException e) { throw new SerializerException(e); } catch (TransformerException e) { throw new SerializerException(e); } finally { } }
From source file:org.fireflow.model.io.service.ServiceParser.java
public static void serialize(List<ServiceDef> services, OutputStream out, String charset) throws IOException, InvalidModelException, SerializerException { try {/*www .j a v a2 s . co m*/ Document document = serializeToDOM(services); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, charset); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, CDATA_SECTION_ELEMENT_LIST); transformer.transform(new DOMSource(document), new StreamResult(out)); out.flush(); } catch (TransformerConfigurationException e) { throw new SerializerException(e); } catch (TransformerException e) { throw new SerializerException(e); } finally { } }
From source file:org.fireflow.pdl.fpdl.io.FPDLSerializer.java
/** * xmloutString/* w w w . j a va 2s . co m*/ * @param workflowProcess * @param out * @return * @throws IOException * @throws SerializerException * @throws InvalidModelException */ public String serialize(WorkflowProcess workflowProcess, OutputStream out) throws IOException, SerializerException, InvalidModelException { try { Document document = serializeToDOM(workflowProcess); //?? Element root = document.getDocumentElement(); String displayname = root.getAttribute(DISPLAY_NAME); //============ TransformerFactory transformerFactory = TransformerFactory.newInstance(); if (JDK_TRANSFORMER_CLASS.equals(transformerFactory.getClass().getName())) { useJDKTransformerFactory = true; } Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, charset); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, CDATA_SECTION_ELEMENT_LIST); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.transform(new DOMSource(document), new StreamResult(out)); out.flush(); return charset; } catch (TransformerConfigurationException e) { throw new SerializerException(e); } catch (TransformerException e) { throw new SerializerException(e); } finally { } }
From source file:org.fireflow.pdl.fpdl20.io.FPDLSerializer.java
public void serialize(WorkflowProcess workflowProcess, OutputStream out) throws IOException, SerializerException, InvalidModelException { try {//from w w w. j av a2 s .co m Document document = serializeToDOM(workflowProcess); TransformerFactory transformerFactory = TransformerFactory.newInstance(); if (JDK_TRANSFORMER_CLASS.equals(transformerFactory.getClass().getName())) { useJDKTransformerFactory = true; } Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, charset); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, CDATA_SECTION_ELEMENT_LIST); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); transformer.transform(new DOMSource(document), new StreamResult(out)); out.flush(); } catch (TransformerConfigurationException e) { throw new SerializerException(e); } catch (TransformerException e) { throw new SerializerException(e); } finally { } }
From source file:org.fireflow.webdesigner.transformer.AbstractFpdlDiagramSerializer.java
public String serializeDiagramToStr(WorkflowProcess workflowProcess, String subProcessName, String encoding, boolean omitXmlDeclaration) { try {/*from w w w.jav a 2 s. c o m*/ Document doc = this.serializeDiagramToDoc(workflowProcess, subProcessName); Transformer tf = TransformerFactory.newInstance().newTransformer(); if (omitXmlDeclaration) { tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); } tf.setOutputProperty(OutputKeys.ENCODING, encoding); tf.setOutputProperty(OutputKeys.INDENT, "yes"); tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); StreamResult dest = new StreamResult(new StringWriter()); tf.transform(new DOMSource(doc), dest); return dest.getWriter().toString(); } catch (Exception e) { //TODO e.printStackTrace(); } return ""; }
From source file:org.firesoa.common.schema.DOMInitializer.java
public static String dom2String(Document dom) { try {//from www. j a va2s.c o m Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, Charset.defaultCharset().name()); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); // transformer.transform() XML Source? Result transformer.transform(new DOMSource(dom), new StreamResult(outputStream)); return outputStream.toString(); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:org.freecine.filmscan.Project.java
/** Save the project info in project directory (in file project.xml) @throws IOException if the project cannot be saved *//*from w w w. ja v a2 s . c o m*/ public void save() throws IOException { File f = File.createTempFile("tmproject", ".xml", dir); try { // Write the strip info to a file StreamResult streamResult = new StreamResult(f); SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); TransformerHandler hd = tf.newTransformerHandler(); Transformer serializer = hd.getTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); hd.setResult(streamResult); hd.startDocument(); writeXml(hd); hd.endDocument(); } catch (Exception e) { throw new IOException("Error saving project: " + e.getMessage(), e); } if (!f.renameTo(new File(dir, "project.xml"))) { // TODO: proper error handling log.warning("cound ot rename project file"); } }
From source file:org.freecine.filmscan.Project.java
private void saveStripInfo(ScanStrip strip, File file) { try {/* w w w . java 2s . c om*/ StreamResult streamResult = new StreamResult(file); SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); TransformerHandler hd = tf.newTransformerHandler(); Transformer serializer = hd.getTransformer(); serializer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); hd.setResult(streamResult); hd.startDocument(); strip.writeXml(hd); hd.endDocument(); } catch (SAXException ex) { log.severe("Error saving " + file.getAbsolutePath() + ": " + ex.getMessage()); } catch (TransformerConfigurationException ex) { log.severe("Error saving " + file.getAbsolutePath() + ": " + ex.getMessage()); } }