Hi Rashmi,
I think the main problem was that you have to write the output stream in the variable TransformationOutput out, this variable is taken by PI mapping engine like java mapping output but you have used a StreamResult variable not linked by PI as java mapping output.
Regards.