List of usage examples for javax.xml.transform TransformerConfigurationException printStackTrace
@Override public void printStackTrace()
From source file:net.dinkla.mof2ecore.MOF2Ecore.java
/** * //www . ja va2 s. co m * @param fileXSL * @param fileInput * @param fileOutput */ public static void mof2ecore(String fileXSL, String fileInput, String fileOutput) { TransformerFactory tFactory = TransformerFactory.newInstance(); try { System.out.println("Processing " + fileInput); Transformer transformer = tFactory.newTransformer(new StreamSource(fileXSL)); transformer.setParameter("ecore_toplevel_package", namePackage); transformer.setParameter("ecore_container_suffix", suffixContainer); // TODO remove broken files and throw error transformer.transform(new StreamSource(fileInput), new StreamResult(new FileOutputStream(fileOutput))); System.out.println("Finished processing " + fileInput); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } }
From source file:fr.ece.epp.tools.Utils.java
public static void output(Node node, String filename) { TransformerFactory transFactory = TransformerFactory.newInstance(); try {/*from w w w .j av a 2 s . co m*/ Transformer transformer = transFactory.newTransformer(); transformer.setOutputProperty("encoding", "utf8"); transformer.setOutputProperty("indent", "yes"); DOMSource source = new DOMSource(); source.setNode(node); StreamResult result = new StreamResult(); if (filename == null) { result.setOutputStream(System.out); } else { result.setOutputStream(new FileOutputStream(filename)); } transformer.transform(source, result); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
From source file:com.bluexml.side.form.utils.DOMUtil.java
/** * Gets a DocumentTransformer object (in fact, a singleton), which is created if non existent. * /*from ww w . ja v a2 s. c o m*/ * @return */ public static Transformer getDocumentTransformer() { if (documentTransformer == null) { try { documentTransformer = TransformerFactory.newInstance().newTransformer(); } catch (TransformerConfigurationException e) { e.printStackTrace(); return null; } catch (TransformerFactoryConfigurationError e) { e.printStackTrace(); return null; } documentTransformer.setOutputProperty(OutputKeys.INDENT, "yes"); } return documentTransformer; }
From source file:org.geowebcache.config.XMLConfiguration.java
private static Node applyTransform(Node oldRootNode, String xslFilename) { DOMResult result = new DOMResult(); Transformer transformer;//from w w w . j ava 2s.c o m InputStream is = XMLConfiguration.class.getResourceAsStream(xslFilename); try { transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(is)); transformer.transform(new DOMSource(oldRootNode), result); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerFactoryConfigurationError e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } return result.getNode(); }
From source file:co.pugo.convert.Transformation.java
/** * helper method to setup transformer//w ww. j av a 2 s. c o m */ private void setupTransformer() { try { transformer = transformerFactory.newTransformer(new StreamSource(xsl)); } catch (TransformerConfigurationException e) { e.printStackTrace(); } }
From source file:org.openmrs.module.mksreports.web.controller.MKSReportsReportsManageController.java
public Transformer getTransformer(StreamSource streamSource) { // setup the xslt transformer net.sf.saxon.TransformerFactoryImpl impl = new net.sf.saxon.TransformerFactoryImpl(); try {//from w ww . j a va 2s . c om return impl.newTransformer(streamSource); } catch (TransformerConfigurationException e) { e.printStackTrace(); } return null; }
From source file:edu.lternet.pasta.client.SubscriptionUtility.java
/** * Transforms a quality report XML document to an HTML table. * //from ww w . ja va2 s . co m * @param xslPath * The path to the quality report XSL stylesheet. * * @return The HTML table as a String object. */ public String xmlToHtml(String xslPath) { String html = null; File styleSheet = new File(xslPath); StringReader stringReader = new StringReader(this.subscription); StringWriter stringWriter = new StringWriter(); StreamSource styleSource = new StreamSource(styleSheet); Result result = new StreamResult(stringWriter); Source source = new StreamSource(stringReader); try { Transformer t = TransformerFactory.newInstance().newTransformer(styleSource); t.transform(source, result); html = stringWriter.toString(); } catch (TransformerConfigurationException e) { logger.error(e.getMessage()); e.printStackTrace(); } catch (TransformerFactoryConfigurationError e) { logger.error(e.getMessage()); e.printStackTrace(); } catch (TransformerException e) { logger.error(e.getMessage()); e.printStackTrace(); } return html; }
From source file:edu.lternet.pasta.client.EmlUtility.java
private String emlReferenceExpander(String xslPath) throws ParseException { String xml = null;//from w w w . j ava 2 s. c o m File styleSheet = new File(xslPath); StringReader stringReader = new StringReader(this.eml); StringWriter stringWriter = new StringWriter(); StreamSource styleSource = new StreamSource(styleSheet); Result result = new StreamResult(stringWriter); Source source = new StreamSource(stringReader); try { Transformer t = TransformerFactory.newInstance().newTransformer(styleSource); t.transform(source, result); xml = stringWriter.toString(); } catch (TransformerConfigurationException e) { logger.error(e.getMessage()); e.printStackTrace(); } catch (TransformerFactoryConfigurationError e) { logger.error(e.getMessage()); e.printStackTrace(); } catch (TransformerException e) { logger.error(e.getMessage()); e.printStackTrace(); throw new ParseException("EML Parse Error: " + e.getMessage(), 0); } return xml; }
From source file:com.oprisnik.semdroid.SemdroidServlet.java
public String getResults(SemdroidReport results, InputStream transformationStyle) { try {/*from w ww . j av a 2 s . c om*/ Document doc = XmlUtils.createDocument(); Element rootElement = doc.createElement("AnalysisResults"); doc.appendChild(rootElement); XmlUtils.addResults(results, doc, rootElement); StringWriter writer = new StringWriter(); TransformerFactory transformerFactory = TransformerFactory.newInstance(); StreamSource stylesource = new StreamSource(transformationStyle); Transformer transformer = transformerFactory.newTransformer(stylesource); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(writer); transformer.transform(source, result); return writer.toString(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); log.warning("Exception: " + pce.getMessage()); log.throwing(this.getClass().getName(), "getResults", pce); } catch (TransformerConfigurationException e) { e.printStackTrace(); log.warning("Exception: " + e.getMessage()); log.throwing(this.getClass().getName(), "getResults", e); } catch (TransformerException e) { e.printStackTrace(); log.warning("Exception: " + e.getMessage()); log.throwing(this.getClass().getName(), "getResults", e); } return null; }
From source file:elaborate.editor.export.tei.TeiMaker.java
public String toXML() { if (tei == null) { return null; }//from www .j a v a 2 s. com TransformerFactory transfac = TransformerFactory.newInstance(); try { DOMSource source = new DOMSource(tei); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); trans.setOutputProperty(OutputKeys.INDENT, "no"); StringWriter sw = new StringWriter(); StreamResult result = new StreamResult(sw); trans.transform(source, result); return sw.toString().replace("interpgrp>", "interpGrp>").replaceAll(" +<lb/>", "<lb/>"); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } return null; }