List of utility methods to do XML Transform
String | transform(File xslt_source, File xml_source) Transforms the XML using an XSLT. return transform(new StreamSource(xslt_source), new StreamSource(xml_source)); |
void | transform(final File sourceXML, final File xslt, final File targetXML) transform Transformer transformer = createTransformer(xslt, Collections.<String, String>emptyMap()); Source source = new StreamSource(sourceXML); Result result = new StreamResult(targetXML); transformer.transform(source, result); |
String | transform(final Source xml, final Source xslt, final Map params, final Writer err) transform TransformerFactory factory = TransformerFactory.newInstance(); factory.setErrorListener(new ErrorListener() { public void warning(final TransformerException e) throws TransformerException { append(e.getMessageAndLocation()); public void error(final TransformerException e) throws TransformerException { append(e.getMessageAndLocation()); public void fatalError(final TransformerException e) throws TransformerException { append(e.getMessageAndLocation()); private void append(final String msg) { if (err != null) { try { err.append(msg + "\n"); } catch (IOException e) { e.printStackTrace(); }); Transformer transform = factory.newTransformer(xslt); if (params != null) { for (Iterator iter = params.entrySet().iterator(); iter.hasNext();) { Entry param = (Entry) iter.next(); transform.setParameter((String) param.getKey(), param.getValue()); StreamResult result = new StreamResult(new StringWriter()); transform.transform(xml, result); return result.getWriter().toString(); |
void | transform(InputStream styleSheet, InputStream xml, Writer out) transform TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource(styleSheet)); transformer.transform(new StreamSource(xml), new StreamResult(out)); |
void | transform(InputStream styleSheet, InputStream xml, Writer out) Transform input xml given a stylesheet. TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource(styleSheet)); transformer.transform(new StreamSource(xml), new StreamResult(out)); |
void | transform(InputStream xmlStream, InputStream xslStream, OutputStream outputStream) transform Source xmlStreamSource = new StreamSource(xmlStream); Source xslStreamSource = new StreamSource(xslStream); Result result = new StreamResult(outputStream); Transformer transformer = TransformerFactory.newInstance().newTransformer(xslStreamSource); transformer.transform(xmlStreamSource, result); |
void | transform(InputStream xslis, InputStream xmlis, OutputStream xmlos) transform try { TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xslis)); transformer.transform(new StreamSource(xmlis), new StreamResult(xmlos)); xslis.close(); xmlis.close(); xmlos.close(); } catch (Exception e) { ... |
boolean | transform(InputStream xsltInputStream, InputStream xmlInputStream, OutputStream outputStream, Map transform boolean result = false; try { Source source = new StreamSource(xsltInputStream); Transformer transformer = TransformerFactory.newInstance().newTemplates(source).newTransformer(); for (Entry<String, Object> entry : parameterMap.entrySet()) { transformer.setParameter(entry.getKey(), entry.getValue()); transformer.transform(new StreamSource(xmlInputStream), new StreamResult(outputStream)); ... |
void | transform(javax.xml.transform.Source source, javax.xml.transform.Result result, boolean indent) Executes a transformation. TransformerFactory factory = TransformerFactory.newInstance(); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); factory.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true); Transformer transformer = factory.newTransformer(); transformer.setOutputProperty(OutputKeys.ENCODING, DEFAULT_ENCODING); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); if (indent) { transformer.setOutputProperty(OutputKeys.INDENT, "yes"); ... |
void | transform(Reader source, Writer result, String style) This method will apply an XSLT transformation TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(new StreamSource(new StringReader(style))); transformer.transform(new StreamSource(source), new StreamResult(result)); |