class SequenceAwareXslTransformer {

    public byte[] transform(final InputStream xslInputStream, final InputStream requestInputStream, final InputStream templateInputStream,
            final Map<String, String> nameToXml) throws SaxonApiException, SAXException {
        Processor processor = processorFactory.createProcessor();
        XMLReader xmlReader = createXMLReader();
        //xsl compilation
        XsltExecutable xsltExecutable = xslCompiler.compileXsl(xslInputStream, processor);
        XsltTransformer xsltTransformer = xsltExecutable.load();
        //set the output
        ByteArrayOutputStream output = xslOutputProvider.getOutput(xsltTransformer);
        //set the request
        setRequest(requestInputStream, processor, xsltTransformer);
        setSessionEntities(nameToXml, processor, xsltTransformer);
        //set the template
        setTemplate(templateInputStream, processor, xmlReader, xsltTransformer);
        xsltTransformer.transform();
        return output.toByteArray();
    }

}