I've been working on a webservice that prints the content of a table as XML - I used a WebRowSet to do this.
response.setContentType("text/xml");
WebRowSet webRowSet = new WebRowSetImpl();
webRowSet.writeXml(resultSet, response.getWriter());
(HttpServletResponse response)
While this much works fine, I simply can't figure out howto apply a Stylesheet to the XML. I tried to use a transformer to do this.
webRowSet.writeXml(resultSet, OutputStream);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(new StreamSource("file.xsl"));
transformer.transform(new StreamSource(InputStream),
new StreamResult(response.getWriter()));
I fail to understand what the OutputStream in writeXml and the InputStream in the StreamSource would be. (I don't want to save the data in a file)
I've found a question that might be related?
An explanation of how I could solve this problem would be very appreciated.