use of javax.xml.transform.TransformerFactory in project AndroidAsync by koush.
the class DocumentBody method prepare.
private void prepare() {
if (bout != null)
return;
try {
DOMSource source = new DOMSource(document);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
bout = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(bout, Charsets.UTF_8);
StreamResult result = new StreamResult(writer);
transformer.transform(source, result);
writer.flush();
} catch (Exception e) {
}
}
use of javax.xml.transform.TransformerFactory in project jop by jop-devel.
the class XmlBuilder method writeDom.
/**
* @param dom
* @param s
* @throws TransformerFactoryConfigurationError
* @throws XmlSerializationException
*/
public static void writeDom(Document dom, Writer s) throws TransformerFactoryConfigurationError, XmlSerializationException {
DOMSource domSource = new DOMSource(dom);
StreamResult streamResult = new StreamResult(s);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer;
try {
serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "http://www.it.uu.se/research/group/darts/uppaal/flat-1_1.dtd");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.transform(domSource, streamResult);
} catch (Exception e) {
throw new XmlSerializationException("Error in domToString()", e);
}
}
use of javax.xml.transform.TransformerFactory in project spring-framework by spring-projects.
the class StaxSourceTests method setUp.
@Before
public void setUp() throws Exception {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformer = transformerFactory.newTransformer();
inputFactory = XMLInputFactory.newInstance();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
}
use of javax.xml.transform.TransformerFactory in project camel by apache.
the class TemplatesFactoryTest method testInstantiateAnInstanceOfTemplates.
@Test
public void testInstantiateAnInstanceOfTemplates() throws Exception {
TemplatesFactory fac = TemplatesFactory.newInstance();
TransformerFactory factory = new TransformerFactoryImpl();
factory.setURIResolver(new ClassPathURIResolver(Constants.SCHEMATRON_TEMPLATES_ROOT_DIR, null));
Templates templates = fac.getTemplates(ClassLoader.getSystemResourceAsStream(rules), factory);
Assert.assertNotNull(templates);
}
use of javax.xml.transform.TransformerFactory in project camel by apache.
the class SaxonUriResolverTest method test.
@Test
public void test() throws Exception {
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
Source xsl = fromClasspath(XSL_PATH);
xsl.setSystemId("classpath:/" + XSL_PATH);
Source xml = fromString(XML_DATA);
TransformerFactory factory = new TransformerFactoryImpl();
Transformer transformer = factory.newTransformer(xsl);
transformer.setURIResolver(new XsltUriResolver(context(), XSL_PATH));
transformer.transform(xml, result);
Assert.assertEquals(XML_RESP, writer.toString());
}
Aggregations