I'm creating an integration solution with Java that filters and modify huge XML files. Those XML files are inputted as a payload document through the solution and to do a big filter in the parts that are interesting for me I want to use XSLT stylesheet. My difficult is that the default Java solution for this does not work for me (XSLT processing with Java?) as I do not want to take the XML from the system, once it is already in the workflow of the solution, and I need the output source to stay in the workflow.
Element production = docX2.createElement("PRODUCTION");
try {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource("slimmer.xslt");
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource((InputStream) docX1);
transformer.transform(text, new StreamResult((OutputStream) production));
} catch (Exception ex) {
Logger.getLogger(IntProcess.class.getName()).log(Level.SEVERE, null, ex);
}
root.appendChild(production);
docX1 is the XML input document that is flowing through the solution, and docX2 is the output document (both are Document class in Java). Production is a tag element from docX2.