class XslResponseGenerator {

    public byte[] generateResponse(final byte[] requestXml, final byte[] xsl, final byte[] template) {
        byte[] result = null;
        InputStream requestInputStream = inputStreamFactory.createByteArrayInputStream(requestXml);
        InputStream xslInputStream = inputStreamFactory.createByteArrayInputStream(xsl);
        InputStream templateInputStream = inputStreamFactory.createByteArrayInputStream(template);
        try {
            result = transformer.transform(xslInputStream, requestInputStream, templateInputStream);
        } catch (Exception e) {
            throw new ResponseFormattingFailedException("Template formatting failed with xslt:" + xsl, e);
        }
        return result;
    }

}