class XslOutputProvider {

    public ByteArrayOutputStream getOutput(final XsltTransformer xsltTransformer) {
        Serializer serializer = serializerFactory.createSerializer();
        serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
        serializer.setOutputProperty(Serializer.Property.INDENT, "no");
        ByteArrayOutputStream output = byteArrayOutputStreamFactory.createByteArrayOutputStream();
        serializer.setOutputStream(output);
        xsltTransformer.setDestination(serializer);
        return output;
    }

}