Hi Kalyan,
It would be easier to implement in UDF (java code) in message mapping. I would suggest to use graphical mapping unless you have specific requirement to use XSLT.
refer the below discussion for Java udf
PI mapping: concatenating multiple records to just one field
regards,
Harish