List of usage examples for javax.xml.transform TransformerFactory getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.plasma.provisioning.xsd.AbstractAssembler.java
protected String serializeElement(ElementNSImpl nsElem) { String result = ""; TransformerFactory transFactory = TransformerFactory.newInstance(); log.debug("transformer factory: " + transFactory.getClass().getName()); //transFactory.setAttribute("indent-number", 2); Transformer idTransform = null; ByteArrayOutputStream stream = null; try {//from w w w . ja v a 2 s .co m idTransform = transFactory.newTransformer(); idTransform.setOutputProperty(OutputKeys.METHOD, "xml"); idTransform.setOutputProperty(OutputKeys.INDENT, "yes"); idTransform.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); Source input = new DOMSource(nsElem.getOwnerDocument()); stream = new ByteArrayOutputStream(); Result output = new StreamResult(stream); idTransform.transform(input, output); stream.flush(); result = new String(stream.toByteArray()); return result; } catch (TransformerConfigurationException e1) { log.error(e1.getMessage(), e1); } catch (TransformerException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.error(e.getMessage(), e); } finally { if (stream != null) try { stream.close(); } catch (Throwable t) { } } return result; }
From source file:org.plasma.provisioning.xsd.ConverterSupport.java
public String serializeElement(ElementNSImpl nsElem) { String result = ""; TransformerFactory transFactory = TransformerFactory.newInstance(); log.debug("transformer factory: " + transFactory.getClass().getName()); //transFactory.setAttribute("indent-number", 2); Transformer idTransform = null; ByteArrayOutputStream stream = null; try {/*from w w w .java 2 s . c om*/ idTransform = transFactory.newTransformer(); idTransform.setOutputProperty(OutputKeys.METHOD, "xml"); idTransform.setOutputProperty(OutputKeys.INDENT, "yes"); idTransform.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); Source input = new DOMSource(nsElem.getOwnerDocument()); stream = new ByteArrayOutputStream(); Result output = new StreamResult(stream); idTransform.transform(input, output); stream.flush(); result = new String(stream.toByteArray()); return result; } catch (TransformerConfigurationException e1) { log.error(e1.getMessage(), e1); } catch (TransformerException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.error(e.getMessage(), e); } finally { if (stream != null) try { stream.close(); } catch (Throwable t) { } } return result; }