try { trans = xslt.newTransformer(); trans.setErrorListener(new XMLListener());
/** Transforms the given XML data using the specified XSLT stylesheet. */ public static String transformXML(Source xmlSource, Templates xslt) throws IOException { Transformer trans; try { trans = xslt.newTransformer(); trans.setErrorListener(new XMLListener()); } catch (TransformerConfigurationException exc) { IOException e = new IOException(); e.initCause(exc); throw e; } StringWriter xmlWriter = new StringWriter(); StreamResult xmlResult = new StreamResult(xmlWriter); try { trans.transform(xmlSource, xmlResult); } catch (TransformerException exc) { IOException e = new IOException(); e.initCause(exc); throw e; } return xmlWriter.toString(); }
private static TransformerFactory createTransformFactory() { TransformerFactory factory = TransformerFactory.newInstance(); factory.setErrorListener(new XMLListener()); return factory; };
private static TransformerFactory createTransformFactory() { TransformerFactory factory = TransformerFactory.newInstance(); factory.setErrorListener(new XMLListener()); return factory; };