Simple function
File: Query.xquery
declare namespace math = "http://rntsoft.com";
declare function math:add($op1 as xs:integer, $op2 as xs:integer) as xs:integer
{
$op1 + $op2
};
declare variable $op1 as xs:integer := 1;
declare variable $op2 as xs:integer := 2;
{$op1}
{$op2}
{math:add($op1, $op2)}
Output:
1
2
3