Hi Bhavana!
As Ramkumar has already mentioned above you should use XSL with java extensions.
Create java class with static methods and call the required method within your xsl transformation.
Add namespace definition to your XSLT:
xmlns:myjava="com.company.xpi.mapping.xslt.XSLTUtils", where namespace name is the full qualified path to your java class including package name.
Call your java method:
<xsl:variable name="Var1" select="myjava:MyMethod()"/>, where "MyMethod()" is the required static method of your class.
By the way, the same approach is used to call lookups in XSL transformations.
Regards, Evgeniy.